public class MultiPointSpring extends PointSpringBase implements ScalableUnits, TransformableGeometry, CopyableComponent, RequiresPrePostAdvance, HasSlaveObjects
A multipoint spring is divided into one or more segments, each
separated by a single point and represented by a MultiPointSpring.Segment
.
Segments may optionally by made wrappable, allowing them to wrap
around any of the Wrappable
objects known the spring. Wrappable
segments are represented by the MultiPointSpring.WrapSegment
subclass of MultiPointSpring.Segment
. Each wrappable segment is implemented using a prescribed number of
knot points (typically 50-100), which are drawn tightly around the wrappable
objects using fictitious wrap forces which pull them together and
contact forces that repel them from the wrappables. The process of
determining the wrap path is done using a Newton-based iteration inside the
MultiPointSpring.WrapSegment.updateWrapStrand(int)
method of MultiPointSpring.WrapSegment
.
When a WrapSegment makes contact with one or more wrappables, is
dynamically partitioned into two or more subsegments separating the
contacting wrappables and the spring start and end points. More
specifically, assume that the segment is in contact with n
wrappables, identified by W_j for 0 <= j < n
. Then
the segment will be divided into n + 1 subsegments, where
During simulation, forces are imparted from the spring to each contacting
wrappable via A/B points, which represent the locations at which the spring
first makes contact (A point) and finally breaks contact (B point) with the
wrappable. The A/B points are associated with the subsegments of each
wrappable segment, and are computed dynamically when the subsegments
are computed, which happens inside the MultiPointSpring.WrapSegment.updateSubSegments()
method of MultiPointSpring.WrapSegment
.
The computation of the wrap path and the updating of the subsegments for
all wrappable segments occurs inside updateWrapSegments(int)
,
which is initially called at time 0 (before any simulation steps)
inside preadvance(double, double, int)
, and subsequently after each
simulation step inside postadvance(double, double, int)
.
Modifier and Type | Class and Description |
---|---|
class |
MultiPointSpring.Segment
Stores information for the segments of this spring.
|
static class |
MultiPointSpring.SegmentSpec
Stores specification information for the segments of this spring.
|
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
Modifier and Type | Field and Description |
---|---|
double |
maxForceNorm |
double |
maxLengthErr |
static boolean |
myDrawWrapPoints |
static PropertyList |
myProps |
double |
sumForceNorm |
double |
sumLengthErr |
int |
totalCalls |
int |
totalFails |
int |
totalFalseStuck |
int |
totalStuck |
myIgnoreCoriolisInJacobian, useMaterial
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
COPY_REFERENCES, REST_POSITION
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
MultiPointSpring()
Constructs an empty multipoint spring.
|
MultiPointSpring(double k,
double d,
double l0)
Constructs an empty multipoint spring initialized with a linear axial
material.
|
MultiPointSpring(java.lang.String name)
Constructs an empty multipoint spring with a name.
|
MultiPointSpring(java.lang.String name,
double k,
double d,
double l0)
Constructs an empty multipoint spring with a name and initialized with a
linear axial material.
|
Modifier and Type | Method and Description |
---|---|
void |
addPoint(int idx,
Point pnt)
Adds a point to this spring at a specified index.
|
void |
addPoint(Point pnt)
Adds a point to this spring.
|
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)
Adds a wrappable to this spring which is applied to all wrap segments.
|
void |
addWrappable(Wrappable wrappable,
int pntIdx0,
int pntIdx1)
Adds a wrappable to this spring which is applied to the segments between
the points indexed by
pntIdx0 and pntIdx1 . |
void |
applyForces(double t)
Applies forces to the points of this spring, as well as any wrappables
that are in contact with wrappable segments, resulting from the tension
in the spring.
|
void |
clearPoints()
Removes all points (and segments) from this spring.
|
void |
clearWrappables()
Removes all wrappables from this spring
|
boolean |
clearWrappableSegment(int segIdx) |
boolean |
containsPoint(Point pnt)
Queries whether this spring contains a specified points.
|
boolean |
containsWrappable(Wrappable wrappable)
Queries whether or not this spring contains a wrappable
for which wrapping is applied to all segments.
|
boolean |
containsWrappable(Wrappable wrappable,
int pntIdx0,
int pntIdx1)
Queries whether or not this spring contains a wrappable which is applied
to the segments between the points indexed by
pntIdx0 and pntIdx1 . |
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Makes a copy of this spring.
|
java.awt.Color |
getABPointColor()
Queries the color to be used for rendering A/B points.
|
double |
getActiveLength()
Computes the active length of this spring, corresponding to
the length of all the active segments.
|
double |
getActiveLengthDot()
Computes the derivative of the active length of this spring.
|
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.
|
int |
getContactCount()
When profiling is enabled, returns the total number of times that the
wrap path was in contact.
|
double |
getContactDamping()
Queries the the contact damping for this spring.
|
java.awt.Color |
getContactingKnotsColor()
Queries the color, if any, used for rendering knots that are in contact,
or
null if no such color is specified. |
double |
getContactStiffness()
Queries the contact stiffness for this spring.
|
int |
getConvergedCount()
When profiling is enabled, returns the total number of times that the
wrap path solution converged.
|
double |
getConvergenceTol()
Queries the convergence tolerance for this spring.
|
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Does nothing and returns
false , since copying of MultiPointSpring
is not currently implemented. |
int |
getDebugLevel()
Gets the debug level for this spring.
|
boolean |
getDrawABPoints()
Queries whether drawing A/B points is enabled for this spring.
|
double |
getDrawDisplacements() |
boolean |
getDrawKnots()
Queries whether knot rendering is enabled for this spring.
|
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
int |
getIterationCount()
When profiling is enabled, returns the cummulative number of iterations
for updating all wrap paths.
|
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)
Returns the
k -th knot in the current segment indexed by segIdx . |
double |
getLength()
Computes the length of this spring.
|
double |
getLengthDot()
Computes the derivative of the length of this spring.
|
boolean |
getLineSearch()
Queries whether line search is enabled for this spring.
|
double |
getMaxWrapDisplacement()
Queries the maximum wrap displacement for this spring.
|
int |
getMaxWrapIterations()
Queries the maximum number of wrap iterations for this spring.
|
Point |
getPoint(int idx)
Returns the
idx -th point in this spring. |
boolean |
getPrintProfiling()
Queries whether printing profile timing information is enabled for this
spring.
|
int |
getProfileCount()
When profiling is enabled, returns the total number of times a wrap
path has been updated.
|
double |
getProfileTimeUsec()
When profiling is enabled, returns the averge compute time required
to update each wrap path.
|
boolean |
getProfiling()
Queries whether the collection of profiling information is enabled for
this spring.
|
MultiPointSpring.Segment |
getSegment(int segIdx)
Returns the curren segment indexed by
segIdx in this spring. |
MultiPointSpring.SegmentSpec |
getSegmentSpec(int segIdx)
Returns the segment indexed by
segIdx in this spring. |
void |
getSoftReferences(java.util.List<ModelComponent> refs)
Appends all soft references for this component to a list.
|
double |
getSor()
Gets the successive overrelaxation parameter for this spring.
|
void |
getState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
int |
getUpdateContactsCount()
When profiling is enabled, returns the cummulative number of contact
detection operations for all wrappable segment updates.
|
double |
getWrapDamping()
Queries the wrap damping for this spring.
|
double |
getWrapKnotDensity()
Returns the default knot density for wrapping strands.
|
PropertyMode |
getWrapKnotDensityMode() |
Wrappable |
getWrappable(int idx)
Returns the idx-th wrappable in this spring.
|
int[] |
getWrappableRange(int idx)
Returns the point indices defining the wrappable range for the idx-th
wrappable in this spring.
|
double |
getWrapStiffness()
Queries the wrap stiffness for this spring.
|
boolean |
hasConditionalPoints() |
boolean |
hasMovingMarkers() |
boolean |
hasState()
Queries if this component has state.
|
boolean |
hasWrappableSegments() |
int |
indexOfPoint(Point pnt)
Returns the index of a specified point in this spring, or -1 if the
point is not present.
|
int |
indexOfWrappable(Wrappable wrappable)
Returns the index of a wrappable in this spring which is applied to
all segments, or -1 if such a wrappable is not present.
|
int |
indexOfWrappable(Wrappable wrappable,
int pntIdx0,
int pntIdx1)
Returns the index of a wrappable in this spring which is applied to the
segments between the points indexed by
pntIdx0 and pntIdx1 . |
void |
initializeSegment(int segIdx,
Point3d[] initialPnts)
Initializes the wrap path for the wrappable segment indexed by
segIdx , using a specified set of initialization points. |
boolean |
isDuplicatable()
Returns
false , since copying of MultiPointSpring is not currently
implemented. |
boolean |
isSegmentPassive(int segIdx)
Queries whether the segment indexed by
segIdx is passive. |
static void |
main(java.lang.String[] args) |
int |
numKnots(int segIdx)
Queries the number of knots in the current segment indexed by
segIdx . |
int |
numPassiveSegments()
Queries the number of passive segments in this spring.
|
int |
numPoints()
Queries the number of points in this spring.
|
int |
numSegments()
Returns the current number of segments in this spring.
|
int |
numSegmentSpecs()
Returns the number of specified segment in this spring.
|
int |
numWrappables()
Queries the number of wrappables specified in this spring.
|
java.lang.String |
pathWrapString() |
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 |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
void |
preadvance(double t0,
double t1,
int flags)
Called from within the model's {
advance() method, before position and velocity states are
advanced. |
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)
Removes a point (and the corresponding segment, if the point is not the
first point) from this spring.
|
boolean |
removeWrappable(Wrappable wrappable)
Remove from this spring a wrappable which is applied to all segments.
|
boolean |
removeWrappable(Wrappable wrappable,
int pntIdx0,
int pntIdx1)
Remove from this spring a wrappable which is applied to the segments
between the points indexed by
pntIdx0 and pntIdx1 . |
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)
Sets the color to be used for rendering A/B points.
|
void |
setAllSegmentsWrappable(int numk)
Sets all segments in this spring to be wrappable with a specified number
of knots.
|
void |
setContactDamping(double damping)
Sets the contact damping for this spring.
|
void |
setContactingKnotsColor(java.awt.Color color)
Sets a special color that should be used for rendering knots that are in
contact.
|
void |
setContactStiffness(double stiffness)
Sets the contact stiffness for this spring.
|
void |
setConvergenceTol(double tol)
Sets the convergence tolerance
tol for this spring. |
void |
setDebugLevel(int level)
Sets the debug level for this spring.
|
void |
setDrawABPoints(boolean enable)
Enables or disables drawing A/B points for this spring.
|
void |
setDrawDisplacements(double scale) |
void |
setDrawKnots(boolean enable)
Enables or disables knot rendering for this spring.
|
void |
setKnotPositions(int segIdx,
Point3d[] plist)
Sets the knot positions for a wrappable current segment
indxed by
segIdx . |
void |
setLineSearch(boolean enable)
Enables or disables line search for this spring.
|
void |
setMaxWrapDisplacement(double d)
Sets the maximum wrap displacement for this spring.
|
void |
setMaxWrapIterations(int num)
Sets the maximum number of wrap iterations for this spring.
|
void |
setPrintProfiling(boolean enabled)
Enables or disables the printing of profile timing information for this
spring.
|
void |
setProfiling(boolean enabled)
Enables or disables the collection of profiling information for this
spring.
|
double |
setRestLengthFromPoints()
Sets the rest length of the spring from the current point locations
|
void |
setSegmentPassive()
Sets the current spring segment (the one following the most recently
added point) to be passive, meaning that its length is not
included as part of the spring's active length.
|
void |
setSegmentPassive(int segIdx,
boolean passive)
Sets whether or not the segment indexed by
segIdx is
passive, meaning that its length is not included as part of the
spring's active length. |
void |
setSegmentWrappable(int numk)
Sets the current spring segment (the one following the most recently
added point) to be wrappable, with a specified number of knots.
|
void |
setSegmentWrappable(int segIdx,
int numk,
Point3d[] initialPnts)
Sets the segment indexed by
segIdx to be wrappable, with a
specified number of knots and set of initialization points. |
void |
setSegmentWrappable(int numk,
Point3d[] initialPnts)
Sets the current spring segment (the one following the most recently
added point) to be wrappable, with a specified number of knots and
initialization points.
|
void |
setSor(double sor)
Sets the successive overrelaxation parameter for this spring.
|
void |
setState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
void |
setWrapDamping(double damping)
Sets the wrap damping for this spring.
|
void |
setWrapKnotDensity(double p)
Sets the default knot density for wrapping strands.
|
void |
setWrapKnotDensityMode(PropertyMode mode) |
void |
setWrapStiffness(double stiffness)
Sets the wrap stiffness for this spring.
|
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() |
void |
updateWrapSegments(int maxIter)
Updates the wrap path for all wrappable segments in this spring, using a
secified maximum number of iterations.
|
advanceState, computeDFdl, computeDFdl, computeDFdldot, computeDFdldot, computeF, computeF, createDefaultMaterial, createRenderProps, getAuxVarDerivative, getAuxVarState, getEffectiveMaterial, getForceScaling, getMaterial, getMaxForce, getRenderColor, getRenderHints, getRenderProps, getRestLength, getSelection, getStateVersion, isSelectable, normalizeForceScaling, numAuxVars, numSelectionQueriesNeeded, requiresAdvance, setAuxVarState, 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, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
transformPriority
connectToHierarchy, disconnectFromHierarchy, getName, getNavpanelVisibility, getNumber, getParent, isFixed, isMarked, isSelected, notifyParentOfChange, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable
getProperty
getChildren, hasChildren
isWritable, write
public static boolean myDrawWrapPoints
public int totalStuck
public int totalCalls
public int totalFails
public int totalFalseStuck
public double maxForceNorm
public double sumForceNorm
public double maxLengthErr
public double sumLengthErr
public static PropertyList myProps
public MultiPointSpring()
public MultiPointSpring(java.lang.String name)
name
- name for the springpublic MultiPointSpring(java.lang.String name, double k, double d, double l0)
name
- name for the springk
- stiffness for the axial materiald
- damping for the axial materiall0
- rest length for the axial materialpublic MultiPointSpring(double k, double d, double l0)
k
- stiffness for the axial materiald
- damping for the axial materiall0
- rest length for the axial materialpublic PropertyList getAllPropertyInfo()
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class PointSpringBase
public double getWrapStiffness()
public void setWrapStiffness(double stiffness)
stiffness
- wrap stiffnesspublic double getWrapDamping()
public void setWrapDamping(double damping)
damping
- wrap dampingpublic double getContactStiffness()
public void setContactStiffness(double stiffness)
stiffness
- contact stiffnesspublic double getContactDamping()
public void setContactDamping(double damping)
damping
- contact dampingpublic void setWrapKnotDensity(double p)
p
- desired knot densitypublic double getWrapKnotDensity()
setWrapKnotDensity(double)
for details.public PropertyMode getWrapKnotDensityMode()
public void setWrapKnotDensityMode(PropertyMode mode)
public int getMaxWrapIterations()
public void setMaxWrapIterations(int num)
num
- maximum number of wrap iterationspublic double getMaxWrapDisplacement()
public void setMaxWrapDisplacement(double d)
d
- maximum wrap displacementpublic double getConvergenceTol()
setConvergenceTol(double)
for a description of the tolerance.public void setConvergenceTol(double tol)
tol
for this spring. The default
value is 1.0e-5
. The tolerance specifies the maximum residual
force at each knot as a fraction of the nominal wrapping tension F.
Since F is given by
K l F = --- mwhere
K
is the wrap stiffness, l
is the strand
length, and m
is the number of knots, a maximum residual
of F * tol
at each knot implies a bound on the norm
of the total force vector given by
K l tol || f || < ------- sqrt(m)
tol
- convergence tolerancepublic boolean getLineSearch()
true
if line search is enabledpublic void setLineSearch(boolean enable)
enable
- if true
, enables line searchpublic boolean getDrawKnots()
true
if knot rendering is enabledpublic void setDrawKnots(boolean enable)
enable
- if true
, enables knot renderingpublic boolean getDrawABPoints()
true
if drawing A/B points is enabledpublic void setDrawABPoints(boolean enable)
enable
- if true
, drawing A/B points is enabledpublic java.awt.Color getABPointColor()
public void setABPointColor(java.awt.Color color)
color
- A/B point colorpublic java.awt.Color getContactingKnotsColor()
null
if no such color is specified.null
public void setContactingKnotsColor(java.awt.Color color)
null
removes any special color.color
- color for rendering contacting knots, or null
public double getSor()
public void setSor(double sor)
sor
- successive overrelaxation parameterpublic int getDebugLevel()
public void setDebugLevel(int level)
> 0
causes different
amount of debugging information to be printed.level
- debug levelpublic boolean getProfiling()
true
if profiling is enabledpublic void setProfiling(boolean enabled)
enabled
- if true
, enabled profilingpublic double getDrawDisplacements()
public void setDrawDisplacements(double scale)
public boolean getPrintProfiling()
true
if printing profile timing information is enabledpublic void setPrintProfiling(boolean enabled)
enabled
- if true
, printing profile timing information is
enabledpublic double getProfileTimeUsec()
public int getUpdateContactsCount()
public int getIterationCount()
public int getConvergedCount()
public int getContactCount()
public int getProfileCount()
public void addPoint(int idx, Point pnt)
idx
must not exceed the
current number of points.idx
- index location for the pointpnt
- point to addpublic void addPoint(Point pnt)
pnt
- point to addpublic Point getPoint(int idx)
idx
-th point in this spring.idx
- point indexidx
-th pointpublic int numPoints()
public int indexOfPoint(Point pnt)
pnt
- point whose index is desiredpublic boolean containsPoint(Point pnt)
true
if the spring contains the pointpublic boolean removePoint(Point pnt)
pnt
- point to removetrue
if the point was present in the spring and removedpublic void clearPoints()
public void addWrappable(Wrappable wrappable)
wrappable
- wrappable to addpublic void addWrappable(Wrappable wrappable, int pntIdx0, int pntIdx1)
pntIdx0
and pntIdx1
. pntIdx0
and pntIdx1
are assumed to be non-negative with pntIdx0 <= pntIdx1
; otherwise, the wrappable will be applied to all
segments.
The range indicated by pntIdx0
and pntIdx1
may lie
partly or completely outside the range of actual points. The range will
also remain fixed even if points are subseqently added or removed from
the spring.
wrappable
- wrappable to addpntIdx0
- index of the first point in the wrapping rangepntIdx1
- index of the second point in the wrapping rangepublic boolean containsWrappable(Wrappable wrappable)
wrappable
- wrappable to querytrue
if the wrappable is present in the springpublic boolean containsWrappable(Wrappable wrappable, int pntIdx0, int pntIdx1)
pntIdx0
and pntIdx1
. See addWrappable(Wrappable,int,int)
for a description
of the constraints on pntIdx0
and pntIdx1
.wrappable
- wrappable to querypntIdx0
- index of the first point in the wrapping rangepntIdx1
- index of the second point in the wrapping rangetrue
if the wrappable is present in the springpublic int numWrappables()
public int indexOfWrappable(Wrappable wrappable)
wrappable
- wrappable to locatepublic int indexOfWrappable(Wrappable wrappable, int pntIdx0, int pntIdx1)
pntIdx0
and pntIdx1
. See addWrappable(Wrappable,int,int)
for a description
of the constraints on pntIdx0
and pntIdx1
. If no such
wrappable is present, the method returns -1.wrappable
- wrappable to locatepntIdx0
- index of the first point in the wrapping rangepntIdx1
- index of the second point in the wrapping rangepublic Wrappable getWrappable(int idx)
idx
- index of the wrappableidx
-th wrappable in this springpublic int[] getWrappableRange(int idx)
idx
- index of the wrappablepublic boolean removeWrappable(Wrappable wrappable)
wrappable
- wrappable to removetrue
if the wrappable was presentpublic boolean removeWrappable(Wrappable wrappable, int pntIdx0, int pntIdx1)
pntIdx0
and pntIdx1
. See
addWrappable(Wrappable,int,int)
for a description of the
constraints on pntIdx0
and pntIdx1
.wrappable
- wrappable to removepntIdx0
- index of the first point in the wrapping rangepntIdx1
- index of the second point in the wrapping rangetrue
if the wrappable was presentpublic void clearWrappables()
public MultiPointSpring.SegmentSpec getSegmentSpec(int segIdx)
segIdx
in this spring. This is the
segment that lies between points idx
and idx
+1.segIdx
- index of the segmentidx
-th segmentpublic MultiPointSpring.Segment getSegment(int segIdx)
segIdx
in this spring.segIdx
- index of the segmentidx
-th segmentpublic void setSegmentWrappable(int numk)
numk
- number of knots to be used in the segmentpublic void setSegmentWrappable(int numk, Point3d[] initialPnts)
The initialization points are described by initialPnts
and are
used to specify the wrap path for the segment: the knots are distributed
along the piecewise-linear path defined by the segment end points on each
end and the initialization points in between. The path is then ``pulled
taught'' while wrapping around any intermediate obstacles.
numk
- number of knots to be used in the segmentinitialPnts
- initialization pointspublic void setSegmentWrappable(int segIdx, int numk, Point3d[] initialPnts)
segIdx
to be wrappable, with a
specified number of knots and set of initialization points. See setSegmentWrappable(int,Point3d[])
for a description of how the
initialization points are used.segIdx
- index of the segmentnumk
- number of knots to be used in the segmentinitialPnts
- initialization pointspublic void setAllSegmentsWrappable(int numk)
numk
- number of knots to be used in each segmentpublic boolean clearWrappableSegment(int segIdx)
public void initializeSegment(int segIdx, Point3d[] initialPnts)
segIdx
, using a specified set of initialization points. See setSegmentWrappable(int,Point3d[])
for a description of how the
initialization points are used.segIdx
- index of the segmentinitialPnts
- initialization pointspublic int numSegmentSpecs()
public int numSegments()
public boolean isSegmentPassive(int segIdx)
segIdx
is passive.true
if the segment is passivepublic void setSegmentPassive()
public void setSegmentPassive(int segIdx, boolean passive)
segIdx
is
passive, meaning that its length is not included as part of the
spring's active length.segIdx
- index of the segmentpassive
- if true
, makes the segment passivepublic int numPassiveSegments()
public int numKnots(int segIdx)
segIdx
. Returns 0 if the segment is not wrappable.segIdx
- index of the current segmentpublic MultiPointSpring.WrapKnot getKnot(int segIdx, int k)
k
-th knot in the current segment indexed by segIdx
.segIdx
- index of the current segmentk
- index of the knot within the segmentk
-th knot in segmentpublic void updateWrapSegments(int maxIter)
maxIter
- maximum number of iterationspublic boolean hasWrappableSegments()
public boolean hasConditionalPoints()
public boolean hasMovingMarkers()
public void updateBounds(Vector3d pmin, Vector3d pmax)
updateBounds
in interface IsRenderable
updateBounds
in class PointSpringBase
pmin
- minimum pointpmax
- maximum pointpublic void prerender(RenderList list)
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)
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 scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
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 postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
scan()
method and stored in the token queue.
The most common use of this method is to resolve the paths
of component references, which may not have been created
at the time of the initial scan()
call.postscan
in interface PostScannable
postscan
in class ModelComponentBase
tokens
- token information that was stored during
scan()
.ancestor
- ancestor component with respect to which
reference component paths are defined.java.io.IOException
- if an error is encountered (such as a reference to a
non-existent component)public void scaleDistance(double s)
scaleDistance
in interface ScalableUnits
scaleDistance
in class PointSpringBase
s
- scaling factorpublic void scaleMass(double s)
scaleMass
in interface ScalableUnits
scaleMass
in class PointSpringBase
s
- scaling factorpublic void transformGeometry(AffineTransform3dBase X)
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)
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)
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 boolean isDuplicatable()
false
, since copying of MultiPointSpring is not currently
implemented.isDuplicatable
in interface CopyableComponent
true
if this component can be duplicated.public boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
false
, since copying of MultiPointSpring
is not currently implemented.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)
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)
getHardReferences
in interface ModelComponent
getHardReferences
in class ModelComponentBase
refs
- list to which hard references are appendedpublic void getSoftReferences(java.util.List<ModelComponent> refs)
updateReferences()
method will
be called to update its internal reference information.
Soft references for MultiPointSpring include intermediate points between
the two end points, and the wrappables.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)
undo
equal to false
,
this component should then examine its soft references and
use ComponentUtils.areConnected()
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 double setRestLengthFromPoints()
setRestLengthFromPoints
in class PointSpringBase
public double getActiveLengthDot()
public double getLengthDot()
getLengthDot
in class PointSpringBase
public double getActiveLength()
public double getLength()
getLength
in class PointSpringBase
public void preadvance(double t0, double t1, int flags)
advance()
method, before position and velocity states are
advanced.
For MultiPointSpring, this method updates the spring's structure and wrap
segments when t0
is 0. Otherwise, the method does nothing.
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)
advance()
method, after all position and velocity state has been
advanced.
For MultiPointSpring, this method updates the spring's structure and wrap segments.
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 java.lang.String pathWrapString()
public void updateStructure()
public void updateSlavePos()
updateSlavePos
in interface HasSlaveObjects
public void updateSlaveVel()
updateSlaveVel
in interface HasSlaveObjects
public boolean hasState()
PointSpringBase
hasState
in interface HasNumericState
hasState
in interface ModelComponent
hasState
in class PointSpringBase
true
if this component has statepublic void getState(DataBuffer data)
getState
in interface HasNumericState
getState
in class PointSpringBase
data
- buffer for storing the state values.public void setState(DataBuffer data)
setState
in interface HasNumericState
setState
in class PointSpringBase
data
- buffer containing the state informationpublic void setKnotPositions(int segIdx, Point3d[] plist)
segIdx
. Used for debugging and testing.segIdx
- index of the current segmentplist
- array of knot positionspublic 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 void applyForces(double t)
applyForces
in interface ForceEffector
applyForces
in class Spring
t
- time (seconds)public void addSolveBlocks(SparseNumberedBlockMatrix M)
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)
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)
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()
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 static void main(java.lang.String[] args)