Skip to content

Instantly share code, notes, and snippets.

View SamyBencherif's full-sized avatar

Samie Bee SamyBencherif

View GitHub Profile
@SamyBencherif
SamyBencherif / Fling.py
Created February 5, 2015 19:55
Fling.py
from scene import *
from random import random
import math
def intersect(a, b):
import math
if (a.w==0 and b.w==0):
return None
try:
@SamyBencherif
SamyBencherif / Curve Fit.py
Created February 17, 2015 19:03
Curve Fit.py
"""
Curve Fit
Gives a point function that intersects any given set of points.
Eg.
(1,1),(2,2) -> (0t^2+1t^1+0t^0,0t^2+1t^1+0t^0)
Written by Samy Bencherif
Using Pythonista for iOS
@SamyBencherif
SamyBencherif / Fling.py
Created February 25, 2015 05:03
Fling.py
"""
100% of this code was written and tested in the Pythonista iOS app
"""
from scene import *
from random import random
import math
def intersect(a, b):
"""
100% of this code was written and tested in the Pythonista iOS app
"""
from scene import *
from random import random
import math
def intersect(a, b):
@SamyBencherif
SamyBencherif / Cube.py
Last active August 29, 2015 14:20
Cube.py
# Created by Samy Bencherif
# Runs in Pythonista for iOS
from scene import *
from math import *
from random import random
def transform(point, transformationVector):
k = [0]*max(len(point), len(transformationVector))
for i in range(max(len(point), len(transformationVector))):
from scene import *
from math import *
CUBE = [ [(-1, 1, -1), (1, 1, -1), (1, -1, -1), (-1, -1, -1)], #front face
[(1, 1, -1), (1, 1, 1), (1, -1, 1), (1, -1, -1)], #right face
[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1)], #top face
[(-1, -1, -1), (1, -1, -1), (1, -1, 1), (-1, -1, 1)], #bottom face
[(-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1)], #left face
[(-1, 1, 1), (1, 1, 1), (1, -1, 1), (-1, -1, 1)], #back face
]
@SamyBencherif
SamyBencherif / Energy Animation.py
Created March 3, 2016 21:43
Energy Animation.py
# coding: utf-8
from scene import *
from random import *
from math import *
def mag(v):
return (v.x**2+v.y**2)**.5
class MyScene (Scene):
int w, h;
/*
This program is based off of Daniel Shiffman's Perlin
Noise Terrain Generation Demo, found here:
https://www.youtube.com/watch?v=IKB1hWWedMk
The goal of this program is to demonstrate that
the issue where the terrain appears to be undulating
@SamyBencherif
SamyBencherif / bbin.py
Last active January 16, 2018 03:15
Better Binary Output Python (from a trashy one-liner)
bbin = lambda x: ''.join([' '+x if i%4==0 and i!=0 else x for i,x in enumerate(bin(x)[2:].zfill((len(bin(x))-2-1)/4*4+4))])
print(bbin(8039)) #0001 1111 0110 0111