pyggel.math3d
index
c:\python25\lib\site-packages\pyggel\math3d.py

pyggle.math3d
This library (PYGGEL) is licensed under the LGPL by Matthew Roe and PYGGEL contributors.
 
The math3d module contains general 3d math functions, as well as collision detection primitives.

 
Modules
       
math

 
Classes
       
__builtin__.object
Vector
AABox
Sphere

 
class AABox(Vector)
    A simple, axis-aligned Cube object - same as Vector except has a size(width/height/depth)
 
 
Method resolution order:
AABox
Vector
__builtin__.object

Methods defined here:
__init__(self, pos, size)
Create the AABox
pos must be a three part tuple of the position of the AABox
size must be either a number representing the size of the AABox - if all sides are equal,
    otherwise, must be a three-part tuple representing the size of each direction of the AABox
collide(self, other)
Return whether this AABox is colliding with another object

Data and other attributes defined here:
ctype = 'AABox'

Methods inherited from Vector:
__abs__(self)
Returns a Vector representing this Vector's absolute position
__add__(self, other)
Return a Vector representing this Vector adding other Vector
__div__(self, other)
Return a Vector representing this Vector divided by other Vector
__eq__(self, other)
Return whether this Vector is at the same position as other Vector
__iadd__(self, other)
Adds other Vector to this Vector
__idiv__(self, other)
Divides this Vector by other Vector
__imul__(self, other)
Multiplies this Vector by other Vector
__isub__(self, other)
Subtracts other Vector from this Vector
__mul__(self, other)
Return a Vector representing this Vector multiplying other Vector
__ne__(self, other)
Return whether this Vector is not at the same position as other Vector
__neg__ = invert(self)
Return an inverted Vector
__nonzero__(self)
Return whether this Vector is not at (0,0,0)
__pow__(self, other)
Return a Vector representing this Vector raised to other Vector
__radd__ = __add__(self, other)
Return a Vector representing this Vector adding other Vector
__rdiv__(self, other)
Returns a Vector representing other Vector divided by this Vector
__rmul__ = __mul__(self, other)
Return a Vector representing this Vector multiplying other Vector
__rpow__(self, other)
Return other Vector raised to this Vector
__rsub__(self, other)
Returns a Vector representing other Vector subtracting this Vector
__sub__(self, other)
Return a Vector representing this Vector subtracting other Vector
angle(self, other)
Return the angle between this vector and another
copy(self)
Return a copy of the Vector
cross(self, other)
Return the cross product between this Vector and other Vector
distance(self, other)
Return the distance between this Vector and other Vector
dot(self, other)
Return the dot product between this Vector and other Vector
fast_distance(self, other)
Return the distance between this Vector and other Vector.
This method is the same as distance, except it does not sqrt the result,
so the comparison must be squared to be accurate, but it is faster.
fast_length(self)
Return the fast_distance of this Vector from (0,0,0)
get_plane_distance(self, plane)
get_pos(self)
Return the position of this Vector as a tuple
in_frustum(self, frustum)
invert(self)
Return an inverted Vector
length(self)
Return the distance of this Vector from (0,0,0)
magnitude(self)
Return the magnititude of the Vector
normalize(self)
Return a normalized Vector
perpendicular(self)
Return a perpendicular Vector
rotate(self, vec, amount)
Return a new Vector that represents this Vector rotated around Vector vec by amount.
vec must be another Vector
amount must be a three part tuple representing the rotation amount in 3d space
Warning - this method seems to be a little buggy, and does not match the other rotations in PYGGEL!
set_pos(self, pos)
Set the position of this Vector from a tuple

Data descriptors inherited from Vector:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Sphere(Vector)
    A simple Sphere object - same as Vector except has a radius
 
 
Method resolution order:
Sphere
Vector
__builtin__.object

Methods defined here:
__init__(self, pos, radius)
Create the Sphere
pos must be a three part tuple of the position of the Sphere
radius must be a positive number
collide(self, other)
Return whether this Sphere is colliding with another object
in_frustum(self, frustum)

Data and other attributes defined here:
ctype = 'Sphere'

