1 #ifndef SimTK_SIMMATH_GEO_POINT_H_ 2 #define SimTK_SIMMATH_GEO_POINT_H_ 48 typedef Vec<3,P> Vec3P;
49 typedef Mat<3,3,P> Mat33P;
50 typedef SymMat<3,P> SymMat33P;
51 typedef UnitVec<P,1> UnitVec3P;
52 typedef Rotation_<P> RotationP;
53 typedef Transform_<P> TransformP;
60 Point_(
const Vec3P& location) : p(location) {}
93 {
return (p2-p1).normSqr(); }
112 (
const Vec3P& p1,
const Vec3P& p2, RealP tol)
115 const RealP scale =
std::max(tol, maxcoord*tol);
125 int& most, RealP& mostCoord);
131 const UnitVec3P& direction,
132 int& most, RealP& mostCoord);
140 int& least,
int& most,
141 RealP& leastCoord, RealP& mostCoord);
147 const UnitVec3P& direction,
148 int& least,
int& most,
149 RealP& leastCoord, RealP& mostCoord);
165 Vec3P& centroid, SymMat33P& covariance);
171 Vec3P& centroid, SymMat33P& covariance);
202 int least[3],
int most[3],
203 Vec3P& low, Vec3P& high);
209 int least[3],
int most[3],
210 Vec3P& low, Vec3P& high);
257 const RotationP& R_FB,
258 int least[3],
int most[3],
259 Vec3P& low_B, Vec3P& high_B);
265 const RotationP& R_FB,
266 int least[3],
int most[3],
267 Vec3P& low_B, Vec3P& high_B);
334 {
return Sphere_<P>(p, 0).stretchBoundary(); }
348 (
const Vec3P& p0,
const Vec3P& p1,
const Vec3P& p2) {
355 (
const Vec3P& p0,
const Vec3P& p1,
const Vec3P& p2,
const Vec3P& p3) {
427 const Vec3P& p3,
bool forceCircumsphere,
Array_<int>& which);
450 return calcApproxBoundingSphere
462 return calcApproxBoundingSphereIndirect
474 #endif // SimTK_SIMMATH_GEO_POINT_H_ static Sphere_< P > calcApproxBoundingSphereIndirect(const Array_< const Vec3P * > &points)
Alternate signature works with an array of pointers to points.
static Sphere_< P > calcBoundingSphereIndirect(const Array_< const Vec3P * > &points)
Create a minimal bounding sphere around a collection of n points, given indirectly as an array of poi...
Definition: Geo_Point.h:379
TAbs abs() const
Elementwise absolute value; that is, the return value has the same dimension as this Vec but with eac...
Definition: Vec.h:345
static Geo::AlignedBox_< P > calcAxisAlignedBoundingBoxIndirect(const Array_< const Vec3P * > &points, Array_< int > &support)
Alternate signature taking an array of pointers to points rather than the points themselves.
static Geo::AlignedBox_< P > calcAxisAlignedBoundingBox(const Array_< Vec3P > &points)
Alternate signature doesn't return support points.
Definition: Geo_Point.h:220
static Sphere_< P > calcApproxBoundingSphere(const Array_< Vec3P > &points)
Calculate an approximate bounding sphere. You should normally use calcBoundingSphere() which will giv...
RealP findDistanceSqr(const Vec3P &p2) const
Find the square of the distance between this point and another one whose location is expressed in the...
Definition: Geo_Point.h:75
static void findAxisAlignedExtremePointsIndirect(const Array_< const Vec3P * > &points, int least[3], int most[3], Vec3P &low, Vec3P &high)
Alternate signature taking an array of pointers to points rather than the points themselves.
static Sphere_< P > calcBoundingSphere(const Vec3P &p0, Array_< int > &which)
Create one-point bounding sphere and return the (trivial) support point, of which there is always one...
Definition: Geo_Point.h:394
static void findExtremePointsIndirect(const Array_< const Vec3P * > &points, const UnitVec3P &direction, int &least, int &most, RealP &leastCoord, RealP &mostCoord)
Alternate signature taking an array of pointers to points rather than the points themselves.
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
static Geo::OrientedBox_< P > calcOrientedBoundingBoxIndirect(const Array_< const Vec3P * > &points, bool optimize=true)
Alternate signature doesn't return support points.
Definition: Geo_Point.h:292
static RealP findDistanceSqr(const Vec3P &p1, const Vec3P &p2)
Find the square of the distance between two points (cheap).
Definition: Geo_Point.h:92
static void findAxisAlignedExtremePoints(const Array_< Vec3P > &points, int least[3], int most[3], Vec3P &low, Vec3P &high)
Given a set of points, find the six points that are the most extreme along the axial directions (not ...
Point_ & setLocation(const Vec3P &location)
Change the location of this point.
Definition: Geo_Point.h:63
static Vec3P findMidpoint(const Vec3P &p1, const Vec3P &p2)
Find the point midway between two points.
Definition: Geo_Point.h:96
static Sphere_< P > calcBoundingSphere(const std::vector< const Vec3P * > &points)
This signature takes an std::vector rather than a SimTK::Array_; no extra copying is required...
Definition: Geo_Point.h:387
static void findOrientedExtremePointsIndirect(const Array_< const Vec3P * > &points_F, const RotationP &R_FB, int least[3], int most[3], Vec3P &low_B, Vec3P &high_B)
Alternate signature taking an array of pointers to points rather than the points themselves.
static void calcCovariance(const Array_< Vec3P > &points_F, Vec3P ¢roid, SymMat33P &covariance)
Given a set of points, calculate the centroid (average location) and covariance matrix of those point...
static Sphere_< P > calcBoundingSphere(const std::vector< Vec3P > &points)
This signature takes an std::vector rather than a SimTK::Array_; no extra copying is required...
Definition: Geo_Point.h:371
TODO: A 3d box oriented and positioned with respect to an unspecified frame F.
Definition: Geo.h:63
A 3d box aligned with an unspecified frame F and centered at a given point measured from that frame's...
Definition: Geo.h:62
static Geo::AlignedBox_< P > calcAxisAlignedBoundingBoxIndirect(const Array_< const Vec3P * > &points)
Alternate signature doesn't return support points.
Definition: Geo_Point.h:232
static void findSupportPoint(const Array_< Vec3P > &points, const UnitVec3P &direction, int &most, RealP &mostCoord)
Given a set of points, find the one that is the furthest in a given direction, and return its index a...
static Vec3P calcCentroidIndirect(const Array_< const Vec3P * > &points_F)
Alternate signature taking an array of pointers to points rather than the points themselves.
static Sphere_< P > calcApproxBoundingSphere(const std::vector< Vec3P > &points)
This signature takes an std::vector rather than a SimTK::Array_; no extra copying is required...
Definition: Geo_Point.h:449
unsigned char square(unsigned char u)
Definition: Scalar.h:351
static void findSupportPointIndirect(const Array_< const Vec3P * > &points, const UnitVec3P &direction, int &most, RealP &mostCoord)
Alternate signature taking an array of pointers to points rather than the points themselves.
static Vec3P calcCentroid(const Array_< Vec3P > &points_F)
Given a set of points, calculate the centroid (average location) of those points. ...
static void calcCovarianceIndirect(const Array_< const Vec3P * > &points_F, Vec3P ¢roid, SymMat33P &covariance)
Alternate signature taking an array of pointers to points rather than the points themselves.
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
static Geo::AlignedBox_< P > calcAxisAlignedBoundingBox(const Array_< Vec3P > &points, Array_< int > &support)
Calculate the smallest axis-aligned bounding box including all n given points.
static Sphere_< P > calcBoundingSphere(const Vec3P &p0, const Vec3P &p1)
Create a minimal bounding sphere around two points.
Definition: Geo_Point.h:340
The SimTK::Array_<T> container class is a plug-compatible replacement for the C++ standard template l...
Definition: Array.h:50
static Geo::OrientedBox_< P > calcOrientedBoundingBox(const Array_< Vec3P > &points, Array_< int > &support, bool optimize=true)
Calculate a tight-fitting oriented bounding box (OBB) that includes all n given points.
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
Defines geometric primitive shapes and algorthms.
static void calcPrincipalComponents(const Array_< Vec3P > &points_F, TransformP &X_FP)
Given a set of points in an unspecified frame F, find the principal component directions describing t...
static void calcPrincipalComponentsIndirect(const Array_< const Vec3P * > &points_F, TransformP &X_FP)
Alternate signature taking an array of pointers to points rather than the points themselves.
static Geo::OrientedBox_< P > calcOrientedBoundingBox(const Array_< Vec3P > &points)
Alternate signature doesn't return support points.
Definition: Geo_Point.h:279
static Geo::OrientedBox_< P > calcOrientedBoundingBoxIndirect(const Array_< const Vec3P * > &points, Array_< int > &support, bool optimize=true)
Alternate signature taking an array of pointers to points rather than the points themselves.
This is the header file that every Simmath compilation unit should include first. ...
This Array_ helper class is the base class for ArrayView_ which is the base class for Array_; here we...
Definition: Array.h:48
Point_(const Vec3P &location)
Construct a Point with the given location. Also serves as implicit conversion from Vec3 to Geo::Point...
Definition: Geo_Point.h:60
RealP calcDistance(const Vec3P &p2) const
Calculate the distance between this point and another one whose location is expressed in the same fra...
Definition: Geo_Point.h:70
void clear()
Erase all the elements currently in this array without changing the capacity; equivalent to erase(beg...
Definition: Array.h:2522
static RealP calcDistance(const Vec3P &p1, const Vec3P &p2)
Calculate the distance between two points (expensive).
Definition: Geo_Point.h:87
static void findOrientedExtremePoints(const Array_< Vec3P > &points_F, const RotationP &R_FB, int least[3], int most[3], Vec3P &low_B, Vec3P &high_B)
Given a set of points, find the six points that are the most extreme along specified orientation dire...
A geometric primitive representing a sphere by its radius and center point, and a collection of spher...
Definition: Geo.h:56
const Vec3P & getLocation() const
Get the location of this Point.
Definition: Geo_Point.h:66
A 3d point primitive represented by a Vec3 from the origin of an unspecified frame, and a collection of point-related utility methods.
Definition: Geo.h:55
void push_back(const T &value)
This method increases the size of the Array by one element at the end and initializes that element by...
Definition: Array.h:2359
static bool pointsAreNumericallyCoincident(const Vec3P &p1, const Vec3P &p2)
Determine whether two points whose locations are known to an accuracy tol are numerically indistingui...
Definition: Geo_Point.h:106
Point_()
Construct an uninitialized Point object; the location will be garbage.
Definition: Geo_Point.h:57
static Sphere_< P > calcBoundingSphere(const Array_< Vec3P > &points)
Create a minimal bounding sphere around a collection of n points.
Definition: Geo_Point.h:363
#define SimTK_SIMMATH_EXPORT
Definition: SimTKmath/include/simmath/internal/common.h:64
static void findExtremePoints(const Array_< Vec3P > &points, const UnitVec3P &direction, int &least, int &most, RealP &leastCoord, RealP &mostCoord)
Given a set of points, find the two points that are the most extreme along a given direction (not nec...
static Sphere_< P > calcApproxBoundingSphereIndirect(const std::vector< const Vec3P * > &points)
This signature takes an std::vector rather than a SimTK::Array_; no extra copying is required...
Definition: Geo_Point.h:461
static Sphere_< P > calcBoundingSphere(const Vec3P &p)
Create a tiny bounding sphere around a single point.
Definition: Geo_Point.h:333