public class MultiPointSpring extends PointSpringBase implements ScalableUnits, TransformableGeometry, CopyableComponent, RequiresPrePostAdvance, HasSlaveObjects, HasAuxState
Modifier and Type | Class and Description |
---|---|
class |
MultiPointSpring.Segment
Stores information for an individual segment of this spring.
|
static class |
MultiPointSpring.SeparationControl |
class |
MultiPointSpring.SubSegment
Contains subsegment information.
|
class |
MultiPointSpring.WrapKnot
Stores information for a single knot point in a wrappable segment.
|
class |
MultiPointSpring.WrapSegment
Implements a wrappable segment.
|
ModelComponent.NavpanelVisibility
HasAuxState.StateContext
Modifier and Type | Field and Description |
---|---|
double |
myDnrmGain |
static boolean |
myDrawWrapPoints |
static boolean |
myIgnoreCoriolisInJacobian |
static PropertyList |
myProps |
double |
mySor |
useMaterial
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
COPY_REFERENCES
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
MultiPointSpring() |
MultiPointSpring(double k,
double d,
double l) |
MultiPointSpring(java.lang.String name) |
MultiPointSpring(java.lang.String name,
double k,
double d,
double l) |
Modifier and Type | Method and Description |
---|---|
void |
addPoint(int idx,
Point pnt) |
void |
addPoint(Point pnt) |
void |
addPosJacobian(SparseNumberedBlockMatrix M,
double s)
Scales the components of the position Jacobian associated with this force
effector and adds it to the supplied solve matrix M.
|
void |
addSolveBlocks(SparseNumberedBlockMatrix M)
Adds any needed blocks to a solve matrix in order to accomodate the
Jacobian terms associated with this force effector.
|
void |
addTransformableDependencies(TransformGeometryContext context,
int flags)
Adds to
context any transformable components which should be
transformed as the same time as this component. |
void |
addVelJacobian(SparseNumberedBlockMatrix M,
double s)
Scales the components of the velocity Jacobian associated with this force
effector and adds it to the supplied solve matrix M.
|
void |
addWrappable(Wrappable wrappable) |
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.
|
void |
applyForces(double t)
Adds forces to the components affected by this force effector at a
particular time.
|
void |
checkStiffness(int segIdx) |
void |
clearPoints() |
void |
clearWrappables() |
double |
computeLength(boolean activeOnly) |
boolean |
containsPoint(Point pnt) |
boolean |
containsWrappable(Wrappable wrappable) |
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Create a copy of this component.
|
java.awt.Color |
getABPointColor() |
double |
getActiveLength() |
double |
getActiveLengthDot() |
int |
getAllABPoints(java.util.ArrayList<Point> pnts)
Returns all the AB points which are currently active on the
segments.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
void |
getAuxState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
double |
getContactDamping() |
java.awt.Color |
getContactingKnotsColor() |
boolean |
getContactRescaling() |
double |
getContactStiffness() |
double |
getConvergenceTol() |
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Collects external references which must also be copied in order to
duplicate this component.
|
int |
getDebugLevel() |
double |
getDnrmGain() |
boolean |
getDrawABPoints() |
boolean |
getDrawKnots() |
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
void |
getInitialAuxState(DataBuffer newData,
DataBuffer oldData)
Saves initial state information data for this component by adding data
to the supplied data buffer.
|
int |
getIterationCount() |
int |
getJacobianType()
Returns a code indicating the matrix type that results when the Jacobian
terms of this force effector are added to the solve matrix.
|
MultiPointSpring.WrapKnot |
getKnot(int segIdx,
int k) |
double |
getLength() |
double |
getLengthDot() |
boolean |
getLineSearch() |
double |
getMaxWrapDisplacement() |
int |
getMaxWrapIterations() |
Point |
getPoint(int idx) |
boolean |
getPrintProfiling() |
double |
getProfileTimeUsec() |
boolean |
getProfiling() |
MultiPointSpring.Segment |
getSegment(int idx) |
MultiPointSpring.SeparationControl |
getSeparationControl() |
void |
getSoftReferences(java.util.List<ModelComponent> refs)
Appends all soft references for this component to a list.
|
double |
getSor() |
boolean |
getUpdateContacts() |
int |
getUpdateContactsCount() |
double |
getWrapDamping() |
Wrappable |
getWrappable(int idx) |
double |
getWrapStiffness() |
int |
indexOfPoint(Point pnt) |
int |
indexOfWrappable(Wrappable wrappable) |
void |
initializeSegment(int segIdx,
Point3d[] initialPnts) |
boolean |
isDuplicatable()
Returns true if this component can be duplicated.
|
boolean |
isSegmentPassive(int segIdx) |
static void |
main(java.lang.String[] args) |
int |
numKnots(int segIdx) |
int |
numPassiveSegments() |
int |
numPoints() |
int |
numWrappables() |
void |
postadvance(double t0,
double t1,
int flags)
Called from within the model's
advance() method, after all position and velocity state has been
advanced. |
void |
preadvance(double t0,
double t1,
int flags)
Called from within the model's
preadvance() method. |
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).
|
boolean |
removePoint(Point pnt) |
boolean |
removeWrappable(Wrappable wrappable) |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
void |
scaleDistance(double s)
Scales all distance coordinates.
|
void |
scaleMass(double s)
Scales all mass units.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setABPointColor(java.awt.Color color) |
void |
setAuxState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
void |
setContactDamping(double damping) |
void |
setContactingKnotsColor(java.awt.Color color) |
void |
setContactRescaling(boolean enable) |
void |
setContactStiffness(double stiffness) |
void |
setConvergenceTol(double h) |
void |
setDebugLevel(int level) |
void |
setDnrmGain(double dnrmGain) |
void |
setDrawABPoints(boolean enable) |
void |
setDrawKnots(boolean enable) |
void |
setKnotPositions(int segIdx,
Point3d[] plist) |
void |
setLineSearch(boolean enable) |
void |
setMaxWrapDisplacement(double d) |
void |
setMaxWrapIterations(int num) |
void |
setPoint(Point pnt,
int idx) |
void |
setPrintProfiling(boolean enabled) |
void |
setProfiling(boolean enabled) |
double |
setRestLengthFromPoints()
Sets the rest length of the spring from the current point locations
|
void |
setSegmentPassive(int segIdx,
boolean passive) |
void |
setSegmentWrappable(int numk) |
void |
setSegmentWrappable(int numk,
Point3d[] initialPnts) |
void |
setSeparationControl(MultiPointSpring.SeparationControl mode) |
void |
setSor(double sor) |
void |
setUpdateContacts(boolean enable) |
void |
setWrapDamping(double damping) |
void |
setWrapStiffness(double stiffness) |
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)
Applies an affine transformation to the geometry of this component.
|
void |
transformGeometry(GeometryTransformer gtr,
TransformGeometryContext context,
int flags)
Transforms the geometry of this component, using the geometry transformer
gtr to transform its individual attributes. |
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
void |
updateReferences(boolean undo,
java.util.Deque<java.lang.Object> undoInfo)
May be called by the system if any of the soft references for
this component are removed from the the component hierarchy.
|
void |
updateSlavePos()
Called when the system's dynamic position state changes, to update the
position state of the slave objects.
|
void |
updateSlaveVel()
Called when the system's dynamic velocity state changes, to update the
velocity state of the slave objects.
|
void |
updateStructure()
Hook method to allow sub-classes to update their structure by adding
or removing points.
|
void |
updateWrapSegments()
Applies one iteration of the wrap segment updating method.
|
computeDFdl, computeDFdldot, computeF, createDefaultMaterial, createRenderProps, getEffectiveMaterial, getMaterial, getMaxForce, getRenderColor, getRenderHints, getRenderProps, getRestLength, getSelection, isSelectable, numSelectionQueriesNeeded, setDamping, setLinearMaterial, setMaterial, setMaxForce, setRenderProps, setRestLength, setStiffness
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, hasChildren, hasState, isConnectedToHierarchy, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connectToHierarchy, disconnectFromHierarchy, getName, getNavpanelVisibility, getNumber, getParent, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, setFixed, setMarked, setName, setNumber, setParent, setSelected
getProperty
getChildren, hasChildren
isWritable, write
public double mySor
public double myDnrmGain
public static boolean myIgnoreCoriolisInJacobian
public static boolean myDrawWrapPoints
public static PropertyList myProps
public MultiPointSpring()
public MultiPointSpring(java.lang.String name)
public MultiPointSpring(java.lang.String name, double k, double d, double l)
public MultiPointSpring(double k, double d, double l)
public double getSor()
public void setSor(double sor)
public double getDnrmGain()
public void setDnrmGain(double dnrmGain)
public double getWrapStiffness()
public void setWrapStiffness(double stiffness)
public int getMaxWrapIterations()
public void setMaxWrapIterations(int num)
public double getMaxWrapDisplacement()
public void setMaxWrapDisplacement(double d)
public double getWrapDamping()
public void setWrapDamping(double damping)
public double getContactStiffness()
public void setContactStiffness(double stiffness)
public double getContactDamping()
public void setContactDamping(double damping)
public boolean getContactRescaling()
public void setContactRescaling(boolean enable)
public MultiPointSpring.SeparationControl getSeparationControl()
public void setSeparationControl(MultiPointSpring.SeparationControl mode)
public double getConvergenceTol()
public void setConvergenceTol(double h)
public boolean getDrawKnots()
public void setDrawKnots(boolean enable)
public boolean getDrawABPoints()
public void setDrawABPoints(boolean enable)
public int getDebugLevel()
public void setDebugLevel(int level)
public boolean getProfiling()
public void setProfiling(boolean enabled)
public boolean getPrintProfiling()
public void setPrintProfiling(boolean enabled)
public double getProfileTimeUsec()
public int getUpdateContactsCount()
public int getIterationCount()
public boolean getLineSearch()
public void setLineSearch(boolean enable)
public boolean getUpdateContacts()
public void setUpdateContacts(boolean enable)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class PointSpringBase
public double setRestLengthFromPoints()
setRestLengthFromPoints
in class PointSpringBase
public void setSegmentPassive(int segIdx, boolean passive)
public int numPassiveSegments()
public boolean isSegmentPassive(int segIdx)
public int numKnots(int segIdx)
public void checkStiffness(int segIdx)
public MultiPointSpring.WrapKnot getKnot(int segIdx, int k)
public void applyForces(double t)
ForceEffector
applyForces
in interface ForceEffector
applyForces
in class Spring
t
- time (seconds)public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
write
.scan
in interface ModelComponent
scan
in interface Scannable
scan
in class ModelComponentBase
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
updateBounds
in class PointSpringBase
pmin
- minimum pointpmax
- maximum pointpublic java.awt.Color getContactingKnotsColor()
public void setContactingKnotsColor(java.awt.Color color)
public java.awt.Color getABPointColor()
public void setABPointColor(java.awt.Color color)
public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class PointSpringBase
list
- list of objects to be renderedpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class PointSpringBase
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 scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
scaleDistance
in class PointSpringBase
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
scaleMass
in class PointSpringBase
s
- scaling factorpublic void transformGeometry(AffineTransform3dBase X)
TransformableGeometry
TransformGeometryContext.transform (this, X, 0);
transformGeometry
in interface TransformableGeometry
X
- affine transformation to apply to the componentpublic void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags)
TransformableGeometry
gtr
to transform its individual attributes. The
context
argument supplies information about what other
components are currently being transformed, and also allows the
requesting of update actions to be performed after all transform called
have completed. The context is also the usual entity that calls
this method, from within its TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method. The argument flags
provides flags to specify
various conditions associated with the the transformation.
At present, the available flags are TransformableGeometry.TG_SIMULATING
and
TransformableGeometry.TG_ARTICULATED
.
This method is not usually called directly by applications.
Instead, it is typically called from within the
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method of the context,
which takes care of the various operations needed for a
complete transform operation, including calling
TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
to collect other
components that should be transformed, calling
TransformableGeometry.transformGeometry(maspack.matrix.AffineTransform3dBase)
for each component, notifying
component parents that the geometry has changed, and calling
any requested TransformGeometryAction
s. More details
are given in the documentation for
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
.
TransformGeometryContext
provides a number of
static convenience transform
methods
which take care of building the context and calling
apply()
for a specified set of components.
This method should not
generally call transformGeometry()
for its descendant
components. Instead, descendants needing transformation should be
specified by adding them to the context in the method TransformableGeometry.addTransformableDependencies(artisynth.core.modelbase.TransformGeometryContext, int)
.
transformGeometry
in interface TransformableGeometry
gtr
- transformer implementing the transformcontext
- context information, including what other components
are being transformedflags
- specifies conditions associated with the transformationpublic void addTransformableDependencies(TransformGeometryContext context, int flags)
TransformableGeometry
context
any transformable components which should be
transformed as the same time as this component. This will generally
include descendant components, and may also include other components to
which this component is connected in some way.
This method is generally called from with the
TransformGeometryContext.apply(maspack.geometry.GeometryTransformer, int)
method of a
TransformGeometryContext
.
addTransformableDependencies
in interface TransformableGeometry
context
- context information, to which the dependent components
are added.flags
- specifies conditions associated with the transformationpublic double computeLength(boolean activeOnly)
public double getActiveLengthDot()
public double getLengthDot()
getLengthDot
in class PointSpringBase
public double getActiveLength()
public double getLength()
getLength
in class PointSpringBase
public void addSolveBlocks(SparseNumberedBlockMatrix M)
ForceEffector
getSolveIndex
) for all dynamic or attached components affected by this
force effector.addSolveBlocks
in interface ForceEffector
M
- solve matrix to which blocks should be addedpublic void addPosJacobian(SparseNumberedBlockMatrix M, double s)
ForceEffector
M is guaranteed to be the same matrix supplied in the most recent call to
addSolveBlocks
, and so implementations may choose
to cache the relevant matrix blocks from that call, instead of retrieving
them directly from M.
addPosJacobian
in interface ForceEffector
M
- solve matrix to which scaled position Jacobian is to be addeds
- scaling factor for position Jacobianpublic void addVelJacobian(SparseNumberedBlockMatrix M, double s)
ForceEffector
M is guaranteed to be the same matrix supplied in the most recent call to
addSolveBlocks
, and so implementations may choose
to cache the relevant matrix blocks from that call, instead of retrieving
them directly from M.
addVelJacobian
in interface ForceEffector
M
- solve matrix to which scaled velocity Jacobian is to be addeds
- scaling factor for velocity Jacobianpublic int getJacobianType()
ForceEffector
Matrix.SYMMETRIC
or Matrix.POSITIVE_DEFINITE
. The former should be set if adding the Jacobian
terms preserves symmetry, and the latter should be set if positive
definiteness if preserved. Both should be set if there is no Jacobian for
this effector (i.e., the Jacobian methods are not implemented). Matrix
types from all the force effectors are logically and-ed together to
determine the type for the entire solve matrix.getJacobianType
in interface ForceEffector
public boolean isDuplicatable()
true
if and only if CopyableComponent.getCopyReferences(java.util.List<artisynth.core.modelbase.ModelComponent>, artisynth.core.modelbase.ModelComponent)
returns true.
This method is not currently used. It is intended to provide a faster
way of determining if a component can be duplicated, without having to
use CopyableComponent.getCopyReferences(java.util.List<artisynth.core.modelbase.ModelComponent>, artisynth.core.modelbase.ModelComponent)
to build the list of copy references.
isDuplicatable
in interface CopyableComponent
true
if this component can be duplicated.public boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
true
if and only if CopyableComponent.isDuplicatable()
returns
true.getCopyReferences
in interface CopyableComponent
refs
- list to which references are appendedancestor
- root node of the hierarchy from which references are to be excludedpublic ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
CopyableComponent
COPY_REFERENCES
is set in flags
, then any component referenced
by this component should itself be set to a copy. This
should be done first checking copyMap
for an
existing copy of the referenced component. If there is no existing
copy, then a copy should be created by calling copy
recursively and adding the new copy to copyMap
.copy
in interface CopyableComponent
copy
in class PointSpringBase
flags
- flags to control the copyingcopyMap
- map to possible existing instances of referenced
componentspublic void getHardReferences(java.util.List<ModelComponent> refs)
ModelComponentBase
getHardReferences
in interface ModelComponent
getHardReferences
in class ModelComponentBase
refs
- list to which hard references are appendedpublic void getSoftReferences(java.util.List<ModelComponent> refs)
ModelComponentBase
updateReferences()
method will
be called to update its internal reference information.getSoftReferences
in interface ModelComponent
getSoftReferences
in class ModelComponentBase
refs
- list to which soft references are appendedpublic void updateReferences(boolean undo, java.util.Deque<java.lang.Object> undoInfo)
ModelComponentBase
undo
equal to false
,
this component should then examine its soft references and
use ComponentUtils.isConnected()
to determine which of them have been disconnected from the hierarchy.
Disconnected references should be removed, and sufficient information
should be appended to undoInfo
to allow this update
to be undone if this method is called later with undo
equal to true
. When undoing an update, the undo
information should be removed from the front of undoInfo
.updateReferences
in interface ModelComponent
updateReferences
in class ModelComponentBase
undo
- if true
, indicates that the most
recent reference update should be undone, using the supplied
undo information.undoInfo
- if undo
is false
, should be used
to store information allowing the reference update to be undone.
Otherwise, if undo
is true
, then this
supplied information to undo the most recent update.public void preadvance(double t0, double t1, int flags)
RequiresPrePostAdvance
preadvance()
method.preadvance
in interface RequiresPrePostAdvance
t0
- current time (seconds)t1
- new time to be advanced to (seconds)flags
- flags passed to the model's
preadvance()
method (reserved for future use).public void postadvance(double t0, double t1, int flags)
RequiresPrePostAdvance
advance()
method, after all position and velocity state has been
advanced.postadvance
in interface RequiresPrePostAdvance
t0
- current time (seconds)t1
- new time to be advanced to (seconds)flags
- flags passed to the model's
advance()
method (reserved for future use).public void updateStructure()
public void updateSlavePos()
HasSlaveObjects
updateSlavePos
in interface HasSlaveObjects
public void updateSlaveVel()
HasSlaveObjects
updateSlaveVel
in interface HasSlaveObjects
public void advanceAuxState(double t0, double t1)
HasAuxState
advanceAuxState
in interface HasAuxState
t0
- beginning time associated with the time step advancet1
- end time associated with the time step advancepublic void skipAuxState(DataBuffer data)
HasAuxState
skipAuxState
in interface HasAuxState
data
- buffer containing the state informationpublic void getAuxState(DataBuffer data)
HasAuxState
getAuxState
in interface HasAuxState
data
- buffer for storing the state values.public void getInitialAuxState(DataBuffer newData, DataBuffer oldData)
HasAuxState
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.
getInitialAuxState
in interface HasAuxState
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.public void setAuxState(DataBuffer data)
HasAuxState
setAuxState
in interface HasAuxState
data
- buffer containing the state informationpublic void addPoint(int idx, Point pnt)
public void addPoint(Point pnt)
public Point getPoint(int idx)
public int numPoints()
public MultiPointSpring.Segment getSegment(int idx)
public int indexOfPoint(Point pnt)
public boolean containsPoint(Point pnt)
public void setPoint(Point pnt, int idx)
public boolean removePoint(Point pnt)
public void clearPoints()
public void setSegmentWrappable(int numk)
public void setSegmentWrappable(int numk, Point3d[] initialPnts)
public void initializeSegment(int segIdx, Point3d[] initialPnts)
public void setKnotPositions(int segIdx, Point3d[] plist)
public void addWrappable(Wrappable wrappable)
public boolean containsWrappable(Wrappable wrappable)
public int numWrappables()
public int indexOfWrappable(Wrappable wrappable)
public Wrappable getWrappable(int idx)
public boolean removeWrappable(Wrappable wrappable)
public void clearWrappables()
public void updateWrapSegments()
public int getAllABPoints(java.util.ArrayList<Point> pnts)
pnts
- returns the AB points. Will be cleared at the start
of the method.public static void main(java.lang.String[] args)