Methods inherited from Vector:
__abs__(self)
Returns a Vector representing this Vector's absolute position
__add__(self, other)
Return a Vector representing this Vector adding other Vector
__div__(self, other)
Return a Vector representing this Vector divided by other Vector
__eq__(self, other)
Return whether this Vector is at the same position as other Vector
__iadd__(self, other)
Adds other Vector to this Vector
__idiv__(self, other)
Divides this Vector by other Vector
__imul__(self, other)
Multiplies this Vector by other Vector
__isub__(self, other)
Subtracts other Vector from this Vector
__mul__(self, other)
Return a Vector representing this Vector multiplying other Vector
__ne__(self, other)
Return whether this Vector is not at the same position as other Vector
__neg__ = invert(self)
Return an inverted Vector
__nonzero__(self)
Return whether this Vector is not at (0,0,0)
__pow__(self, other)
Return a Vector representing this Vector raised to other Vector
__radd__ = __add__(self, other)
Return a Vector representing this Vector adding other Vector
__rdiv__(self, other)
Returns a Vector representing other Vector divided by this Vector
__rmul__ = __mul__(self, other)
Return a Vector representing this Vector multiplying other Vector
__rpow__(self, other)
Return other Vector raised to this Vector
__rsub__(self, other)
Returns a Vector representing other Vector subtracting this Vector
__sub__(self, other)
Return a Vector representing this Vector subtracting other Vector
angle(self, other)
Return the angle between this vector and another
copy(self)
Return a copy of the Vector
cross(self, other)
Return the cross product between this Vector and other Vector
distance(self, other)
Return the distance between this Vector and other Vector
dot(self, other)
Return the dot product between this Vector and other Vector
fast_distance(self, other)
Return the distance between this Vector and other Vector.
This method is the same as distance, except it does not sqrt the result,
so the comparison must be squared to be accurate, but it is faster.
fast_length(self)
Return the fast_distance of this Vector from (0,0,0)
get_plane_distance(self, plane)
get_pos(self)
Return the position of this Vector as a tuple
invert(self)
Return an inverted Vector
length(self)
Return the distance of this Vector from (0,0,0)
magnitude(self)
Return the magnititude of the Vector
normalize(self)
Return a normalized Vector
perpendicular(self)
Return a perpendicular Vector
rotate(self, vec, amount)
Return a new Vector that represents this Vector rotated around Vector vec by amount.
vec must be another Vector
amount must be a three part tuple representing the rotation amount in 3d space
Warning - this method seems to be a little buggy, and does not match the other rotations in PYGGEL!
set_pos(self, pos)
Set the position of this Vector from a tuple

Data descriptors inherited from Vector:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Vector(__builtin__.object)
    A simple, 3d Vector class
 
  Methods defined here:
__abs__(self)
Returns a Vector representing this Vector's absolute position
__add__(self, other)
Return a Vector representing this Vector adding other Vector
__div__(self, other)
Return a Vector representing this Vector divided by other Vector
__eq__(self, other)
Return whether this Vector is at the same position as other Vector
__iadd__(self, other)
Adds other Vector to this Vector
__idiv__(self, other)
Divides this Vector by other Vector
__imul__(self, other)
Multiplies this Vector by other Vector
__init__(self, pos)
Create the Vector
pos must be a three part tuple of the position of the Vector
__isub__(self, other)
Subtracts other Vector from this Vector
__mul__(self, other)
Return a Vector representing this Vector multiplying other Vector
__ne__(self, other)
Return whether this Vector is not at the same position as other Vector
__neg__ = invert(self)
__nonzero__(self)
Return whether this Vector is not at (0,0,0)
__pow__(self, other)
Return a Vector representing this Vector raised to other Vector
__radd__ = __add__(self, other)
__rdiv__(self, other)
Returns a Vector representing other Vector divided by this Vector
__rmul__ = __mul__(self, other)
__rpow__(self, other)
Return other Vector raised to this Vector
__rsub__(self, other)
Returns a Vector representing other Vector subtracting this Vector
__sub__(self, other)
Return a Vector representing this Vector subtracting other Vector
angle(self, other)
Return the angle between this vector and another
collide(self, other)
Return whether this Vector collides with another object
copy(self)
Return a copy of the Vector
cross(self, other)
Return the cross product between this Vector and other Vector
distance(self, other)
Return the distance between this Vector and other Vector
dot(self, other)
Return the dot product between this Vector and other Vector
fast_distance(self, other)
Return the distance between this Vector and other Vector.
This method is the same as distance, except it does not sqrt the result,
so the comparison must be squared to be accurate, but it is faster.
fast_length(self)
Return the fast_distance of this Vector from (0,0,0)
get_plane_distance(self, plane)
get_pos(self)
Return the position of this Vector as a tuple
in_frustum(self, frustum)
invert(self)
Return an inverted Vector
length(self)
Return the distance of this Vector from (0,0,0)
magnitude(self)
Return the magnititude of the Vector
normalize(self)
Return a normalized Vector
perpendicular(self)
Return a perpendicular Vector
rotate(self, vec, amount)
Return a new Vector that represents this Vector rotated around Vector vec by amount.
vec must be another Vector
amount must be a three part tuple representing the rotation amount in 3d space
Warning - this method seems to be a little buggy, and does not match the other rotations in PYGGEL!
set_pos(self, pos)
Set the position of this Vector from a tuple

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
ctype = 'Vector'

 
Functions
       
calcTriNormal(t1, t2, t3, flip=False)
Return a normal for lighting based on 3 points.
Code provided by Ian Mallet.
get_distance(a, b)
Return the distance between two points
move_with_rotation(pos, rot, amount)
Returns a new position that is calculated based on
the old pos, moved by amount according to rot facing.
pos is the original position we are moving from,
rot is the 3d rotation of the object - can be one value or a three part tuple
amount is how much to move by