Simbody
Public Member Functions | Static Public Member Functions

SimTK::ContactGeometry::Ellipsoid Class Reference

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...

#include <ContactGeometry.h>

Inheritance diagram for SimTK::ContactGeometry::Ellipsoid:

List of all members.

Public Member Functions

 Ellipsoid (const Vec3 &radii)
 Construct an Ellipsoid given its three principal half-axis dimensions a,b,c (all positive) along the local x,y,z directions respectively.
const Vec3getRadii () const
 Obtain the three half-axis dimensions a,b,c used to define this ellipsoid.
void setRadii (const Vec3 &radii)
 Set the three half-axis dimensions a,b,c (all positive) used to define this ellipsoid, overriding the current radii and recalculating the principal curvatures at a cost of about 50 flops.
const Vec3getCurvatures () const
 For efficiency we precalculate the principal curvatures whenever the ellipsoid radii are set; this avoids having to repeatedly perform these three expensive divisions at runtime.
UnitVec3 findUnitNormalAtPoint (const Vec3 &P) const
 Given a point P =(x,y,z) on the ellipsoid surface, return the unique unit outward normal to the ellipsoid at that point.
Vec3 findPointWithThisUnitNormal (const UnitVec3 &n) const
 Given a unit direction n, find the unique point P on the ellipsoid surface at which the outward-facing normal is n.
Vec3 findPointInSameDirection (const Vec3 &Q) const
 Given a direction d defined by the vector Q-O for an arbitrary point in space Q=(x,y,z)!=O, find the unique point P on the ellipsoid surface that is in direction d from the ellipsoid origin O.
void findParaboloidAtPoint (const Vec3 &Q, Transform &X_EP, Vec2 &k) const
 Given a point Q on the surface of the ellipsoid, find the approximating paraboloid at Q in a frame P where OP=Q, Pz is the outward-facing unit normal to the ellipsoid at Q, Px is the direction of maximum curvature and Py is the direction of minimum curvature.
void findParaboloidAtPointWithNormal (const Vec3 &Q, const UnitVec3 &n, Transform &X_EP, Vec2 &k) const
 If you already have both a point and the unit normal at that point, this will save about 50 flops by trusting that you have provided the correct normal; be careful -- no one is going to check that you got this right.
const EllipsoidImplgetImpl () const
 Internal use only.
EllipsoidImplupdImpl ()
 Internal use only.

Static Public Member Functions

static bool isInstance (const ContactGeometry &geo)
 Return true if the supplied ContactGeometry object is an Ellipsoid.
static const EllipsoidgetAs (const ContactGeometry &geo)
 Cast the supplied ContactGeometry object to a const Ellipsoid.
static EllipsoidupdAs (ContactGeometry &geo)
 Cast the supplied ContactGeometry object to a writable Ellipsoid.
static ContactGeometryTypeId classTypeId ()
 Obtain the unique id for Ellipsoid contact geometry.

Detailed Description

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.

The implicit equation f(x,y,z)=0 of the ellipsoid surface is

    f(x,y,z) = Ax^2+By^2+Cz^2 - 1
    where A=1/a^2, B=1/b^2, C=1/c^2     

A,B, and C are the squares of the principal curvatures ka=1/a, kb=1/b, and kc=1/c.

The interior of the ellipsoid consists of all points such that f(x,y,z)<0 and points exterior satisfy f(x,y,z)>0. The region around any point (x,y,z) on an ellipsoid surface is locally an elliptic paraboloid with equation

    -2 z' = kmax x'^2 + kmin y'^2   

where z' is measured along the the outward unit normal n at (x,y,z), x' is measured along the the unit direction u of maximum curvature, and y' is measured along the unit direction v of minimum curvature. kmax,kmin are the curvatures with kmax >= kmin > 0. The signs of the mutually perpendicular vectors u and v are chosen so that (u,v,n) forms a right-handed coordinate system for the paraboloid.


Constructor & Destructor Documentation

SimTK::ContactGeometry::Ellipsoid::Ellipsoid ( const Vec3 radii) [explicit]

Construct an Ellipsoid given its three principal half-axis dimensions a,b,c (all positive) along the local x,y,z directions respectively.

The curvatures (reciprocals of radii) are precalculated here at a cost of about 50 flops.


Member Function Documentation

const Vec3& SimTK::ContactGeometry::Ellipsoid::getRadii ( ) const

Obtain the three half-axis dimensions a,b,c used to define this ellipsoid.

void SimTK::ContactGeometry::Ellipsoid::setRadii ( const Vec3 radii)

Set the three half-axis dimensions a,b,c (all positive) used to define this ellipsoid, overriding the current radii and recalculating the principal curvatures at a cost of about 50 flops.

Parameters:
[in]radiiThe three half-dimensions of the ellipsoid, in the ellipsoid's local x, y, and z directions respectively.
const Vec3& SimTK::ContactGeometry::Ellipsoid::getCurvatures ( ) const

For efficiency we precalculate the principal curvatures whenever the ellipsoid radii are set; this avoids having to repeatedly perform these three expensive divisions at runtime.

