#include <CProxyPointForceAlgo.h>
Inheritance diagram for cProxyPointForceAlgo:
Public Member Functions | |
cProxyPointForceAlgo () | |
Constructor of cProxyPointForceAlgo. | |
void | initialize (cWorld *a_world, const cVector3d &a_initialPos) |
Initialize the algorithm. | |
virtual cVector3d | computeForces (const cVector3d &a_nextDevicePos) |
Calculate interaction forces between device and meshes. | |
void | setProxyRadius (const double a_radius) |
Set radius of proxy. | |
virtual double | getProxyRadius () const |
Read radius of proxy. | |
virtual cVector3d | getProxyGlobalPosition () const |
Get last computed position of proxy in world coordinates. | |
virtual cVector3d | getDeviceGlobalPosition () const |
Get last specified position of device in world coordinates. | |
virtual cVector3d | getLastGlobalForce () const |
Get last computed global force vector. | |
virtual unsigned int | getContacts (cTriangle *&a_t0, cTriangle *&a_t1, cTriangle *&a_t2) |
Return the number of current contacts and the associated triangles. | |
virtual cGenericObject * | getContactObject () |
Return a pointer to the object with which device is currently in contact. | |
virtual cVector3d | getContactPoint () |
Return point of contact between proxy and object. | |
virtual void | getContactObjectLastGlobalPos (cVector3d &a_pos) |
Return global position of object with which device last contacted. | |
virtual void | getContactObjectLastGlobalRot (cMatrix3d &a_rot) |
Return global rotation of object with which device last contacted. | |
void | enableDynamicProxy (bool a_enable) |
Set dynamic proxy flag, (if on, all contacts are computed in object-local space). | |
bool | getDynamicProxyEnabled () |
Return whether the dynamic proxy flag is on. | |
virtual cVector3d | getNormalForce () |
Return most recently calculated normal force. | |
virtual cVector3d | getTangentialForce () |
Return most recently calculated tangential force. | |
void | setUseFriction (const bool &a_useFriction) |
Set whether friction is used. | |
void | setUseZillesFriction (const bool &a_useZillesFriction) |
Set whether Zilles friction is used. | |
void | setUseMelderFriction (const bool &a_useMelderFriction) |
Set whether Melder friction is used. | |
void | setMovingObject (cGenericObject *a_movingObject) |
Set moving object. | |
Protected Member Functions | |
virtual bool | goalAchieved (const cVector3d &a_proxy, const cVector3d &a_goal) const |
Test whether the proxy has reached the goal point. | |
virtual void | offsetGoalPosition (cVector3d &a_goal, const cVector3d &a_proxy) const |
Offset the goal to account for proxy volume. | |
virtual void | computeNextBestProxyPosition (cVector3d a_goal) |
Compute the next goal position of the proxy. | |
void | testFrictionAndMoveProxy (const cVector3d &goal, const cVector3d &proxy, cVector3d normal, cGenericObject *parent) |
Attempt to move the proxy, subject to friction constraints. | |
virtual void | computeForce () |
Compute force to apply to device. | |
virtual void | correctProxyForObjectMotion () |
Let proxy move along with the object it's touching, if object has moved. | |
virtual void | updateDynamicContactState () |
Set the dynamic proxy state to reflect new contact information. | |
Protected Attributes | |
cVector3d | m_proxyGlobalPos |
Global position of the proxy. | |
cVector3d | m_deviceGlobalPos |
Global position of device. | |
cVector3d | m_lastGlobalForce |
Last computed force (in global coordinate frame). | |
cVector3d | m_nextBestProxyGlobalPos |
Next best position for the proxy (in global coordinate frame). | |
bool | m_slipping |
Are we currently in a "slip friction" state? | |
cVector3d | m_normalForce |
Normal force. | |
cVector3d | m_tangentialForce |
Tangential force. | |
bool | m_useMelderFriction |
Use the Melder friction algorithm? | |
unsigned int | m_numContacts |
Number of contacts between proxy and triangles (0, 1, 2 or 3). | |
cTriangle * | m_triangle0 |
Pointer to first triangle with which proxy is in contact. | |
cTriangle * | m_triangle1 |
Pointer to second triangle with which proxy is in contact. | |
cTriangle * | m_triangle2 |
Pointer to third triangle with which proxy is in contact. | |
cGenericObject * | m_touchingObject |
Pointer to the object (if any) with which the proxy is currently in contact. | |
cGenericObject * | m_movingObject |
If the proxy is associated with a specific moving object... | |
cVector3d | m_touchingPoint |
Point of contact (if any) between proxy and object. | |
cColorf | m_colorProxy |
Color of rendered proxy. | |
cColorf | m_colorLine |
Color of rendered line. | |
double | m_radius |
Radius used to display device position. | |
double | m_displayRadius |
Radius used to display the proxy position. | |
bool | m_dynamicProxy |
Dynamic proxy flag (if on, all contacts are computed in object-local space). | |
meshPositionMap | lastIterationPositions |
Mapping from meshes to position/rotation info for handling moving objects. | |
cVector3d | m_lastObjectGlobalPos |
Dynamic proxy tracks last position of object it's touching at each call. | |
cMatrix3d | m_lastObjectGlobalRot |
Dynamic proxy tracks last rotation of object it's touching at each call. |
cProxyPointForceAlgo::cProxyPointForceAlgo | ( | ) |
Constructor of cProxyPointForceAlgo.
Constructor of cProxyPointForceAlgo.
void cProxyPointForceAlgo::initialize | ( | cWorld * | a_world, | |
const cVector3d & | a_initialPos | |||
) | [virtual] |
Initialize the algorithm.
Initialize the algorithm, including setting the pointer to the world in which the algorithm is to operate, and setting the initial position of the device.
a_world | Pointer to world in which force algorithm is operating. | |
a_initialPos | Initial position of the device. |
Reimplemented from cGenericPointForceAlgo.
Calculate interaction forces between device and meshes.
This method computes the force to add to the device due to any collisions with meshes by calling computeNextBestProxyPosition() to update the proxy location and then computeForce() to calculate a force vector based on the proxy location.
a_nextDevicePos | Current position of the device. |
Reimplemented from cGenericPointForceAlgo.
unsigned int cProxyPointForceAlgo::getContacts | ( | cTriangle *& | a_t0, | |
cTriangle *& | a_t1, | |||
cTriangle *& | a_t2 | |||
) | [virtual] |
Return the number of current contacts and the associated triangles.
Return the number of current contacts, and the associated triangles in the output parameters.
a_t0 | Returns pointer to first contact triangle. | |
a_t1 | Returns pointer to second contact triangle. | |
a_t2 | Returns pointer to third contact triangle. |
bool cProxyPointForceAlgo::goalAchieved | ( | const cVector3d & | a_proxy, | |
const cVector3d & | a_goal | |||
) | const [protected, virtual] |
Test whether the proxy has reached the goal point.
Test whether the proxy has reached the goal point, allowing for subclass- specific approximations.
a_goal | The location to which we'd like to move the proxy | |
a_proxy | The current position of the proxy |
void cProxyPointForceAlgo::offsetGoalPosition | ( | cVector3d & | a_goal, | |
const cVector3d & | a_proxy | |||
) | const [protected, virtual] |
Offset the goal to account for proxy volume.
Offset the current goal position to account for the volume/shape of the proxy.
a_goal | The location to which we'd like to move the proxy, offset upon return | |
a_proxy | The current position of the proxy |
void cProxyPointForceAlgo::computeNextBestProxyPosition | ( | cVector3d | a_goal | ) | [protected, virtual] |
Compute the next goal position of the proxy.
Given the new position of the device and considering the current position of the proxy, this function attempts to move the proxy towards the device position (the goal). If its path is blocked by an obstacle (e.g., a triangle in a mesh), the proxy is moved to this intersection point and a new goal is calculated as the closest point to the original goal in the half-plane above the intersection triangle. The process is repeated if necessary, bringing the proxy to its final location.
a_goal | The goal towards which to move the proxy, subject to constraints |
Initialize normal and tangential forces.
void cProxyPointForceAlgo::testFrictionAndMoveProxy | ( | const cVector3d & | goal, | |
const cVector3d & | proxy, | |||
cVector3d | normal, | |||
cGenericObject * | parent | |||
) | [protected] |
Attempt to move the proxy, subject to friction constraints.
Attempt to move the proxy, subject to friction constraints. This is called from computeNextBestProxyPosition when the proxy is ready to move along a known surface.
goal | The location to which we'd like to move the proxy | |
proxy | The current position of the proxy | |
normal | The surface normal at the obstructing surface | |
parent | The surface along which we're moving |
void cProxyPointForceAlgo::computeForce | ( | ) | [protected, virtual] |
Compute force to apply to device.
This method uses the information computed earlier in computeNextProxyPosition() to determine the force to apply to the device. The function computes a force proportional to the distance between the positions of the proxy and the device and scaled by the average stiffness of each contact triangle.
void cProxyPointForceAlgo::correctProxyForObjectMotion | ( | ) | [protected, virtual] |
Let proxy move along with the object it's touching, if object has moved.
This method lets the proxy move along with the object it's touching, if the object has moved since the previous proxy iteration.
void cProxyPointForceAlgo::updateDynamicContactState | ( | ) | [protected, virtual] |
Set the dynamic proxy state to reflect new contact information.
This method sets the dynamic proxy state to reflect new contact information.