artisynth.core.mechmodels
Class MultiPointSpring

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.mechmodels.Spring
          extended by artisynth.core.mechmodels.PointSpringBase
              extended by artisynth.core.mechmodels.MultiPointSpring
All Implemented Interfaces:
ForceComponent, ForceEffector, RequiresPrePostAdvance, CopyableComponent, ModelComponent, RenderableComponent, ScalableUnits, java.lang.Cloneable, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Scannable
Direct Known Subclasses:
MultiPointMuscle

public class MultiPointSpring
extends PointSpringBase
implements ScalableUnits, CopyableComponent, RequiresPrePostAdvance


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Field Summary
static boolean myIgnoreCoriolisInJacobian
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.mechmodels.PointSpringBase
useMaterial
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface artisynth.core.modelbase.CopyableComponent
COPY_REFERENCES
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
MultiPointSpring()
           
MultiPointSpring(double k, double d, double l)
           
MultiPointSpring(java.lang.String name)
           
MultiPointSpring(java.lang.String name, double k, double d, double l)
           
 
Method Summary
 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 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 applyForces(double t)
          Adds forces to the components affected by this force effector at a particular time.
 void clearPassiveSegments()
           
 void clearPoints()
           
 void computeSegmentForce(Vector3d f, int i, double F)
          Computes the force acting on point i due to the spring segment between i and i+1.
 boolean containsPoint(Point pnt)
           
 ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
          Create a copy of this component.
 double getActiveLength()
           
 double getActiveLengthDot()
           
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
 boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
          Collects external references which must also be copied in order to duplicate this component.
 void getHardReferences(java.util.List<ModelComponent> refs)
          Appends all hard references for this component to a list.
 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.
 double getLength()
           
 double getLengthDot()
           
 Point getPoint(int idx)
           
 int indexOfPoint(Point pnt)
           
 boolean isDuplicatable()
          Returns true if this component can be duplicated.
 boolean isSegmentPassive(int segIdx)
           
 int numPoints()
           
 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 printPointReferences(java.io.PrintWriter pw, CompositeComponent ancestor)
           
 boolean removePoint(Point pnt)
           
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
 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 setPoint(Point pnt, int idx)
           
 double setRestLengthFromPoints()
          Sets the rest length of the spring from the current point locations
 void setSegmentPassive(int segIdx, boolean passive)
           
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 void updateStructure()
          Hook method to allow sub-classes to update their structure by adding or removing points.
 
Methods inherited from class artisynth.core.mechmodels.PointSpringBase
computeDFdl, computeDFdldot, computeF, createDefaultMaterial, createRenderProps, getEffectiveMaterial, getMaterial, getMaxForce, getRenderColor, getRenderHints, getRenderProps, getRestLength, getSelection, isSelectable, numSelectionQueriesNeeded, prerender, setDamping, setLinearMaterial, setMaterial, setMaxForce, setRenderProps, setRestLength, setStiffness
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, hasState, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
connectToHierarchy, disconnectFromHierarchy, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from interface maspack.properties.HasProperties
getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Field Detail

myIgnoreCoriolisInJacobian

public static boolean myIgnoreCoriolisInJacobian

myProps

public static PropertyList myProps
Constructor Detail

MultiPointSpring

public MultiPointSpring()

MultiPointSpring

public MultiPointSpring(java.lang.String name)

MultiPointSpring

public MultiPointSpring(java.lang.String name,
                        double k,
                        double d,
                        double l)

MultiPointSpring

public MultiPointSpring(double k,
                        double d,
                        double l)
Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class PointSpringBase
Returns:
static information for all exported properties

getPoint

public Point getPoint(int idx)

numPoints

public int numPoints()

containsPoint

public boolean containsPoint(Point pnt)

addPoint

public void addPoint(int idx,
                     Point pnt)

addPoint

public void addPoint(Point pnt)

indexOfPoint

public int indexOfPoint(Point pnt)

removePoint

public boolean removePoint(Point pnt)

setRestLengthFromPoints

public double setRestLengthFromPoints()
Sets the rest length of the spring from the current point locations

Specified by:
setRestLengthFromPoints in class PointSpringBase
Returns:
the new rest length

clearPoints

public void clearPoints()

setPoint

public void setPoint(Point pnt,
                     int idx)

clearPassiveSegments

public void clearPassiveSegments()

setSegmentPassive

public void setSegmentPassive(int segIdx,
                              boolean passive)

isSegmentPassive

public boolean isSegmentPassive(int segIdx)

computeSegmentForce

public void computeSegmentForce(Vector3d f,
                                int i,
                                double F)
Computes the force acting on point i due to the spring segment between i and i+1.

Parameters:
f - computed force acting between i and i+1
i - index of the point in the segment
F - scalar force in the entire spring

applyForces

public void applyForces(double t)
Description copied from interface: ForceEffector
Adds forces to the components affected by this force effector at a particular time. Component forces should be added and not set, since other forces may be added to the same components by other force effectors.

Specified by:
applyForces in interface ForceEffector
Specified by:
applyForces in class Spring
Parameters:
t - time (seconds)

printPointReferences

public void printPointReferences(java.io.PrintWriter pw,
                                 CompositeComponent ancestor)
                          throws java.io.IOException
Throws:
java.io.IOException

scan

public void scan(ReaderTokenizer rtok,
                 java.lang.Object ref)
          throws java.io.IOException
