Simbody
|
A ContactGeometry object describes the physical shape of contact surface. More...
#include <ContactGeometry.h>
Classes | |
class | Ellipsoid |
This ContactGeometry subclass represents an ellipsoid centered at the origin, with its principal axes pointing along the x, y, and z axes and half dimensions a,b, and c (all > 0) along those axes, respectively. More... | |
class | EllipsoidImpl |
class | HalfSpace |
This ContactGeometry subclass represents an object that occupies the entire half-space x>0. More... | |
class | HalfSpaceImpl |
class | Sphere |
This ContactGeometry subclass represents a sphere centered at the origin. More... | |
class | SphereImpl |
class | TriangleMesh |
This ContactGeometry subclass represents an arbitrary shape described by a mesh of triangular faces. More... | |
class | TriangleMeshImpl |
Public Member Functions | |
ContactGeometry () | |
Base class default constructor creates an empty handle. | |
ContactGeometry (const ContactGeometry &src) | |
Copy constructor makes a deep copy. | |
ContactGeometry & | operator= (const ContactGeometry &src) |
Copy assignment makes a deep copy. | |
~ContactGeometry () | |
Base class destructor deletes the implementation object. Note that this is not virtual; handles should consist of just a pointer to the implementation. | |
Vec3 | findNearestPoint (const Vec3 &position, bool &inside, UnitVec3 &normal) const |
Given a point, find the nearest point on the surface of this object. | |
bool | intersectsRay (const Vec3 &origin, const UnitVec3 &direction, Real &distance, UnitVec3 &normal) const |
Determine whether this object intersects a ray, and if so, find the intersection point. | |
void | getBoundingSphere (Vec3 ¢er, Real &radius) const |
Get a bounding sphere which completely encloses this object. | |
const std::string & | getType () const |
Get a string which uniquely identifies the type of geometry this object represents. | |
int | getTypeIndex () const |
Get an integer which uniquely identifies the type of geometry this object represents. | |
ContactGeometryTypeId | getTypeId () const |
ContactTrackerSubsystem uses this id for fast identification of specific surface shapes. | |
ContactGeometry (ContactGeometryImpl *impl) | |
Internal use only. | |
bool | isOwnerHandle () const |
Internal use only. | |
bool | isEmptyHandle () const |
Internal use only. | |
bool | hasImpl () const |
Internal use only. | |
const ContactGeometryImpl & | getImpl () const |
Internal use only. | |
ContactGeometryImpl & | updImpl () |
Internal use only. | |
Static Public Member Functions | |
static void | combineParaboloids (const Rotation &R_SP1, const Vec2 &k1, const UnitVec3 &x2, const Vec2 &k2, Rotation &R_SP, Vec2 &k) |
This utility method is useful for characterizing the relative geometry of two locally-smooth surfaces in contact, in a way that is useful for later application of Hertz compliant contact theory for generating forces. | |
static void | combineParaboloids (const Rotation &R_SP1, const Vec2 &k1, const UnitVec3 &x2, const Vec2 &k2, Vec2 &k) |
This is a much faster version of combineParaboloids() for when you just need the curvatures of the difference paraboloid, but not the directions of those curvatures. | |
Protected Attributes | |
ContactGeometryImpl * | impl |
Internal use only. |
A ContactGeometry object describes the physical shape of contact surface.
It is used with GeneralContactSubsystem or ContactTrackerSubsystem for doing collision detection and contact modeling. This is the base class for the geometry handles; user code will typically reference one of the local classes it defines instead for specific shapes.
SimTK::ContactGeometry::ContactGeometry | ( | ) | [inline] |
Base class default constructor creates an empty handle.
SimTK::ContactGeometry::ContactGeometry | ( | const ContactGeometry & | src | ) |
Copy constructor makes a deep copy.
SimTK::ContactGeometry::~ContactGeometry | ( | ) |
Base class destructor deletes the implementation object. Note that this is not virtual; handles should consist of just a pointer to the implementation.
SimTK::ContactGeometry::ContactGeometry | ( | ContactGeometryImpl * | impl | ) | [explicit] |
Internal use only.
ContactGeometry& SimTK::ContactGeometry::operator= | ( | const ContactGeometry & | src | ) |
Copy assignment makes a deep copy.
Vec3 SimTK::ContactGeometry::findNearestPoint | ( | const Vec3 & | position, |
bool & | inside, | ||
UnitVec3 & | normal | ||
) | const |
Given a point, find the nearest point on the surface of this object.
If multiple points on the surface are equally close to the specified point, this may return any of them.
[in] | position | The point in question. |
[out] | inside | On exit, this is set to true if the specified point is inside this object, false otherwise. |
[out] | normal | On exit, this contains the surface normal at the returned point. |
Reimplemented in SimTK::ContactGeometry::TriangleMesh.
bool SimTK::ContactGeometry::intersectsRay | ( | const Vec3 & | origin, |
const UnitVec3 & | direction, | ||
Real & | distance, | ||
UnitVec3 & | normal | ||
) | const |
Determine whether this object intersects a ray, and if so, find the intersection point.
[in] | origin | The position at which the ray begins. |
[in] | direction | The ray direction. |
[out] | distance | If an intersection is found, the distance from the ray origin to the intersection point is stored in this. Otherwise, it is left unchanged. |
[out] | normal | If an intersection is found, the surface normal of the intersection point is stored in this. Otherwise, it is left unchanged. |
true
if an intersection is found, false
otherwise. Reimplemented in SimTK::ContactGeometry::TriangleMesh.
void SimTK::ContactGeometry::getBoundingSphere | ( | Vec3 & | center, |
Real & | radius | ||
) | const |
Get a bounding sphere which completely encloses this object.
[out] | center | On exit, this contains the location of the center of the bounding sphere. |
[out] | radius | On exit, this contains the radius of the bounding sphere. |
static void SimTK::ContactGeometry::combineParaboloids | ( | const Rotation & | R_SP1, |
const Vec2 & | k1, | ||
const UnitVec3 & | x2, | ||
const Vec2 & | k2, | ||
Rotation & | R_SP, | ||
Vec2 & | k | ||
) | [static] |
This utility method is useful for characterizing the relative geometry of two locally-smooth surfaces in contact, in a way that is useful for later application of Hertz compliant contact theory for generating forces.
We assume that contact points Q1 on surface1 and Q2 on surface2 have been determined with the following properties:
Then the local regions near Q1 and Q2 may be fit with paraboloids P1 and P2 that have their origins at Q1 and Q2, and have the same normals and curvatures at the origins as do the original surfaces. We will behave here as though Q1 and Q2 are coincident in space at a point Q; imagine sliding them along the normal until that happens. Now we define the equations of P1 and P2 in terms of the maximum and minimum curvatures of surface1 and surface2 at Q:
P1: -2z = kmax1 x1^2 + kmin1 y1^2 P2: 2z = kmax2 x2^2 + kmin2 y2^2
Although the origin Q and z direction are shared, the x,y directions for the two paraboloids, though in the same plane z=0, are relatively rotated. Note that the kmins might be negative; the surfaces do not have to be convex.
For Hertz contact, we need to know the difference (relative) surface between the two paraboloids. The difference is a paraboloid P with equation
P: -2z = kmax x^2 + kmin y^2
It shares the origin Q and z direction (oriented as for P1), but has its own principal directions x,y which are coplanar with x1,y1 and x2,y2 but rotated into some unknown composite orientation. The purpose of this method is to calculate kmax and kmin, and optionally (depending which signature you call), x and y, the directions of maximum and minimum curvature (resp.). The curvature directions are also the principal axes of the contact ellipse formed by the deformed surfaces, so are necessary (for example) if you want to draw that ellipse.
Cost is about 220 flops. If you don't need the curvature directions, call the other overloaded signature which returns only kmax and kmin and takes only about 1/3 as long.
[in] | R_SP1 | The orientation of the P1 paraboloid's frame, expressed in some frame S (typically the frame of the surface to which P1 is fixed). R_SP1.x() is the direction of maximum curvature; y() is minimum curvature; z is the contact normal pointing away from surface 1. |
[in] | k1 | The maximum (k1[0]) and minimum (k1[1]) curvatures for P1 at the contact point Q1 on surface1. Negative curvatures are handled correctly here but may cause trouble for your force model if the resulting contact is conforming. |
[in] | x2 | The direction of maximum curvature for paraboloid P2. x2 must be in the x1,y1 plane provided in R_SP1 and expressed in the S frame. |
[in] | k2 | The maximum (k2[0]) and minimum (k2[1]) curvatures for P2 at the contact point Q2 on surface2. Negative curvatures are handled correctly here but may cause trouble for your force model if the resulting contact is conforming. |
[out] | R_SP | The orientation of the difference paraboloid P's frame, expressed in the same S frame as was used for P1. R_SP.x() is the direction of maximum curvature of P at the contact point; y() is the minimum curvature direction; z() is the unchanged contact normal pointing away from surface1. |
[out] | k | The maximum (k[0]) and minimum(k[1]) curvatures for the difference paraboloid P at the contact point Q. If either of these is negative or zero then the surfaces are conforming and you can't use a point contact force model. Note that if k1>0 and k2>0 (i.e. surfaces are convex at Q) then k>0 too. If some of the surface curvatures are concave, it is still possible that k>0, depending on the relative curvatures. |
static void SimTK::ContactGeometry::combineParaboloids | ( | const Rotation & | R_SP1, |
const Vec2 & | k1, | ||
const UnitVec3 & | x2, | ||
const Vec2 & | k2, | ||
Vec2 & | k | ||
) | [static] |
This is a much faster version of combineParaboloids() for when you just need the curvatures of the difference paraboloid, but not the directions of those curvatures.
Cost is about 70 flops. See the other overload of this method for details.
const std::string& SimTK::ContactGeometry::getType | ( | ) | const |
Get a string which uniquely identifies the type of geometry this object represents.
Typically each subclass of ContactGeometry defines its own value.
int SimTK::ContactGeometry::getTypeIndex | ( | ) | const |
Get an integer which uniquely identifies the type of geometry this object represents.
A unique index is generated automatically for each unique type value as returned by getType().
ContactGeometryTypeId SimTK::ContactGeometry::getTypeId | ( | ) | const |
ContactTrackerSubsystem uses this id for fast identification of specific surface shapes.
bool SimTK::ContactGeometry::isOwnerHandle | ( | ) | const |
Internal use only.
bool SimTK::ContactGeometry::isEmptyHandle | ( | ) | const |
Internal use only.
bool SimTK::ContactGeometry::hasImpl | ( | ) | const [inline] |
Internal use only.
const ContactGeometryImpl& SimTK::ContactGeometry::getImpl | ( | ) | const [inline] |
Internal use only.
Reimplemented in SimTK::ContactGeometry::Sphere, SimTK::ContactGeometry::Ellipsoid, and SimTK::ContactGeometry::TriangleMesh.
ContactGeometryImpl& SimTK::ContactGeometry::updImpl | ( | ) | [inline] |
Internal use only.
Reimplemented in SimTK::ContactGeometry::Sphere, SimTK::ContactGeometry::Ellipsoid, and SimTK::ContactGeometry::TriangleMesh.
ContactGeometryImpl* SimTK::ContactGeometry::impl [protected] |
Internal use only.