public class FrameSpring extends Spring implements RenderableComponent, ScalableUnits, TransformableGeometry, CopyableComponent, ForceTargetComponent, HasNumericState
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static PropertyList |
myProps |
static boolean |
mySymmetricJacobian |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
COPY_REFERENCES, REST_POSITION
Constructor and Description |
---|
FrameSpring() |
FrameSpring(java.lang.String name) |
FrameSpring(java.lang.String name,
double k,
double kRot,
double d,
double dRot) |
FrameSpring(java.lang.String name,
FrameMaterial mat) |
Modifier and Type | Method and Description |
---|---|
int |
addForcePosJacobian(SparseBlockMatrix J,
double h,
boolean staticOnly,
int bi)
Add a row to the force Jacobian for this force target component.
|
int |
addForceVelJacobian(SparseBlockMatrix J,
double h,
int bi) |
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 |
addPosJacobianWorld(SparseNumberedBlockMatrix M,
double s) |
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 |
addVelJacobianWorld(SparseNumberedBlockMatrix M,
double s) |
void |
advanceState(double t0,
double t1)
If
HasNumericState.requiresAdvance() and HasNumericState.hasState() both return true , then this method is called each time step by the system integrator
to update this component's state. |
void |
applyForces(double t)
Adds forces to the components affected by this force effector at a
particular time.
|
void |
computeVelJacobianWorld(FrameMaterial mat,
double sd,
Matrix6d blk00,
Matrix6d blk01,
Matrix6d blk10,
Matrix6d blk11) |
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Create a copy of this component.
|
static FrameMaterial |
createDefaultMaterial() |
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
RigidTransform3d |
getAttachFrameA() |
RigidTransform3d |
getAttachFrameB() |
int |
getAuxVarDerivative(double[] buf,
int idx)
If this component has auxiliary variables, returns the current values of
their derivatives in
buf , starting at the location idx . |
int |
getAuxVarState(double[] buf,
int idx)
If this component has auxiliary variables, returns their values in
buf , starting at the location idx . |
double |
getAxisLength() |
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Collects external references which must also be copied in order to
duplicate this component.
|
RigidTransform3d |
getCurrentTCW()
Returns the current pose of the C frame, in world coordinates.
|
void |
getCurrentTCW(RigidTransform3d TCW)
Returns the current pose of the C frame, in world coordinates.
|
RigidTransform3d |
getCurrentTDW()
Returns the current pose of the D frame, in world coordinates.
|
void |
getCurrentTDW(RigidTransform3d TDW)
Returns the current pose of the D frame, in world coordinates.
|
boolean |
getDrawFrameC() |
boolean |
getDrawFrameD() |
void |
getForce(VectorNd minf,
boolean staticOnly) |
int |
getForceSize() |
Frame |
getFrameA() |
Frame |
getFrameB() |
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
RigidTransform3d |
getInitialT21()
Deprecated.
Use
getTDC0 instead. |
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.
|
FrameMaterial |
getMaterial() |
int |
getRenderHints()
Returns a bit code giving rendering hints about this renderable.
|
RenderProps |
getRenderProps()
Returns the render properities for this object.
|
void |
getSelection(java.util.LinkedList<java.lang.Object> list,
int qid)
Append to
list the component (or components) associated with
the qid -th selection query issued by this component's render
method. |
Wrench |
getSpringForce() |
void |
getState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
int |
getStateVersion()
Returns a version number for this component's state.
|
RigidTransform3d |
getTDC0()
Returns the TDC transform "rest" position.
|
boolean |
hasState()
Queries if this component has state.
|
void |
initializeTDC0()
Initializes the TDC transform "rest" position to correspond to the
current locations of the C and D frames.
|
boolean |
isDuplicatable()
Returns true if this component can be duplicated.
|
boolean |
isJacobianSymmetric() |
boolean |
isSelectable()
Returns true if this object is in fact selectable.
|
int |
numAuxVars()
Returns the number of auxiliary variables associated with this
component, or 0 if there are no auxiliary variables.
|
int |
numSelectionQueriesNeeded()
If this selectable manages its own selection (by issuing selection
queries within its
render method), then this method should
return the maximum number of selection queries that will be
required. |
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 |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
boolean |
requiresAdvance()
Returns
true if the state of this component must be
updated each time step using HasNumericState.advanceState(double, double) . |
void |
scaleDistance(double s)
Scales all distance coordinates.
|
void |
scaleMass(double s)
Scales all mass units.
|
void |
setAttachFrameA(RigidTransform3d X1A) |
void |
setAttachFrameB(RigidTransform3d X2B) |
int |
setAuxVarState(double[] buf,
int idx)
If this component has auxiliary variables, sets them from the values in
buf , starting at the location idx . |
void |
setAxisLength(double len) |
void |
setDrawFrameC(boolean draw) |
void |
setDrawFrameD(boolean draw) |
void |
setFrameA(Frame frame) |
void |
setFrameB(Frame frame) |
void |
setFrames(Frame frameA,
Frame frameB,
RigidTransform3d TDW) |
void |
setFrames(Frame frameA,
RigidTransform3d T1A,
Frame frameB,
RigidTransform3d T2B) |
void |
setInitialT21()
Deprecated.
Use
initializeTDC0 instead. |
void |
setInitialT21(RigidTransform3d X21)
Deprecated.
Use
setTDC0 instead. |
void |
setJacobianSymmetric(boolean symmetric) |
<T extends FrameMaterial> |
setMaterial(T mat) |
void |
setRenderProps(RenderProps props)
Assigns a new set of render properties to this object.
|
void |
setRotaryStiffness(double k) |
void |
setState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
void |
setTDC0(RigidTransform3d TDC0)
Sets the value of the TDC transform "rest" position.
|
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. |
int |
transformPriority()
Returns an index used for ordering this component within a set of
components to which
transformGeometry() will be
applied. |
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, 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
connectToHierarchy, disconnectFromHierarchy, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
public static boolean mySymmetricJacobian
public static PropertyList myProps
public FrameSpring()
public FrameSpring(java.lang.String name)
public FrameSpring(java.lang.String name, double k, double kRot, double d, double dRot)
public FrameSpring(java.lang.String name, FrameMaterial mat)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ModelComponentBase
public double getAxisLength()
public void setAxisLength(double len)
public boolean getDrawFrameD()
public void setDrawFrameD(boolean draw)
public void setDrawFrameC(boolean draw)
public boolean getDrawFrameC()
public void setInitialT21(RigidTransform3d X21)
setTDC0
instead.public void setInitialT21()
initializeTDC0
instead.public RigidTransform3d getInitialT21()
getTDC0
instead.public void setTDC0(RigidTransform3d TDC0)
TDC0
- new transform valuepublic RigidTransform3d getTDC0()
public void initializeTDC0()
public RenderProps getRenderProps()
HasRenderProps
getRenderProps
in interface HasRenderProps
public void setRenderProps(RenderProps props)
HasRenderProps
null
will remove render properties from this object.setRenderProps
in interface HasRenderProps
props
- new render properties for this objectpublic RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
public void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
list
- list of objects to be renderedpublic void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
pmin
- minimum pointpmax
- maximum pointpublic int getRenderHints()
IsRenderable
TRANSPARENT
and
TWO_DIMENSIONAL
.getRenderHints
in interface IsRenderable
public boolean isSelectable()
IsSelectable
isSelectable
in interface IsSelectable
public int numSelectionQueriesNeeded()
IsSelectable
render
method), then this method should
return the maximum number of selection queries that will be
required. Otherwise, this method should return -1.numSelectionQueriesNeeded
in interface IsSelectable
public void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
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 getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
IsSelectable
list
the component (or components) associated with
the qid
-th selection query issued by this component's render
method. This will only be called if this component manages its own
selection (i.e., the number nums
returned by IsSelectable.numSelectionQueriesNeeded()
is positive), and qid
will in
turn be a number between 0 and nums
-1.getSelection
in interface IsSelectable
list
- selected objects are appended to the end of this listqid
- index of the selection querypublic static FrameMaterial createDefaultMaterial()
public FrameMaterial getMaterial()
public <T extends FrameMaterial> void setMaterial(T mat)
public void setRotaryStiffness(double k)
public void setFrameA(Frame frame)
public Frame getFrameA()
public void setFrameB(Frame frame)
public Frame getFrameB()
public void setAttachFrameA(RigidTransform3d X1A)
public RigidTransform3d getAttachFrameA()
public RigidTransform3d getCurrentTCW()
public void getCurrentTCW(RigidTransform3d TCW)
TCW
- returns the current pose of Cpublic void setAttachFrameB(RigidTransform3d X2B)
public RigidTransform3d getAttachFrameB()
public RigidTransform3d getCurrentTDW()
public void getCurrentTDW(RigidTransform3d TDW)
TDW
- returns the current pose of Dpublic void setFrames(Frame frameA, Frame frameB, RigidTransform3d TDW)
public void setFrames(Frame frameA, RigidTransform3d T1A, Frame frameB, RigidTransform3d T2B)
public Wrench getSpringForce()
public void applyForces(double t)
ForceEffector
applyForces
in interface ForceEffector
applyForces
in class Spring
t
- time (seconds)public 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 addPosJacobianWorld(SparseNumberedBlockMatrix M, double s)
public 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 void addVelJacobianWorld(SparseNumberedBlockMatrix M, double s)
public void computeVelJacobianWorld(FrameMaterial mat, double sd, Matrix6d blk00, Matrix6d blk01, Matrix6d blk10, Matrix6d blk11)
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 int getForceSize()
getForceSize
in interface ForceTargetComponent
public void getForce(VectorNd minf, boolean staticOnly)
getForce
in interface ForceTargetComponent
public int addForcePosJacobian(SparseBlockMatrix J, double h, boolean staticOnly, int bi)
ForceTargetComponent
fm = J u
addForcePosJacobian
in interface ForceTargetComponent
J
- force Jacobianh
- current time stepstaticOnly
- use only static forcesbi
- block row index for the row to be addedpublic int addForceVelJacobian(SparseBlockMatrix J, double h, int bi)
addForceVelJacobian
in interface ForceTargetComponent
public int transformPriority()
TransformableGeometry
transformGeometry()
will be
applied. Components with higher values will be transformed before those
with lower values.transformPriority
in interface TransformableGeometry
public void transformGeometry(AffineTransform3dBase X)
TransformableGeometry
TransformGeometryContext.transform (this, X, 0);
transformGeometry
in interface TransformableGeometry
X
- affine transformation to apply to the componentpublic 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 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 scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
s
- scaling factorpublic void setJacobianSymmetric(boolean symmetric)
public boolean isJacobianSymmetric()
public 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 void getHardReferences(java.util.List<ModelComponent> refs)
ModelComponentBase
getHardReferences
in interface ModelComponent
getHardReferences
in class ModelComponentBase
refs
- list to which hard references are appendedpublic 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 hasState()
hasState
in interface HasNumericState
hasState
in interface ModelComponent
hasState
in class ModelComponentBase
true
if this component has statepublic int getStateVersion()
getStateVersion
in interface HasNumericState
public void getState(DataBuffer data)
getState
in interface HasNumericState
data
- buffer for storing the state values.public void setState(DataBuffer data)
setState
in interface HasNumericState
data
- buffer containing the state informationpublic boolean requiresAdvance()
true
if the state of this component must be
updated each time step using HasNumericState.advanceState(double, double)
.requiresAdvance
in interface HasNumericState
true
if advanceState
must be calledpublic void advanceState(double t0, double t1)
HasNumericState.requiresAdvance()
and HasNumericState.hasState()
both return true
, then this method is called each time step by the system integrator
to update this component's state. For single step integrators, the method
is called once at the start of the integration, with t0
and
t1
set to the step's start and end times. For multi-step
integrators (such as Runge Kutta), the method is called for each
sub-step, with t0
and t1
set to the sub-step's time
bounds. Multi-step integrators will also use HasNumericState.getState(maspack.util.DataBuffer)
and
HasNumericState.setState(maspack.util.DataBuffer)
to save and restore state as required.advanceState
in interface HasNumericState
t0
- beginning time associated with the time step or sub-stept1
- end time associated with the time step or sub-steppublic int numAuxVars()
If HasNumericState.hasState()
returns true
and the component has
auxiliary variables, the variables are updated each time step by the
system integrator using explcit integration of the form
w += h dwdtwhere
h
is a time increment, w
is a vector of variables
accessed using HasNumericState.getAuxVarState(double[], int)
and HasNumericState.setAuxVarState(double[], int)
, and
dwdt
is a time derivative obtained using HasNumericState.getAuxVarDerivative(double[], int)
. For single step integrators, this will be done
once at the start of the integration, with h
set to the time step
size. For multi-step integrators (such as Runge Kutta), this will be done
at the start of each sub-step, with h
set to the sub-step size.
If present, auxiliary variables are also assumed to be contained
within the state accessed using HasNumericState.getState(maspack.util.DataBuffer)
and HasNumericState.setState(maspack.util.DataBuffer)
.
numAuxVars
in interface HasNumericState
public int getAuxVarState(double[] buf, int idx)
buf
, starting at the location idx
. See HasNumericState.numAuxVars()
for
a description of auxiliary variables. The method returns idx +
num
, where num
is the number of variables.getAuxVarState
in interface HasNumericState
buf
- returns the variable valuesidx
- starting point within buf
idx
plus the number of variablespublic int setAuxVarState(double[] buf, int idx)
buf
, starting at the location idx
. See HasNumericState.numAuxVars()
for a description of auxiliary variables. The method
returns idx + num
, where num
is the number of variables.setAuxVarState
in interface HasNumericState
buf
- contains the new variable valuesidx
- starting point within buf
idx
plus the number of variablespublic int getAuxVarDerivative(double[] buf, int idx)
buf
, starting at the location idx
.
See HasNumericState.numAuxVars()
for a description of auxiliary variables. The
method returns idx + num
, where num
is the number of
variables.getAuxVarDerivative
in interface HasNumericState
buf
- returns the variable derivative valuesidx
- starting point within buf
idx
plus the number of variablespublic 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 ModelComponentBase
flags
- flags to control the copyingcopyMap
- map to possible existing instances of referenced
components