Simbody
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes

SimTK::ContactGeometry Class Reference

A ContactGeometry object describes the physical shape of contact surface. More...

#include <ContactGeometry.h>

Inheritance diagram for SimTK::ContactGeometry:

List of all members.

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.
ContactGeometryoperator= (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 &center, 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 ContactGeometryImplgetImpl () const
 Internal use only.
ContactGeometryImplupdImpl ()
 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

ContactGeometryImplimpl
 Internal use only.

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
[in]positionThe point in question.
[out]insideOn exit, this is set to true if the specified point is inside this object, false otherwise.
[out]normalOn exit, this contains the surface normal at the returned point.
Returns:
The point on the surface of the object which is closest to the specified 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.

Parameters:
[in]originThe position at which the ray begins.
[in]directionThe ray direction.
[out]distanceIf an intersection is found, the distance from the ray origin to the intersection point is stored in this. Otherwise, it is left unchanged.
[out]normalIf an intersection is found, the surface normal of the intersection point is stored in this. Otherwise, it is left unchanged.
Returns:
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.

Parameters:
[out]centerOn exit, this contains the location of the center of the bounding sphere.
[out]radiusOn 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:

  • the surface normals are aligned but opposite
  • points Q1 and Q2 are separated only along the normal (no tangential separation)

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.

Parameters:
[in]R_SP1The 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]k1The 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]x2The 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]k2The 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_SPThe 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]kThe 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.
See also:
The other signature for combineParaboloids() that is much cheaper if you just need the curvatures k but not the directions R_SP.
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]
ContactGeometryImpl& SimTK::ContactGeometry::updImpl ( ) [inline]

Member Data Documentation

Internal use only.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines