pycollision.geometry

geometry library defines some linear algebra routines which were used by the objects and collision algorithms

pycollision.geometry.angle_between_vectors(x, v, w)

calculates the angle bewteen 2 given vectors, taking care of rounding errors for the norm! Basically it the the angle between x and v, but these gives sometimes the same angle if x is mirrored by v, so the orthogonal vector w is then giving with is sign the left or right side of v! The angle may be not mathematically correct, but it is only used for sorting!

pycollision.geometry.distance_to_plane(v, plane_norm, plane_dist)

calculate the distance from a point v to the plane given by the normal vector and the distance

pycollision.geometry.get_center_of_points_3D(points)

calculates a center point for the given point array, using a simple approach of calculating the middle of the min and max values for all 3 dimensions

pycollision.geometry.intersection_line_plane(edge, norm_vector, distance, atol=1e-08)

calculates the intersection point between a ray and a plane

pycollision.geometry.orthogonal_vector(plane_norm, atol=1e-08)

calculates one pseudo-random vector which is orthogonal to the plane_norm vector

pycollision.geometry.plane_vectors(plane_norm, atol=1e-08)

plane vectors

calculate two spanning vectors for the plane given by the norm_vector

pycollision.geometry.point_of_plane(plane_norm, plane_dist, atol=1e-08)

calculates a random point on the plane

pycollision.geometry.point_of_plane_random(norm, dist, rvalue, atol=1e-08)

point_of_plane

calculates a random point on the plane

pycollision.geometry.polygon_sort(points, norm_vector, atol=1e-08)

sort the array of points to form a polygon which is on the plane given by the norm_vector

First Idea is to use scipy.spatial.ConvexHull , but in the end, there is a much simply algorithm which do not base on any external extra package

pycollision.geometry.projection_vector(v, ref)

calculate the vector projection of v on ref

Parameters
  • v – 3d vector v

  • ref – 3d vector on which v should be projected

pycollision.geometry.pyramid_volume(plane, height)

calculate the volume of a Pyramid

Parameters
  • plane – array of the 4 corners given by a 3d vector

  • height – 3d vector to the height point