KrisLibrary
1.0.0
|
A generic geometric primitive class. More...
#include <geometry3d.h>
Public Types | |
enum | Type { Empty, Point, Segment, Triangle, Polygon, Sphere, Ellipsoid, Cylinder, AABB, Box } |
Public Member Functions | |
GeometricPrimitive3D (const GeometricPrimitive3D &prim) | |
GeometricPrimitive3D (const Vector3 &pt) | |
GeometricPrimitive3D (const Segment3D &line) | |
GeometricPrimitive3D (const Triangle3D &t) | |
GeometricPrimitive3D (const Polygon3D &p) | |
GeometricPrimitive3D (const Sphere3D &s) | |
GeometricPrimitive3D (const Ellipsoid3D &s) | |
GeometricPrimitive3D (const Cylinder3D &s) | |
GeometricPrimitive3D (const AABB3D &s) | |
GeometricPrimitive3D (const Box3D &s) | |
const char * | TypeName () const |
AABB3D | GetAABB () const |
Box3D | GetBB () const |
RigidTransform | GetFrame () const |
void | Transform (const RigidTransform &T) |
void | Transform (const Matrix4 &T) |
bool | SupportsCollides (Type b) const |
bool | Collides (const Vector3 &pt) const |
bool | Collides (const Segment3D &s) const |
bool | Collides (const Triangle3D &t) const |
bool | Collides (const Polygon3D &p) const |
bool | Collides (const Sphere3D &s) const |
bool | Collides (const Ellipsoid3D &s) const |
bool | Collides (const Cylinder3D &s) const |
bool | Collides (const AABB3D &s) const |
bool | Collides (const Box3D &s) const |
bool | Collides (const GeometricPrimitive3D &g) const |
bool | SupportsDistance (Type b) const |
Real | Distance (const Vector3 &pt) const |
Real | Distance (const Segment3D &s) const |
Real | Distance (const Triangle3D &t) const |
Real | Distance (const Polygon3D &p) const |
Real | Distance (const Sphere3D &s) const |
Real | Distance (const Ellipsoid3D &s) const |
Real | Distance (const Cylinder3D &s) const |
Real | Distance (const AABB3D &s) const |
Real | Distance (const Box3D &s) const |
Real | Distance (const GeometricPrimitive3D &g) const |
std::vector< double > | ClosestPointParameters (const Vector3 &pt) const |
Vector3 | ParametersToPoint (const std::vector< double > ¶ms) const |
Vector3 | ParametersToNormal (const std::vector< double > ¶ms) const |
bool | RayCast (const Ray3D &ray, Vector3 &pt) const |
bool | SupportsClosestPoints (Type b) const |
Real | ClosestPoints (const Vector3 &pt, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Segment3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Triangle3D &t, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Polygon3D &p, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Sphere3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Ellipsoid3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Cylinder3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const AABB3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const Box3D &s, Vector3 &cp, Vector3 &direction) const |
Real | ClosestPoints (const GeometricPrimitive3D &g, Vector3 &cp, Vector3 &direction) const |
Public Attributes | |
Type | type |
AnyValue | data |
A generic geometric primitive class.
TODO: make the API comparable to GeometricPrimitive2D.
Real Math3D::GeometricPrimitive3D::ClosestPoints | ( | const Vector3 & | pt, |
Vector3 & | cp, | ||
Vector3 & | direction | ||
) | const |
TODO better normal estimation
TODO better normal estimation
References Math3D::Cylinder3D::closestPoint(), Math3D::Sphere3D::closestPoint(), and Math3D::Triangle3D::distance().
Referenced by Geometry::AnyCollisionGeometry3D::SetTransform(), and SupportsClosestPoints().
|
inline |
The ClosestPoints function returns the distance value d (negative meaning penetration) and the closest point on this (cp). The normalized direction to the closest point on the other geometry is also given (direction) so that the closest point on the other object is cp + d*direction. If the objects are touching, direction will indicate the normal by which this can move so that the penetration derivative is maximized (i.e., the negative distance gradient). If direction = 0 then there's a singularity or the direction cannot be calculated.
References ClosestPoints().