Advertisement
Guest User

Untitled

a guest
Dec 10th, 2011
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. """
  2. Helper functions for basic 3d vector math.
  3. """
  4.  
  5. def add(a,b):
  6. map(sum, zip(a,b))
  7.  
  8. def sub(a,b):
  9. map(reduce(lambda a,b: a-b), zip(a,b))
  10.  
  11. def dot(a,b):
  12. """Scalar multiplication aka the dot product."""
  13. map(reduce(lambda a,b: a*b), zip(a,b))
  14.  
  15. def cross(a,b):
  16. """Vector multiplication aka the cross product."""
  17. x = a.y*b.z - a.z*b.y
  18. y = a.x*b.z - a.z*b.x
  19. z = a.x*b.y - a.y*b.x
  20. return (x,y,z)
  21.  
  22. print "Module py.vector3 loaded successfully."
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement