public class CollisionHandler extends RenderableConstrainerBase implements HasRenderProps, Renderable
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static boolean |
computeTimings |
static boolean |
myPrune |
static boolean |
preventBilateralSeparation |
myProps
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
CollisionHandler(CollisionManager manager) |
CollisionHandler(CollisionManager manager,
CollidableBody col0,
CollidableBody col1,
CollisionBehavior behav,
artisynth.core.mechmodels.CollisionManager.BehaviorSource src) |
Modifier and Type | Method and Description |
---|---|
int |
addBilateralConstraints(SparseBlockMatrix GT,
VectorNd dg,
int numb)
Appends the current bilateral force constraint matrix
Gc^T to the
matrix GT , by appending block columns to it. |
int |
addFrictionConstraints(SparseBlockMatrix DT,
java.util.ArrayList<FrictionInfo> finfo,
boolean prune,
int numf)
Appends the friction force constraint matrix
Dc^T to the matrix
DT , by appending block columns to it. |
int |
addUnilateralConstraints(SparseBlockMatrix NT,
VectorNd dn,
int numu)
Appends the current unilateral force constraint matrix
Nc^T to the
matrix NT , by appending block columns to it. |
static boolean |
attachedNearContact(ContactPoint cpnt,
Collidable collidable,
java.util.Set<Vertex3d> attachedVertices) |
void |
clearContactActivity() |
double |
computeCollisionConstraints(ContactInfo cinfo) |
void |
getBilateralConstraints(java.util.List<ContactConstraint> list) |
int |
getBilateralForces(VectorNd lam,
int idx)
Returns the bilateral forces that were most recently set for this
constrainer using
Constrainer.setBilateralForces(maspack.matrix.VectorNd, double, int) . |
int |
getBilateralInfo(MechSystem.ConstraintInfo[] ginfo,
int idx)
Returns constraint information for each row of the bilateral
constraint system
|
void |
getBilateralSizes(VectorNi sizes)
Returns the sizes of each block column in the bilateral force constraint
matrix.
|
int |
getBodyIndex(Collidable col)
Returns 0 if a specified collidable is associated with this handler's
first collidable body, 1 if it is associated with the second body,
and -1 if it is associated with neither.
|
CollidableBody |
getCollidable(int cidx) |
CollidablePair |
getCollidablePair() |
void |
getConstrainedComponents(java.util.HashSet<DynamicComponent> set) |
void |
getConstrainedComponents(java.util.List<DynamicComponent> list)
Collected all the dynamic components constrained by this constrainer.
|
ContactConstraint |
getContact(java.util.HashMap<ContactPoint,ContactConstraint> contacts,
ContactPoint cpnt0,
ContactPoint cpnt1,
boolean hashUsingFace,
boolean pnt0OnCollidable1,
double distance) |
CollisionHandler |
getDown()
Returns next handler in a column of a CollisionHandlerTable.
|
int |
getFrictionForces(VectorNd phi,
int idx)
Returns the friction forces that were most recently set for this
constrainer using
Constrainer.setFrictionForces(maspack.matrix.VectorNd, double, int) . |
int |
getFrictionState(VectorNi state,
int idx) |
ContactInfo |
getLastContactInfo() |
CollisionHandler |
getNext()
Returns next handler in a row of a CollisionHandlerTable.
|
CollidableBody |
getOtherCollidable(CollidableBody cb) |
RenderProps |
getRenderProps()
Returns the render properities for this object.
|
void |
getState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
int |
getUnilateralForces(VectorNd the,
int idx)
Returns the unilateral forces that were most recently set for this
constrainer using
Constrainer.setUnilateralForces(maspack.matrix.VectorNd, double, int) . |
int |
getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo,
int idx)
Returns constraint information for each row of the unilateral
constraint system
|
void |
getUnilateralSizes(VectorNi sizes)
Returns the sizes of each block column in the unilateral force constraint
matrix.
|
int |
getUnilateralState(VectorNi state,
int idx) |
int |
maxFrictionConstraintSets()
Returns the maximum number of friction constraint sets that can be
expected for this constraint.
|
int |
numBilateralConstraints() |
int |
numUnilateralConstraints() |
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
void |
prerender(RenderProps props) |
void |
printNetContactForces() |
void |
removeInactiveContacts() |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
void |
render(Renderer renderer,
RenderProps props,
int flags) |
int |
setBilateralForces(VectorNd lam,
double s,
int idx)
Sets the bilateral forces that were computed to enforce this
constraint.
|
void |
setDown(CollisionHandler down)
Sets next handler in a column of a CollisionHandlerTable.
|
int |
setFrictionForces(VectorNd phi,
double s,
int idx)
Sets the friction forces that were computed to enforce this
constraint.
|
int |
setFrictionState(VectorNi state,
int idx) |
void |
setNext(CollisionHandler next)
Sets next handler in a row of a CollisionHandlerTable.
|
void |
setState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
int |
setUnilateralForces(VectorNd the,
double s,
int idx)
Sets the unilateral forces that were computed to enforce this
constraint.
|
int |
setUnilateralState(VectorNi state,
int idx) |
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
double |
updateConstraints(double t,
int flags)
Updates the current set of constraints, and returns the maximum
penetration
> 0 associated with all of them. |
void |
zeroForces()
Zeros all bilateral and unilateral constraint forces in this constraint.
|
copy, createRenderProps, defaultRenderPropsAreNull, getAllPropertyInfo, getRenderHints, getSelection, isSelectable, numSelectionQueriesNeeded, setRenderProps
hasState
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, scan, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSelection, isSelectable, numSelectionQueriesNeeded
getRenderHints
createRenderProps, setRenderProps
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
advanceState, getAuxVarDerivative, getAuxVarState, getStateVersion, numAuxVars, requiresAdvance, setAuxVarState
public static boolean computeTimings
public static boolean preventBilateralSeparation
public static boolean myPrune
public CollisionHandler(CollisionManager manager)
public CollisionHandler(CollisionManager manager, CollidableBody col0, CollidableBody col1, CollisionBehavior behav, artisynth.core.mechmodels.CollisionManager.BehaviorSource src)
public RenderProps getRenderProps()
HasRenderProps
getRenderProps
in interface HasRenderProps
getRenderProps
in class RenderableConstrainerBase
public ContactInfo getLastContactInfo()
public static boolean attachedNearContact(ContactPoint cpnt, Collidable collidable, java.util.Set<Vertex3d> attachedVertices)
public ContactConstraint getContact(java.util.HashMap<ContactPoint,ContactConstraint> contacts, ContactPoint cpnt0, ContactPoint cpnt1, boolean hashUsingFace, boolean pnt0OnCollidable1, double distance)
public double computeCollisionConstraints(ContactInfo cinfo)
public CollidableBody getCollidable(int cidx)
public int getBodyIndex(Collidable col)
col
- collidable to inspectcol
.public CollidableBody getOtherCollidable(CollidableBody cb)
public CollidablePair getCollidablePair()
public CollisionHandler getNext()
public void setNext(CollisionHandler next)
next
- next handler to add to the rowpublic CollisionHandler getDown()
public void setDown(CollisionHandler down)
down
- next handler to add to the columnpublic void clearContactActivity()
public void removeInactiveContacts()
public double updateConstraints(double t, int flags)
Constrainer
>
0 associated with all of them. If no constraints are
presently active, returns -1.updateConstraints
in interface Constrainer
updateConstraints
in class ConstrainerBase
public void getConstrainedComponents(java.util.List<DynamicComponent> list)
Constrainer
getConstrainedComponents
in interface Constrainer
getConstrainedComponents
in class ConstrainerBase
list
- list to which constrained components should be appendedpublic void getConstrainedComponents(java.util.HashSet<DynamicComponent> set)
public void getBilateralSizes(VectorNi sizes)
Constrainer
sizes
.getBilateralSizes
in interface Constrainer
getBilateralSizes
in class ConstrainerBase
sizes
- vector to which the block column sizes are appendedpublic void getUnilateralSizes(VectorNi sizes)
Constrainer
sizes
.getUnilateralSizes
in interface Constrainer
getUnilateralSizes
in class ConstrainerBase
sizes
- vector to which the block column sizes are appendedpublic void getBilateralConstraints(java.util.List<ContactConstraint> list)
public int addBilateralConstraints(SparseBlockMatrix GT, VectorNd dg, int numb)
Constrainer
Gc^T
to the
matrix GT
, by appending block columns to it. If the argument
dg
is non-null
, it should be used to return the
velocity constraint time derivative, defined by
\dot Gc velstarting at the location
numb
. In all cases, the method must
return an updated value of numb
, incremented by the total row
size of Gc
.addBilateralConstraints
in interface Constrainer
addBilateralConstraints
in class ConstrainerBase
GT
- matrix to which the bilateral force contraint matrix
is appended.dg
- if non-null
, returns the velocity constraint time
derivativenumb
- starting index for time derivative in dg
numb
public int getBilateralInfo(MechSystem.ConstraintInfo[] ginfo, int idx)
Constrainer
Gc vel = 0.This information is placed in pre-allocated
MechSystem.ConstraintInfo
structures in ginfo
, starting at idx
. The method must
return an updated value of idx
, incremented by the number of
rows of Gc
.
The constraint information to be set in ConstraintInfo
includes:
dist // distance to the constraint surface. compliance // if > 0, gives constraint compliance value damping // damping; only used if compliance > 0 force // used for computing non-linear compliance
getBilateralInfo
in interface Constrainer
getBilateralInfo
in class ConstrainerBase
ginfo
- returns the constraint informationidx
- starting location in ginfo
for returning constraint
infoidx
public int setBilateralForces(VectorNd lam, double s, int idx)
Constrainer
lam
, starting at the index idx
, and should be
scaled by s
. (In practice, s
is used to convert from
impulses to forces.) The method must return an updated value of idx
, incremented by the number of forces associated with this constraint.setBilateralForces
in interface Constrainer
setBilateralForces
in class ConstrainerBase
lam
- supplies the force impulses, which should be scaled by s
s
- scaling factor for the force valuesidx
- starting index of forces in lam
idx
public int getBilateralForces(VectorNd lam, int idx)
Constrainer
Constrainer.setBilateralForces(maspack.matrix.VectorNd, double, int)
. The forces are returned in
lam
, starting at the index idx
. The method must return
an updated value of idx
, incremented by the number of forces
associated with this constraint.getBilateralForces
in interface Constrainer
getBilateralForces
in class ConstrainerBase
lam
- returns the forcesidx
- starting index for forces in lam
idx
public void zeroForces()
Constrainer
zeroForces
in interface Constrainer
zeroForces
in class ConstrainerBase
public int addUnilateralConstraints(SparseBlockMatrix NT, VectorNd dn, int numu)
Constrainer
Nc^T
to the
matrix NT
, by appending block columns to it. If the argument
dn
is non-null
, it should be used to return the
velocity constraint time derivative, defined by
\dot Nc velstarting at the location
numu
. In all cases, the method must
return an updated value of numu
, incremented by the total row
size of Nc
.addUnilateralConstraints
in interface Constrainer
addUnilateralConstraints
in class ConstrainerBase
NT
- matrix to which the unilateral force contraint matrix
is appended.dn
- if non-null
, returns the velocity constraint time
derivativenumu
- starting index for time derivative in dn
numu
public int getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo, int idx)
Constrainer
Nc vel > 0.This information is placed in pre-allocated
MechSystem.ConstraintInfo
structures in ninfo
, starting at idx
. The method must
return an updated value of idx
, incremented by the number of
rows of Nc
.
The constraint information to be set in ConstraintInfo
includes:
dist // distance to the constraint surface. compliance // if > 0, gives constraint compliance value damping // damping; only used if compliance > 0 force // used for computing non-linear compliance
getUnilateralInfo
in interface Constrainer
getUnilateralInfo
in class ConstrainerBase
ninfo
- returns the constraint informationidx
- starting location in ninfo
for returning constraint
infoidx
public int setUnilateralForces(VectorNd the, double s, int idx)
Constrainer
the
, starting at the index idx
, and should be
scaled by s
. (In practice, s
is used to convert from
impulses to forces.) The method must return an updated value of idx
, incremented by the number of forces associated with this constraint.setUnilateralForces
in interface Constrainer
setUnilateralForces
in class ConstrainerBase
the
- supplies the force impulses, which should be scaled by s
s
- scaling factor for the force valuesidx
- starting index of forces in the
idx
public int getUnilateralForces(VectorNd the, int idx)
Constrainer
Constrainer.setUnilateralForces(maspack.matrix.VectorNd, double, int)
. The forces are returned in
the
, starting at the index idx
. The method must return
an updated value of idx
, incremented by the number of forces
associated with this constraint.getUnilateralForces
in interface Constrainer
getUnilateralForces
in class ConstrainerBase
the
- returns the forcesidx
- starting index for forces in the
idx
public int setUnilateralState(VectorNi state, int idx)
setUnilateralState
in interface Constrainer
setUnilateralState
in class ConstrainerBase
public int getUnilateralState(VectorNi state, int idx)
getUnilateralState
in interface Constrainer
getUnilateralState
in class ConstrainerBase
public int maxFrictionConstraintSets()
Constrainer
finfo
argument that is
passed to Constrainer.addFrictionConstraints(maspack.matrix.SparseBlockMatrix, java.util.ArrayList<maspack.spatialmotion.FrictionInfo>, boolean, int)
.maxFrictionConstraintSets
in interface Constrainer
maxFrictionConstraintSets
in class ConstrainerBase
public int addFrictionConstraints(SparseBlockMatrix DT, java.util.ArrayList<FrictionInfo> finfo, boolean prune, int numf)
Constrainer
Dc^T
to the matrix
DT
, by appending block columns to it. Each block column in Dc^T
corresponds to a friction constraint set, for which
information should be supplied in the pre-allocated FrictionInfo
structures in finfo
, starting at idx
. The method must
return an updated value of idx
, incremented by the number of
friction constraint sets.addFrictionConstraints
in interface Constrainer
addFrictionConstraints
in class ConstrainerBase
DT
- matrix to which the friction force contraint matrix
is appended.finfo
- returns friction constraint information for each
block column in Dc^T
prune
- restrict entries of DT to friction constraints
for which the contact force is > 0
.numf
- starting index for friction information in finfo
idx
public int setFrictionForces(VectorNd phi, double s, int idx)
phi
, starting at the index idx
, and should be
scaled by s
. (In practice, s
is used to convert from
impulses to forces.) The method must return an updated value of idx
, incremented by the number of forces associated with this constraint.setFrictionForces
in interface Constrainer
setFrictionForces
in class ConstrainerBase
phi
- supplies the force impulses, which should be scaled by s
s
- scaling factor for the force valuesidx
- starting index of forces in phi
idx
public int getFrictionForces(VectorNd phi, int idx)
Constrainer.setFrictionForces(maspack.matrix.VectorNd, double, int)
. The forces are returned in
phi
, starting at the index idx
. The method must return
an updated value of idx
, incremented by the number of forces
associated with this constraint.getFrictionForces
in interface Constrainer
getFrictionForces
in class ConstrainerBase
phi
- returns the forcesidx
- starting index for forces in phi
idx
public int setFrictionState(VectorNi state, int idx)
setFrictionState
in interface Constrainer
setFrictionState
in class ConstrainerBase
public int getFrictionState(VectorNi state, int idx)
getFrictionState
in interface Constrainer
getFrictionState
in class ConstrainerBase
public void printNetContactForces()
public int numBilateralConstraints()
public int numUnilateralConstraints()
public void getState(DataBuffer data)
getState
in interface HasNumericState
getState
in class ConstrainerBase
data
- buffer for storing the state values.public void setState(DataBuffer data)
setState
in interface HasNumericState
setState
in class ConstrainerBase
data
- buffer containing the state informationpublic void prerender(RenderProps props)
public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class RenderableConstrainerBase
list
- list of objects to be renderedpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class RenderableConstrainerBase
renderer
- provides the functionality used to perform the rendering.flags
- flags that may be used to control different
aspects of the rendering. Flags are defined in Renderer
and currently include
Renderer.HIGHLIGHT
and
Renderer.SORT_FACES
.public void render(Renderer renderer, RenderProps props, int flags)
public void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
updateBounds
in class RenderableConstrainerBase
pmin
- minimum pointpmax
- maximum point