1 #ifndef SimTK_SIMMATH_GEO_LINESEG_H_ 2 #define SimTK_SIMMATH_GEO_LINESEG_H_ 52 typedef Vec<3,RealP> Vec3P;
62 { setEndpoints(e0,e1); }
66 { e[0]=e0; e[1]=e1;
return *
this; }
70 { assert(which==0 || which==1); e[which] = p;
return *
this; }
78 { assert(tol >= 0);
return calcLengthSqr() <=
square(tol); }
83 { assert(which==0 || which==1);
return e[which]; }
89 { assert(which==0 || which==1);
return e[which]; }
92 const Vec3P&
operator[](
int which)
const {
return getEndpoint(which);}
94 Vec3P&
operator[](
int which) {
return updEndpoint(which);}
109 {
return t*e[0] + (1-t)*e[1]; }
114 {
return (e[0]+e[1]) / RealP(2); }
126 "Geo::LineSeg_::findDistanceToPoint(): Not implemented yet.");
127 return Geo::getNaN<P>();}
133 "Geo::LineSeg_::findDistanceToPointSqr(): Not implemented yet.");
134 return Geo::getNaN<P>();}
149 #endif // SimTK_SIMMATH_GEO_LINESEG_H_ RealP calcLength() const
Calculate the length of this line segment (expensive).
Definition: Geo_LineSeg.h:98
LineSeg_ & setEndpoints(const Vec3P &e0, const Vec3P &e1)
Change the end points of this line segment.
Definition: Geo_LineSeg.h:65
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
#define SimTK_ASSERT_ALWAYS(cond, msg)
Definition: ExceptionMacros.h:349
RealP findDistanceToPointSqr(const Vec3P &p2) const
Find the square of the distance between this line segment and a point expressed in the same frame...
Definition: Geo_LineSeg.h:131
const Vec3P & operator[](int which) const
Access an end point by indexing the line segment.
Definition: Geo_LineSeg.h:92
unsigned char square(unsigned char u)
Definition: Scalar.h:351
Vec3P & operator[](int which)
Get writable access to an end point by indexing the line segment.
Definition: Geo_LineSeg.h:94
Vec3P & updEndpoint(int which)
Get a writable reference to the location of an end point. Order is the same as construction.
Definition: Geo_LineSeg.h:88
RealP findDistanceToPoint(const Vec3P &p2) const
Find the distance between this line segment and a point expressed in the same frame.
Definition: Geo_LineSeg.h:124
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
Defines geometric primitive shapes and algorthms.
A 3d line segment primitive represented by its end points in an unspecified frame, and a collection of line segment-related utility methods.
Definition: Geo.h:57
Vec3P findMidpoint() const
Return the center point of the line segment; this is the same as findPoint(1/2) but faster...
Definition: Geo_LineSeg.h:113
This is the header file that every Simmath compilation unit should include first. ...
LineSeg_()
Construct an uninitialized LineSeg object; the end points will be garbage (NaN in Debug builds)...
Definition: Geo_LineSeg.h:57
RealP calcLengthSqr() const
Calculate the square of the length of this line segment (cheap).
Definition: Geo_LineSeg.h:102
Sphere_< P > calcBoundingSphere() const
Calculate a minimal bounding sphere for this line segment.
Definition: Geo_LineSeg.h:119
A geometric primitive representing a sphere by its radius and center point, and a collection of spher...
Definition: Geo.h:56
Vec3P findPoint(RealP t) const
Return a point along the line segment given by its coordinate t, where t==0 gives end point 0...
Definition: Geo_LineSeg.h:108
LineSeg_ & setEndpoint(int which, const Vec3P &p)
Change one end point of this line segment.
Definition: Geo_LineSeg.h:69
LineSeg_(const Vec3P &e0, const Vec3P &e1)
Construct a LineSeg with the given end points.
Definition: Geo_LineSeg.h:61
Defines primitive operations on spheres.
#define SimTK_SIMMATH_EXPORT
Definition: SimTKmath/include/simmath/internal/common.h:64
bool isDegenerate(RealP tol=Geo::getDefaultTol< P >()) const
Determine whether this line segment is degenerate to a given tolerance, meaning that its length is le...
Definition: Geo_LineSeg.h:77
const Vec3P & getEndpoint(int which) const
Get the location of an end point. Order is the same as construction.
Definition: Geo_LineSeg.h:82
static Sphere_< P > calcBoundingSphere(const Vec3P &p)
Create a tiny bounding sphere around a single point.
Definition: Geo_Point.h:333