#include <CompGeom.h>
Public Types | |
| enum | SegSegIntersectType { SegSegNoIntersect, SegSegIntersect, SegSegVertex, SegSegEdge } |
| enum | SegTriIntersectType { SegTriNoIntersect, SegTriInclFace, SegTriInclVertex, SegTriInclEdge, SegTriInside, SegTriVertex, SegTriEdge, SegTriFace, SegTriEdgeOverlap, SegTriPlanarIntersect } |
| enum | SegPlaneIntersectType { SegPlaneInPlane, SegPlaneToSide, SegPlaneFirst, SegPlaneSecond, SegPlaneOtherIntersect } |
| enum | PolygonLocation { PolygonInside, PolygonOutside, PolygonOnVertex, PolygonOnEdge } |
| enum | SegBoxIntersectType { SegBoxNoIntersect, SegBoxFullyInside, SegBoxPartiallyInside, SegBoxSurfaceIntersect, SegBoxPointIntersect, SegBoxPassThrough } |
Static Public Member Functions | |
| static Vector3 | generate_point_on_plane (const Vector3 &normal, Real d) |
| Generates a point on a plane. | |
| static SegBoxIntersectType | intersect_seg_box (const Vector3 &lo, const Vector3 &hi, const std::pair< Vector3, Vector3 > &seg, Vector3 &isect1, Vector3 &isect2) |
| Intersects a line segment with a box. | |
| static bool | is_convex_polygon (const std::list< Vector3 > &polygon, const Vector3 &normal) |
| Determines whether a polygon is convex. | |
| static std::list< TrianglePtr > | triangulate_convex_polygon (const std::list< Vector3 > &polygon) |
| Triangulates a convex polygon in O(n). | |
| static bool | intersect_noncoplanar_tris (const Triangle &t1, const Triangle &t2, Vector3 &p1, Vector3 &p2) |
| Intersects two non-coplanar triangles in 3D and returns the line of intersection. | |
| static boost::shared_ptr< std::list< Vector3 > > | intersect_tris (const Triangle &t1, const Triangle &t2) |
| Intersects two triangles in 3D and returns the points of intersection. | |
| static Real | fit_plane (const std::list< Vector3 > &points, Vector3 &normal, Real &d) |
| Attempts to fit a plane to a set of points. | |
| static SegTriIntersectType | intersect_seg_tri (const Triangle &t, const std::pair< Vector3, Vector3 > &seg, Vector3 &isect, Vector3 &isect2) |
| Determines the intersection between a line segment and triangle in 3D. | |
| static SegSegIntersectType | intersect_segs_3D (const std::pair< Vector3, Vector3 > &s1, const std::pair< Vector3, Vector3 > &s2, Vector3 &isect, Vector3 &isect2) |
| Determines whether two line segments in 3D intersect. | |
| static SegPlaneIntersectType | intersect_seg_plane (const Triangle &tri, const std::pair< Vector3, Vector3 > &seg, Vector3 &isect, unsigned int &big_dim) |
| Determines the intersection between a line segment and a plane in 3D. | |
| static boost::shared_ptr< std::list< Vector3 > > | calc_convex_hull_2D (const std::list< Vector3 > &points, const VectorN &normal) |
| Calculates the convex hull of a set of points that lie on a 2D manifold using quickhull. | |
| static PolyhedronPtr | calc_convex_hull_3D (const std::list< Vector3 > &points) |
| Calculates the convex hull of points in 3D using quickhull. | |
| static boost::shared_ptr< std::list< Vector3 > > | intersect_coplanar_tris (const Triangle &t1, const Triangle &t2, const Vector3 &normal, Real d) |
| Intersects two coplanar triangles. | |
| static SegSegIntersectType | intersect_segs_2D (const std::pair< Vector2, Vector2 > &s1, const std::pair< Vector2, Vector2 > &s2, Vector2 &isect, Vector2 &isect2) |
| Determines whether two line segments in 2D intersect. | |
| static PolygonLocation | polygon_location (const std::list< Vector2 > &polygon, const Vector2 &point) |
| Determines whether a 2D point is inside a polygon. | |
| static bool | collinear (const Vector3 &a, const Vector3 &b, const Vector3 &c) |
| Determines whether three points are collinear. | |
| static bool | collinear (const Vector2 &a, const Vector2 &b, const Vector2 &c) |
| Determines whether three points are collinear. | |
| static LongReal | volume (const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector3 &d) |
| Gets the volume of a tetrahedron composed of vertices a, b, c, d. | |
| static int | volume_sign (const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector3 &d) |
| Gets the sign of the volume of a tetrahedron composed of vertices a, b, c, d. | |
| static Vector3 | calc_centroid_2D (const std::list< Vector3 > &poly, const Vector3 &normal) |
| Computes the 3D (2D) centroid of points on a plane. | |
| static void | project_plane (std::list< Vector3 > &points, const Vector3 &normal, Real d) |
| Projects a set of points onto a plane. | |
| static bool | coplanar (const Triangle &t1, const Triangle &t2) |
| Determines whether two triangles are coplanar. | |
| static Real | calc_area (const std::list< Vector3 > &poly, const Vector3 &normal) |
| Computes the area of points on a plane. | |
| static Vector3 | to_3D (const Vector2 &v) |
| Converts a 2D vector to a 3D vector. | |
| static Vector3 | to_3D (const Vector2 &v, Real d) |
| Converts a 2D vector to a 3D vector. | |
| static Vector2 | to_2D (const Vector3 &v) |
| Converts a 3D vector to a 2D vector. | |
| static void | det_line_endpoints (std::list< Vector3 > &points, std::pair< Vector3, Vector3 > &endpoints) |
| Determines the two endpoints of a set of colinear points (in time n lg n). | |
| static void | det_line_endpoints (std::list< Vector2 > &points, std::pair< Vector2, Vector2 > &endpoints) |
| Determines the two endpoints of a set of colinear points (in time n lg n). | |
| static bool | query_intersect_tri_tri (const Triangle &t1, const Triangle &t2) |
| template<class ForwardIterator> | |
| static bool | collinear (ForwardIterator first, ForwardIterator last) |
| Determines whether a set of points is collinear. | |
| template<class ForwardIterator> | |
| static PolyhedronPtr | calc_convex_hull_3D (ForwardIterator first, ForwardIterator last) |
| Computes the 3D convex hull of a set of points. | |
| template<class ForwardIterator> | |
| static Vector3 | calc_centroid (ForwardIterator first, ForwardIterator last) |
| Computes the centroid of a set of facets. | |
| CompGeom::SegBoxIntersectType CompGeom::intersect_seg_box | ( | const Vector3 & | lo, | |
| const Vector3 & | hi, | |||
| const std::pair< Vector3, Vector3 > & | seg, | |||
| Vector3 & | isect1, | |||
| Vector3 & | isect2 | |||
| ) | [static] |
Intersects a line segment with a box.
| lo | the lower corner of the box | |
| hi | the upper corner of the box | |
| seg | the line segment to query | |
| isect1 | the first point of intersection (if not SegBoxNoIntersect) | |
| isect2 | the second point of intersection (if SegBoxPartiallyInside, SegBoxFullyInside, SegBoxPassThrough, or SegBoxSurfaceIntersect) |
| std::list< TrianglePtr > CompGeom::triangulate_convex_polygon | ( | const std::list< Vector3 > & | polygon | ) | [static] |
Triangulates a convex polygon in O(n).
| polygon | a connected, counter-clockwise oriented, convex polygon; additionally, the first point is assumed to be connected to the last) |
| bool CompGeom::intersect_noncoplanar_tris | ( | const Triangle & | t1, | |
| const Triangle & | t2, | |||
| Vector3 & | p1, | |||
| Vector3 & | p2 | |||
| ) | [static] |
Intersects two non-coplanar triangles in 3D and returns the line of intersection.
| t1 | the first triangle | |
| t2 | the second triangle | |
| p1 | an endpoint of the line of intersection (on return) | |
| p2 | an endpoint of the line of intersection (on return) |
| boost::shared_ptr< std::list< Vector3 > > CompGeom::intersect_tris | ( | const Triangle & | t1, | |
| const Triangle & | t2 | |||
| ) | [static] |
Intersects two triangles in 3D and returns the points of intersection.
| Real CompGeom::fit_plane | ( | const std::list< Vector3 > & | points, | |
| Vector3 & | normal, | |||
| Real & | d | |||
| ) | [static] |
Attempts to fit a plane to a set of points.
The singular value decomposition is used to determine the plane that fits the points best in a least-squares sense.
| points | the set of points (in 3D) | |
| normal | contains the "best" normal, on return |
| CompGeom::SegTriIntersectType CompGeom::intersect_seg_tri | ( | const Triangle & | t, | |
| const std::pair< Vector3, Vector3 > & | seg, | |||
| Vector3 & | isect, | |||
| Vector3 & | isect2 | |||
| ) | [static] |
Determines the intersection between a line segment and triangle in 3D.
Adapted from O'Rourke, p. 238.
| t | a triangle in 3D | |
| seg | a line segment in 3D | |
| isect | contains the point of intersection, if any (on return) | |
| isect2 | contains a second point of intersect, if the intersection type is seg_tri_inside, seg_tri_edge_overlap, or seg_tri_planar_intersect (on return) |
| CompGeom::SegSegIntersectType CompGeom::intersect_segs_3D | ( | const std::pair< Vector3, Vector3 > & | s1, | |
| const std::pair< Vector3, Vector3 > & | s2, | |||
| Vector3 & | isect, | |||
| Vector3 & | isect2 | |||
| ) | [static] |
Determines whether two line segments in 3D intersect.
| s1 | the points of the first line segment | |
| s2 | the points of the second line segment | |
| isect | the point of intersection (if any) | |
| isect2 | the second point of intersection (for edge intersection) |
| CompGeom::SegPlaneIntersectType CompGeom::intersect_seg_plane | ( | const Triangle & | tri, | |
| const std::pair< Vector3, Vector3 > & | seg, | |||
| Vector3 & | isect, | |||
| unsigned int & | big_dim | |||
| ) | [static] |
Determines the intersection between a line segment and a plane in 3D.
| tri | a 3D triangle that is fully contained in the plane to be intersected | |
| seg | a 3D line segment | |
| isect | the point of intersection (on return) | |
| big_dim | the dimension of the largest component (on return) | |
| NEAR_ZERO | the tolerance to test for zero |
| boost::shared_ptr< std::list< Vector3 > > CompGeom::calc_convex_hull_2D | ( | const std::list< Vector3 > & | points, | |
| const VectorN & | normal | |||
| ) | [static] |
Calculates the convex hull of a set of points that lie on a 2D manifold using quickhull.
| points | the set of points in 3D | |
| normal | the (optional) normal of the points; this will be computed using SVD if not provided |
| boost::shared_ptr< std::list< Vector3 > > CompGeom::intersect_coplanar_tris | ( | const Triangle & | t1, | |
| const Triangle & | t2, | |||
| const Vector3 & | normal, | |||
| Real | d | |||
| ) | [static] |
Intersects two coplanar triangles.
| normal | a normal to both triangles | |
| d | the plane intercept for the plane equation that contains both triangles |
| CompGeom::SegSegIntersectType CompGeom::intersect_segs_2D | ( | const std::pair< Vector2, Vector2 > & | s1, | |
| const std::pair< Vector2, Vector2 > & | s2, | |||
| Vector2 & | isect, | |||
| Vector2 & | isect2 | |||
| ) | [static] |
Determines whether two line segments in 2D intersect.
Taken from O'Rourke, p. 224.
| s1 | the points of the first line segment | |
| s2 | the points of the second line segment | |
| isect | the point of intersection (if any) | |
| isect2 | the second point of intersection (for edge intersection) |
| CompGeom::PolygonLocation CompGeom::polygon_location | ( | const std::list< Vector2 > & | polygon, | |
| const Vector2 & | point | |||
| ) | [static] |
Determines whether a 2D point is inside a polygon.
Adapted from O'Rourke, p. 244.
| polygon | a vector of points that describe a polygon (orientation irrelevant); each successive vertex in the vector is connected to the previous vector to make the polygon (polygon.front() and polygon.back() are connected as well) | |
| point | the point to test |
| int CompGeom::volume_sign | ( | const Vector3 & | a, | |
| const Vector3 & | b, | |||
| const Vector3 & | c, | |||
| const Vector3 & | d | |||
| ) | [static] |
Gets the sign of the volume of a tetrahedron composed of vertices a, b, c, d.
| Vector3 CompGeom::calc_centroid_2D | ( | const std::list< Vector3 > & | poly, | |
| const Vector3 & | normal | |||
| ) | [static] |
Computes the 3D (2D) centroid of points on a plane.
| poly | a counter-clockwise oriented polygon in 3D | |
| normal | a vector normal to the plane that contains the points |
| void CompGeom::project_plane | ( | std::list< Vector3 > & | points, | |
| const Vector3 & | normal, | |||
| Real | d | |||
| ) | [static] |
Projects a set of points onto a plane.
This method is intended to be used with fit_plane() to project the set of points exactly onto a plane; note that this method is unnecessary if the points fit a plane exactly.
Computes the area of points on a plane.
| poly | a counter-clockwise oriented polygon in 3D | |
| normal | a vector normal to the plane that contains the points |
Converts a 2D vector to a 3D vector.
Converts a 2D vector to a 3D vector.
Converts a 3D vector to a 2D vector.
| void CompGeom::det_line_endpoints | ( | std::list< Vector3 > & | points, | |
| std::pair< Vector3, Vector3 > & | endpoints | |||
| ) | [static] |
Determines the two endpoints of a set of colinear points (in time n lg n).
| points | a set of points; this set will be sorted on return | |
| endpoints | the endpoints of the line will be placed here on return |
| void CompGeom::det_line_endpoints | ( | std::list< Vector2 > & | points, | |
| std::pair< Vector2, Vector2 > & | endpoints | |||
| ) | [static] |
Determines the two endpoints of a set of colinear points (in time n lg n).
| points | a set of points; this set will be sorted on return | |
| endpoints | the endpoints of the line will be placed here on return |
Determines whether two triangles intersect.
| PolyhedronPtr Physsim::CompGeom::calc_convex_hull_3D | ( | ForwardIterator | first, | |
| ForwardIterator | last | |||
| ) | [static] |
| Vector3 Physsim::CompGeom::calc_centroid | ( | ForwardIterator | first, | |
| ForwardIterator | last | |||
| ) | [static] |
Computes the centroid of a set of facets.
The facets may represent a polygon, a polyhedron, or even an open polyhedron. However, the facets may not intersect.
1.5.1