Description copied from class: ModelComponentBase
Scans this element from a ReaderTokenizer. The expected text format is assumed to be compatible with that produced by write.

Specified by:
scan in interface ModelComponent
Specified by:
scan in interface Scannable
Overrides:
scan in class ModelComponentBase
Parameters:
rtok - Tokenizer from which to scan the element
ref - optional reference object which can be used for resolving references to other objects
Throws:
java.io.IOException - if an I/O or formatting error occured

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
Specified by:
updateBounds in class PointSpringBase
Parameters:
pmin - minimum point
pmax - maximum point

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
Specified by:
render in class PointSpringBase
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.

scaleDistance

public void scaleDistance(double s)
Description copied from interface: ScalableUnits
Scales all distance coordinates.

Specified by:
scaleDistance in interface ScalableUnits
Overrides:
scaleDistance in class PointSpringBase
Parameters:
s - scaling factor

scaleMass

public void scaleMass(double s)
Description copied from interface: ScalableUnits
Scales all mass units.

Specified by:
scaleMass in interface ScalableUnits
Overrides:
scaleMass in class PointSpringBase
Parameters:
s - scaling factor

getLength

public double getLength()
Specified by:
getLength in class PointSpringBase

getLengthDot

public double getLengthDot()

getActiveLength

public double getActiveLength()

getActiveLengthDot

public double getActiveLengthDot()

addSolveBlocks

public void addSolveBlocks(SparseNumberedBlockMatrix M)
Description copied from interface: ForceEffector
Adds any needed blocks to a solve matrix in order to accomodate the Jacobian terms associated with this force effector. In general, blocks will be need to be added at locations given by the block indices (bi, bj), where bi and bj correspond to the solve indices (as returned by getSolveIndex) for all dynamic or attached components affected by this force effector.

Specified by:
addSolveBlocks in interface ForceEffector
Parameters:
M - solve matrix to which blocks should be added

addPosJacobian

public void addPosJacobian(SparseNumberedBlockMatrix M,
                           double s)
Description copied from interface: ForceEffector
Scales the components of the position Jacobian associated with this force effector and adds it to the supplied solve matrix M.

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.

Specified by:
addPosJacobian in interface ForceEffector
Parameters:
M - solve matrix to which scaled position Jacobian is to be added
s - scaling factor for position Jacobian

addVelJacobian

public void addVelJacobian(SparseNumberedBlockMatrix M,
                           double s)
Description copied from interface: ForceEffector
Scales the components of the velocity Jacobian associated with this force effector and adds it to the supplied solve matrix M.

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.

Specified by:
addVelJacobian in interface ForceEffector
Parameters:
M - solve matrix to which scaled velocity Jacobian is to be added
s - scaling factor for velocity Jacobian

getJacobianType

public int getJacobianType()
Description copied from interface: ForceEffector
Returns a code indicating the matrix type that results when the Jacobian terms of this force effector are added to the solve matrix. This should be a logical or-ing of either 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.

Specified by:
getJacobianType in interface ForceEffector
Returns:
solve matrix type resulting from adding Jacobian terms

isDuplicatable

public boolean isDuplicatable()
Returns true if this component can be duplicated. Duplication means that we can expect to be able to make a complete copy of the component along with all it's external references. This method should return true if and only if CopyableComponent.getCopyReferences(java.util.List, 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) to build the list of copy references.

Specified by:
isDuplicatable in interface CopyableComponent
Returns:
true if this component can be duplicated.

getCopyReferences

public boolean getCopyReferences(java.util.List<ModelComponent> refs,
                                 ModelComponent ancestor)
Collects external references which must also be copied in order to duplicate this component. These references should exclude those which are contained within a specified component hierarchy. This method should return true if and only if CopyableComponent.isDuplicatable() returns true.

Specified by:
getCopyReferences in interface CopyableComponent
Parameters:
refs - list to which references are appended
ancestor - root node of the hierarchy from which references are to be excluded
Returns:
false if it is discovered that the component cannot be duplicated

copy

public ModelComponent copy(int flags,
                           java.util.Map<ModelComponent,ModelComponent> copyMap)
Description copied from interface: CopyableComponent
Create a copy of this component. If 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.

Specified by:
copy in interface CopyableComponent
Overrides:
copy in class PointSpringBase

getHardReferences

public void getHardReferences(java.util.List<ModelComponent> refs)
Description copied from class: ModelComponentBase
Appends all hard references for this component to a list. References are other components, outside of this component's immediate ancestry, on which this component depends. For example, an AxialSpring refers to two Point components as for it's end points. A hard reference is one which the referring component must have, and which if deleted, implies that the referring component should be deleted too.

Specified by:
getHardReferences in interface ModelComponent
Overrides:
getHardReferences in class ModelComponentBase
Parameters:
refs - list to which hard references are appended

preadvance

public void preadvance(double t0,
                       double t1,
                       int flags)
Description copied from interface: RequiresPrePostAdvance
Called from within the model's preadvance() method.

Specified by:
preadvance in interface RequiresPrePostAdvance
Parameters:
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).

postadvance

public void postadvance(double t0,
                        double t1,
                        int flags)
Description copied from interface: RequiresPrePostAdvance
Called from within the model's advance() method, after all position and velocity state has been advanced.

Specified by:
postadvance in interface RequiresPrePostAdvance
Parameters:
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).

updateStructure

public void updateStructure()
Hook method to allow sub-classes to update their structure by adding or removing points.