The curvatures are ka=1/a, kb=1/b, and kc=1/c so that the ellipsoid's implicit equation can be written Ax^2+By^2+Cz^2=1, with A=ka^2, etc.

UnitVec3 SimTK::ContactGeometry::Ellipsoid::findUnitNormalAtPoint ( const Vec3 P) const

Given a point P =(x,y,z) on the ellipsoid surface, return the unique unit outward normal to the ellipsoid at that point.

If P is not on the surface, the result is the same as for the point obtained by scaling the vector P - O until it just touches the surface. That is, we compute P'=findPointInThisDirection(P) and then return the normal at P'. Cost is about 50 flops regardless of whether P was initially on the surface.

Parameters:
[in]PA point on the ellipsoid surface, measured and expressed in the ellipsoid's local frame. See text for what happens if P is not actually on the ellipsoid surface.
Returns:
The outward-facing unit normal at point P (or at the surface point pointed to by P).
See also:
findPointInSameDirection()
Vec3 SimTK::ContactGeometry::Ellipsoid::findPointWithThisUnitNormal ( const UnitVec3 n) const

Given a unit direction n, find the unique point P on the ellipsoid surface at which the outward-facing normal is n.

Cost is about 50 flops.

Parameters:
[in]nThe unit vector for which we want to find a match on the ellipsoid surface, expressed in the ellipsoid's local frame.
Returns:
The point on the ellipsoid's surface at which the outward-facing normal is the same as n. The point is measured and expressed in the ellipsoid's local frame.
Vec3 SimTK::ContactGeometry::Ellipsoid::findPointInSameDirection ( const Vec3 Q) const

Given a direction d defined by the vector Q-O for an arbitrary point in space Q=(x,y,z)!=O, find the unique point P on the ellipsoid surface that is in direction d from the ellipsoid origin O.

That is, P=s*d for some scalar s > 0 such that f(P)=0. Cost is about 50 flops.

Parameters:
[in]QA point in space measured from the ellipsoid origin but not the origin.
Returns:
P, the intersection of the ray in the direction Q-O with the ellipsoid surface
void SimTK::ContactGeometry::Ellipsoid::findParaboloidAtPoint ( const Vec3 Q,
Transform X_EP,
Vec2 k 
) const

Given a point Q on the surface of the ellipsoid, find the approximating paraboloid at Q in a frame P where OP=Q, Pz is the outward-facing unit normal to the ellipsoid at Q, Px is the direction of maximum curvature and Py is the direction of minimum curvature.

k=(kmax,kmin) are the returned curvatures with kmax >= kmin > 0. The equation of the resulting paraboloid in the P frame is -2z = kmax*x^2 + kmin*y^2. Cost is about 270 flops; you can save a little time if you already know the normal at Q by using the other overloaded signature for this method.

Warning:
It is up to you to make sure that Q is actually on the ellipsoid surface. If it is not you will quietly get a meaningless result.
Parameters:
[in]QA point on the surface of this ellipsoid, measured and expressed in the ellipsoid's local frame.
[out]X_EPThe frame of the paraboloid P, measured and expressed in the ellipsoid local frame E. X_EP.p() is Q, X_EP.x() is the calculated direction of maximum curvature kmax; y() is the direction of minimum curvature kmin; z is the outward facing normal at Q.
[out]kThe maximum (k[0]) and minimum (k[1]) curvatures of the ellipsoid (and paraboloid P) at point Q.
See also:
findParaboloidAtPointWithNormal()
void SimTK::ContactGeometry::Ellipsoid::findParaboloidAtPointWithNormal ( const Vec3 Q,
const UnitVec3 n,
Transform X_EP,
Vec2 k 
) const

If you already have both a point and the unit normal at that point, this will save about 50 flops by trusting that you have provided the correct normal; be careful -- no one is going to check that you got this right.

The results are meaningless if the point and normal are not consistent. Cost is about 220 flops.

See also:
findParaboloidAtPoint() for details
static bool SimTK::ContactGeometry::Ellipsoid::isInstance ( const ContactGeometry geo) [inline, static]

Return true if the supplied ContactGeometry object is an Ellipsoid.

static const Ellipsoid& SimTK::ContactGeometry::Ellipsoid::getAs ( const ContactGeometry geo) [inline, static]

Cast the supplied ContactGeometry object to a const Ellipsoid.

static Ellipsoid& SimTK::ContactGeometry::Ellipsoid::updAs ( ContactGeometry geo) [inline, static]

Cast the supplied ContactGeometry object to a writable Ellipsoid.

static ContactGeometryTypeId SimTK::ContactGeometry::Ellipsoid::classTypeId ( ) [static]

Obtain the unique id for Ellipsoid contact geometry.

const EllipsoidImpl& SimTK::ContactGeometry::Ellipsoid::getImpl ( ) const

Internal use only.

Reimplemented from SimTK::ContactGeometry.

EllipsoidImpl& SimTK::ContactGeometry::Ellipsoid::updImpl ( )

Internal use only.

Reimplemented from SimTK::ContactGeometry.


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