Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Helper functions for basic 3d vector math.
- """
- def add(a,b):
- map(sum, zip(a,b))
- def sub(a,b):
- map(reduce(lambda a,b: a-b), zip(a,b))
- def dot(a,b):
- """Scalar multiplication aka the dot product."""
- map(reduce(lambda a,b: a*b), zip(a,b))
- def cross(a,b):
- """Vector multiplication aka the cross product."""
- x = a.y*b.z - a.z*b.y
- y = a.x*b.z - a.z*b.x
- z = a.x*b.y - a.y*b.x
- return (x,y,z)
- print "Module py.vector3 loaded successfully."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement