artisynth.core.mechmodels
Class RigidBodyContact

java.lang.Object
  extended by artisynth.core.mechmodels.RigidBodyContact
All Implemented Interfaces:
Constrainer, HasAuxState, RigidBodyConstrainer, GLRenderable

public class RigidBodyContact
extends java.lang.Object
implements RigidBodyConstrainer, GLRenderable, Constrainer


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.mechmodels.HasAuxState
HasAuxState.StateContext
 
Field Summary
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
RigidBodyContact(RigidBody b0, PolygonalMesh m0, RigidBody b1, PolygonalMesh m1)
           
RigidBodyContact(RigidBody b0, RigidBody b1)
           
 
Method Summary
 int addBilateralConstraints(SparseBlockMatrix GT, VectorNd dg, int numb, IntHolder changeCnt)
           
 int addFrictionConstraints(SparseBlockMatrix DT, MechSystem.FrictionInfo[] finfo, int numf)
           
 int addUnilateralConstraints(SparseBlockMatrix NT, VectorNd dn, int numu, IntHolder changeCnt)
           
 void advanceAuxState(double t0, double t1)
          Called at the very beginning of the time step (in the system's preadvance() method) to perform any required updating of the component's state before the application in input probes or controllers.
 RenderProps createRenderProps()
           
 boolean equals(java.lang.Object obj)
           
 void getAuxState(DataBuffer data)
          Saves state information for this component by adding data to the supplied DataBuffer.
 MatrixNdBlock getBilateralBlockA(int numb)
           
 MatrixNdBlock getBilateralBlockB(int numb)
           
 int getBilateralConstraints(java.util.ArrayList<RigidBodyConstraint> bilaterals)
          Gets the bilateral constraints associated with this constrainer.
 int getBilateralImpulses(VectorNd lam, int idx)
           
 int getBilateralInfo(MechSystem.ConstraintInfo[] ginfo, int idx)
           
 void getBilateralSizes(VectorNi sizes)
           
 RigidBody getBodyA()
          Returns the first body associated with this constrainer.
 RigidBody getBodyB()
          Returns the second body associated with this constrainer, or null if there is no such body.
 double getFriction()
           
 void getInitialAuxState(DataBuffer newData, DataBuffer oldData)
          Saves initial state information data for this component by adding data to the supplied data buffer.
 double getPenetrationTol()
           
 int getRenderHints()
          Returns a bit code giving rendering hints about this renderable.
 MatrixNdBlock getUnilateralBlockA(int numu)
           
 MatrixNdBlock getUnilateralBlockB(int numu)
           
 double getUnilateralConstraints(java.util.ArrayList<RigidBodyConstraint> unilaterals, boolean setEngaged)
          Gets the unilateral constraints associated with this constrainer.
 int getUnilateralImpulses(VectorNd the, int idx)
           
 int getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo, int idx)
           
 void getUnilateralSizes(VectorNi sizes)
           
 boolean hasActiveContact()
           
 int hashCode()
           
 boolean hasUnilateralConstraints()
          Returns true if this constrainer has unilateral constraints.
 int maxFrictionConstraintSets()
           
 int numBilateralConstraints()
          Returns the number of bilateral constraints associated with this constrainer.
 int numUnilateralConstraints()
          Returns the number of unilateral constraints which are currently engaged.
 void prerender(RenderList list)
          Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
 void scaleDistance(double s)
           
 void setAuxState(DataBuffer data)
          Restores the state for this component by reading from the supplied data buffer, starting at the current buffer offsets.
 int setBilateralImpulses(VectorNd lam, double h, int idx)
           
 void setFriction(double mu)
           
 void setPenetrationTol(double tol)
           
 int setUnilateralImpulses(VectorNd the, double h, int idx)
           
 void skipAuxState(DataBuffer data)
          Skips over the state information for this component contained in the supplied data buffer, starting at the current buffer offsets.
 void transformGeometry(AffineTransform3dBase X, TransformableGeometry topObject)
           
 void updateBodyStates(double t, boolean setEngaged)
          Updates internal information needed for computing constraints.
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 double updateConstraints(double t, int flags)
           
 void updateUnilateralConstraints(java.util.ArrayList<RigidBodyConstraint> unilaterals, int offset, int num)
          Updates the unilateral constraints associated with this constrainer.
 double updateValues(double t)
           
 void zeroImpulses()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RigidBodyContact

public RigidBodyContact(RigidBody b0,
                        PolygonalMesh m0,
                        RigidBody b1,
                        PolygonalMesh m1)

RigidBodyContact

public RigidBodyContact(RigidBody b0,
                        RigidBody b1)
Method Detail

setPenetrationTol

public void setPenetrationTol(double tol)
Specified by:
setPenetrationTol in interface RigidBodyConstrainer

getPenetrationTol

public double getPenetrationTol()
Specified by:
getPenetrationTol in interface RigidBodyConstrainer

getBodyA

public RigidBody getBodyA()
Description copied from interface: RigidBodyConstrainer
Returns the first body associated with this constrainer.

Specified by:
getBodyA in interface RigidBodyConstrainer
Returns:
first body associated with this constrainer

getBodyB

public RigidBody getBodyB()
Description copied from interface: RigidBodyConstrainer
Returns the second body associated with this constrainer, or null if there is no such body.

Specified by:
getBodyB in interface RigidBodyConstrainer
Returns:
second body associated with this constrainer

getFriction

public double getFriction()

setFriction

public void setFriction(double mu)

getBilateralBlockA

public MatrixNdBlock getBilateralBlockA(int numb)
Specified by:
getBilateralBlockA in interface RigidBodyConstrainer

getBilateralBlockB

public MatrixNdBlock getBilateralBlockB(int numb)
Specified by:
getBilateralBlockB in interface RigidBodyConstrainer

getUnilateralBlockA

public MatrixNdBlock getUnilateralBlockA(int numu)
Specified by:
getUnilateralBlockA in interface RigidBodyConstrainer

getUnilateralBlockB

public MatrixNdBlock getUnilateralBlockB(int numu)
Specified by:
getUnilateralBlockB in interface RigidBodyConstrainer

updateBodyStates

public void updateBodyStates(double t,
                             boolean setEngaged)
Description copied from interface: RigidBodyConstrainer
Updates internal information needed for computing constraints.

Specified by:
updateBodyStates in interface RigidBodyConstrainer
Parameters:
t - current time (seconds)
setEngaged - if true, then the method should determine which unilateral constraints are engaged

updateValues

public double updateValues(double t)

updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Parameters:
pmin - minimum point
pmax - maximum point

getRenderHints

public int getRenderHints()
Description copied from interface: GLRenderable
Returns a bit code giving rendering hints about this renderable. Current bit codes include TRANSLUCENT.

Specified by:
getRenderHints in interface GLRenderable
Returns:
bit code of rendering hints.

prerender

public void prerender(RenderList list)
Description copied from interface: GLRenderable
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer.

Specified by:
prerender in interface GLRenderable

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Parameters:
renderer - renderer object which is used to perform the rendering. Provides pointers to GL and GLU, along with helper functions.
flags - supplies flags that may be used to control different aspects of the rendering. Flags are defined in GLRenderer and currently include GLRenderer.SELECTED, GLRenderer.VERTEX_COLORING, GLRenderer.HSV_COLOR_INTERPOLATION, GLRenderer.SORT_FACES, and GLRenderer.CLEAR_MESH_DISPLAY_LISTS.

createRenderProps

public RenderProps createRenderProps()

scaleDistance

public void scaleDistance(double s)

transformGeometry

public void transformGeometry(AffineTransform3dBase X,
                              TransformableGeometry topObject)

hasUnilateralConstraints

public boolean hasUnilateralConstraints()
Description copied from interface: RigidBodyConstrainer
Returns true if this constrainer has unilateral constraints.

Specified by:
hasUnilateralConstraints in interface RigidBodyConstrainer
Returns:
true if there are unilateral constraints

numUnilateralConstraints

public int numUnilateralConstraints()
Description copied from interface: RigidBodyConstrainer
Returns the number of unilateral constraints which are currently engaged. This should be the same as the number of constraints that would be returned by getUnilateralConstraints with setEngaged set to false.

Specified by:
numUnilateralConstraints in interface RigidBodyConstrainer
Returns:
number of currently engaged unilateral constraints

getUnilateralConstraints

public double getUnilateralConstraints(java.util.ArrayList<RigidBodyConstraint> unilaterals,
                                       boolean setEngaged)
Description copied from interface: RigidBodyConstrainer
Gets the unilateral constraints associated with this constrainer. They are supplied by the constrainer and appended to an array list.

Specified by:
getUnilateralConstraints in interface RigidBodyConstrainer
Parameters:
unilaterals - array list into which the constrainer places the constraints
setEngaged - if true, recompute the set of unilateral constraints. If false, the set of unilateral constraints will stay the same.
Returns:
maximum penetration of the unilateral constraints

updateUnilateralConstraints

public void updateUnilateralConstraints(java.util.ArrayList<RigidBodyConstraint> unilaterals,
                                        int offset,
                                        int num)
Description copied from interface: RigidBodyConstrainer
Updates the unilateral constraints associated with this constrainer. The constraints are the same as those returned by the most recent call to getUnilateralConstraints, located at a specific offset within an array list.

Specified by:
updateUnilateralConstraints in interface RigidBodyConstrainer
Parameters:
unilaterals - contains constraints which should be updated
offset - starting location of constraints within unilaterals
num - number of constraints to update

setUnilateralImpulses

public int setUnilateralImpulses(VectorNd the,
                                 double h,
                                 int idx)
Specified by:
setUnilateralImpulses in interface Constrainer
Specified by:
setUnilateralImpulses in interface RigidBodyConstrainer

zeroImpulses

public void zeroImpulses()
Specified by:
zeroImpulses in interface Constrainer
Specified by:
zeroImpulses in interface RigidBodyConstrainer

getUnilateralImpulses

public int getUnilateralImpulses(VectorNd the,
                                 int idx)
Specified by:
getUnilateralImpulses in interface Constrainer
Specified by:
getUnilateralImpulses in interface RigidBodyConstrainer

getBilateralSizes

public void getBilateralSizes(VectorNi sizes)
Specified by:
getBilateralSizes in interface Constrainer
Specified by:
getBilateralSizes in interface RigidBodyConstrainer

getUnilateralSizes

public void getUnilateralSizes(VectorNi sizes)
Specified by:
getUnilateralSizes in interface Constrainer
Specified by:
getUnilateralSizes in interface RigidBodyConstrainer

updateConstraints

public double updateConstraints(double t,
                                int flags)
Specified by:
updateConstraints in interface Constrainer
Specified by:
updateConstraints in interface RigidBodyConstrainer

addBilateralConstraints

public int addBilateralConstraints(SparseBlockMatrix GT,
                                   VectorNd dg,
                                   int numb,
                                   IntHolder changeCnt)
Specified by:
addBilateralConstraints in interface Constrainer

getBilateralInfo

public int getBilateralInfo(MechSystem.ConstraintInfo[] ginfo,
                            int idx)
Specified by:
getBilateralInfo in interface Constrainer

addUnilateralConstraints

public int addUnilateralConstraints(SparseBlockMatrix NT,
                                    VectorNd dn,
                                    int numu,
                                    IntHolder changeCnt)
Specified by:
addUnilateralConstraints in interface Constrainer

getUnilateralInfo

public int getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo,
                             int idx)
Specified by:
getUnilateralInfo in interface Constrainer

maxFrictionConstraintSets

public int maxFrictionConstraintSets()
Specified by:
maxFrictionConstraintSets in interface Constrainer

addFrictionConstraints

public int addFrictionConstraints(SparseBlockMatrix DT,
                                  MechSystem.FrictionInfo[] finfo,
                                  int numf)
Specified by:
addFrictionConstraints in interface Constrainer

numBilateralConstraints

public int numBilateralConstraints()
Description copied from interface: RigidBodyConstrainer
Returns the number of bilateral constraints associated with this constrainer.

Specified by:
numBilateralConstraints in interface RigidBodyConstrainer
Returns:
number of bilateral constraints

getBilateralConstraints

public int getBilateralConstraints(java.util.ArrayList<RigidBodyConstraint> bilaterals)
Description copied from interface: RigidBodyConstrainer
Gets the bilateral constraints associated with this constrainer. They are supplied by the constrainer and appended to an array list.

Specified by:
getBilateralConstraints in interface RigidBodyConstrainer
Parameters:
bilaterals - array list into which the constrainer places the constraints

setBilateralImpulses

public int setBilateralImpulses(VectorNd lam,
                                double h,
                                int idx)
Specified by:
setBilateralImpulses in interface Constrainer
Specified by:
setBilateralImpulses in interface RigidBodyConstrainer

getBilateralImpulses

public int getBilateralImpulses(VectorNd lam,
                                int idx)
Specified by:
getBilateralImpulses in interface Constrainer
Specified by:
getBilateralImpulses in interface RigidBodyConstrainer

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

advanceAuxState

public void advanceAuxState(double t0,
                            double t1)
Description copied from interface: HasAuxState
Called at the very beginning of the time step (in the system's preadvance() method) to perform any required updating of the component's state before the application in input probes or controllers. If no such updating is required, this method may do nothing.

Specified by:
advanceAuxState in interface HasAuxState
Parameters:
t0 - beginning time associated with the time step advance
t1 - end time associated with the time step advance

skipAuxState

public void skipAuxState(DataBuffer data)
Skips over the state information for this component contained in the supplied data buffer, starting at the current buffer offsets. Essentially this a dummy read; the buffer offsets should be advanced over the state information, but that information should not actually be stored in the component.

Specified by:
skipAuxState in interface HasAuxState
Parameters:
data - buffer containing the state information

getAuxState

public void getAuxState(DataBuffer data)
Description copied from interface: HasAuxState
Saves state information for this component by adding data to the supplied DataBuffer. Existing data in the buffer should not be disturbed.

Specified by:
getAuxState in interface HasAuxState
Parameters:
data - buffer for storing the state values.

getInitialAuxState

public void getInitialAuxState(DataBuffer newData,
                               DataBuffer oldData)
Description copied from interface: HasAuxState
Saves initial state information data for this component by adding data to the supplied data buffer. Existing data in the buffer should not be disturbed.

If oldData is non-null, then this contains previously stored initial state information (starting at its current buffer offsets), which should be stored into newData in place of the current component state data. This may only be partially possible if the component's state structure has changed since oldData was written.

Specified by:
getInitialAuxState in interface HasAuxState
Parameters:
newData - buffer for storing the state values.
oldData - if non-null, contains old state information that should be written into newData in place of the current state information.

setAuxState

public void setAuxState(DataBuffer data)
Description copied from interface: HasAuxState
Restores the state for this component by reading from the supplied data buffer, starting at the current buffer offsets.

Specified by:
setAuxState in interface HasAuxState
Parameters:
data - buffer containing the state information

hasActiveContact

public boolean hasActiveContact()