public class RigidBody extends Frame implements CollidableBody, HasSurfaceMesh, ConnectableBody, CompositeComponent, Wrappable
Modifier and Type | Class and Description |
---|---|
static class |
RigidBody.InertiaMethod |
Collidable.Collidability, Collidable.Group
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_SUBMESHES_SELECTABLE |
static PropertyList |
myProps |
dynamicVelInWorldCoords, myRenderFrame
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
All, AllBodies, Deformable, Rigid, Self
COPY_REFERENCES, REST_POSITION
TG_ARTICULATED, TG_DRAGGER, TG_PRESERVE_ORIENTATION, TG_SIMULATING
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
RigidBody() |
RigidBody(RigidTransform3d XBodyToWorld,
SpatialInertia M,
PolygonalMesh mesh,
java.lang.String meshFileName) |
RigidBody(java.lang.String name) |
RigidBody(java.lang.String name,
PolygonalMesh mesh,
java.lang.String meshFilePath,
double density,
double scale) |
Modifier and Type | Method and Description |
---|---|
void |
add(ModelComponent comp) |
void |
addConnector(BodyConnector c) |
void |
addEffectiveFrameMass(SpatialInertia M,
RigidTransform3d TFL)
Adds a frame inertia to the effective spatial inertia for this Frame.
|
void |
addEffectivePointMass(double m,
Vector3d loc)
Adds a point mass to the effective spatial inertia for this Frame.
|
RigidMeshComp |
addMesh(MeshBase mesh)
Adds a mesh to this object.
|
RigidMeshComp |
addMesh(MeshBase mesh,
boolean hasMass,
boolean collidable)
Adds a mesh to this object.
|
RigidMeshComp |
addMesh(MeshBase mesh,
java.lang.String fileName,
AffineTransform3dBase Xh,
boolean hasMass,
boolean collidable)
Adds a mesh to this object
|
void |
addMeshComp(RigidMeshComp mc)
Explicitly adds a mesh component.
|
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 S,
double s)
Scales the components of the velocity Jacobian associated with this force
effector and adds it to the supplied solve matrix M.
|
boolean |
allowCollision(ContactPoint cpnt,
Collidable other,
java.util.Set<Vertex3d> attachedVertices)
Returns
true if a collision between this Collidable
and other should be allowed for the contact point
cpnt . |
void |
applyForces(double t)
Adds forces to the components affected by this force effector at a
particular time.
|
void |
applyGravity(Vector3d gacc)
Applies a gravity force to this component, given a prescribed
gravity acceleration vector.
|
Point3d |
centerPoseOnCenterOfMass()
Adjusts the pose so that it reflects the rigid body's center of mass.
|
void |
clearMeshComps() |
void |
collectVertexMasters(java.util.List<ContactMaster> mlist,
Vertex3d vtx)
Collects the contact masters for a particular mesh vertex.
|
void |
componentChanged(ComponentChangeEvent e)
Notifies this composite component that a change has occured within one or
more of its descendants.
|
boolean |
containsConnector(BodyConnector c) |
boolean |
containsContactMaster(CollidableDynamicComponent comp)
Returns true if this Collidable contains a specified contact master
component.
|
boolean |
containsMeshComp(RigidMeshComp mc)
Checks if this object contains a particular geometry
|
RigidBody |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap)
Create a copy of this component.
|
static RigidBody |
createBox(java.lang.String bodyName,
double wx,
double wy,
double wz,
double density)
Creates a box-shaped RigidBody with a prescribed uniform density.
|
static RigidBody |
createBox(java.lang.String bodyName,
double wx,
double wy,
double wz,
double density,
boolean addNormals)
Creates a box-shaped RigidBody with a prescribed uniform density.
|
static RigidBody |
createBox(java.lang.String bodyName,
double wx,
double wy,
double wz,
int nx,
int ny,
int nz,
double density,
boolean addNormals)
Creates a box-shaped RigidBody with a prescribed uniform density.
|
static RigidBody |
createCylinder(java.lang.String bodyName,
double r,
double h,
double density,
int nsides)
Creates a cylindrical RigidBody with a prescribed uniform density.
|
static RigidBody |
createEllipsoid(java.lang.String bodyName,
double a,
double b,
double c,
double density,
int nslices)
Creates an ellipsoidal RigidBody with a prescribed uniform density.
|
static RigidBody |
createFromMesh(java.lang.String bodyName,
java.lang.Object obj,
java.lang.String relPath,
double density,
double scale) |
static RigidBody |
createFromMesh(java.lang.String bodyName,
PolygonalMesh mesh,
double density,
double scale) |
static RigidBody |
createFromMesh(java.lang.String bodyName,
PolygonalMesh mesh,
java.lang.String meshFilePath,
double density,
double scale) |
static RigidBody |
createFromMesh(java.lang.String bodyName,
java.lang.String meshPath,
double density,
double scale) |
static RigidBody |
createIcosahedralSphere(java.lang.String bodyName,
double r,
double density,
int ndivisions)
Creates an icosahedrally spherical RigidBody with a prescribed uniform
density.
|
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
static RigidBody |
createSphere(java.lang.String bodyName,
double r,
double density,
int nslices)
Creates an spherical RigidBody with a prescribed uniform density.
|
void |
extrapolatePose(Twist vel,
double h) |
ModelComponent |
findComponent(java.lang.String path)
Recursively searches for a subcomponent of this ModelComponent,
identified by a path of component names.
|
ModelComponent |
get(int idx)
Returns a specific subcomponent of this ModelComponent, identified by
index.
|
ModelComponent |
get(java.lang.String nameOrNumber)
Returns a specific subcomponent of this ModelComponent, identified by
name or string representation of the subcomponent's number
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
ModelComponent |
getByNumber(int num)
Returns a specific subcomponent of this ModelComponent, identified by
number.
|
Point3d |
getCenterOfMass() |
void |
getCenterOfMass(Point3d com) |
double |
getCharacteristicRadius()
Returns a typical "radius" that should be expected for this wrappable,
defined as the distance for a surface point to the center.
|
java.util.Iterator<? extends HierarchyNode> |
getChildren() |
Collidable.Collidability |
getCollidable()
Returns the
Collidable.Collidability of this Collidable. |
Collidable |
getCollidableAncestor()
Returns the most immediate Collidable ancestor of this Collidable,
if any.
|
int |
getCollidableIndex() |
PolygonalMesh |
getCollisionMesh()
Returns the mesh that should be used for computing collisions, or
null if there is no such mesh. |
java.util.List<BodyConnector> |
getConnectors() |
boolean |
getCopyReferences(java.util.List<ModelComponent> refs,
ModelComponent ancestor)
Collects external references which must also be copied in order to
duplicate this component.
|
double |
getDensity()
Returns the density of this body.
|
Range |
getDensityRange() |
DistanceGrid |
getDistanceGrid()
Returns a signed distance grid that can be used with a
SignedDistanceCollider, or
null if a grid is not available. |
DistanceGridComp |
getDistanceGridComp()
Returns a
DistanceGridComp object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid() returns false ). |
Vector3i |
getDistanceGridRes()
Convenience method to call
DistanceGridComp.getResolution()
for this body's distance grid. |
SpatialInertia |
getEffectiveInertia() |
double |
getEffectiveMass()
Gets the effective scalar mass of this component.
|
void |
getEffectiveMass(Matrix M,
double t)
Gets the effective mass of this component at a particular time.
|
static int |
getEffectiveMassForces(VectorNd f,
double t,
FrameState state,
SpatialInertia effectiveInertia,
int idx) |
int |
getEffectiveMassForces(VectorNd f,
double t,
int idx)
Gets the mass forces for this component at a particular time.
|
FrameMarker[] |
getFrameMarkers()
Returns an array of all FrameMarkers currently associated with this rigid
body.
|
boolean |
getGridSurfaceRendering()
Queries if grid surface rendering is enabled.
|
void |
getInertia(SpatialInertia M) |
double |
getInertialDamping() |
PropertyMode |
getInertialDampingMode() |
RigidBody.InertiaMethod |
getInertiaMethod() |
void |
getInverseMass(Matrix Minv,
Matrix M)
Inverts a mass for this component.
|
double |
getMass()
Returns the mass of this body.
|
double |
getMass(double t)
Returns the scalar mass of this component at time t.
|
void |
getMass(Matrix M,
double t)
Gets the mass of this component at a particular time.
|
Range |
getMassRange() |
PolygonalMesh |
getMesh()
Deprecated.
Use
getSurfaceMesh() instead. |
RigidMeshComp |
getMeshComp(int idx) |
RigidMeshComp |
getMeshComp(java.lang.String name) |
MeshComponentList<RigidMeshComp> |
getMeshComps() |
CompositeComponent.NavpanelDisplay |
getNavpanelDisplay()
Returns the DisplayMode for this component.
|
int |
getNumberLimit()
Returns the current upper limit for numbers among all subcomponents in
this composite.
|
SymmetricMatrix3d |
getRotationalInertia()
Returns the rotational inertia of this body.
|
void |
getRotationalInertia(SymmetricMatrix3d J) |
boolean |
getSubmeshesSelectable() |
PolygonalMesh |
getSurfaceMesh()
Returns the surface mesh for this rigid body.
|
RigidMeshComp |
getSurfaceMeshComp()
Returns the mesh component, if any, associated with the surface
mesh for this body.
|
PolygonalMesh[] |
getSurfaceMeshes()
Returns an array listing all the (non-null) surface meshes associated
with this component, or a zero-length array if there are none.
|
double |
getVolume() |
boolean |
hasChildren() |
boolean |
hasDistanceGrid()
Returns
true if this RigidBody supports a signed
distance grid that can be used with a SignedDistanceCollider. |
boolean |
hasForce()
Queries whether or not this component actually exerts its own
state-dependent forces (typically associated with damping).
|
boolean |
hasInvariantMasters()
Queries whether or not the contact masters for a particular collision
point are invariant across all contacts.
|
boolean |
hierarchyContainsReferences()
Returns true if the component hierarchy formed by this component and its
descendents is closed with respect to references.
|
int |
indexOf(ModelComponent comp)
Returns the index of a specified subcomponent, or -1 if that the
component is not present.
|
boolean |
isCompound()
Queries whether or not this collidable has sub-collidables.
|
boolean |
isDeformable()
Returns
true if this collidable is deformable. |
boolean |
isDuplicatable()
Returns true if this component can be duplicated.
|
boolean |
isFreeBody() |
boolean |
isMassConstant() |
int |
mulInverseEffectiveMass(Matrix M,
double[] a,
double[] f,
int idx) |
static int |
mulInverseEffectiveMass(SpatialInertia S,
double[] a,
double[] f,
int idx) |
int |
numComponents()
Returns the number of components in this CompositeComponent.
|
int |
numMeshComps()
Number of meshes associated with this object
|
int |
numSurfaceMeshes()
Returns the number of surfaces meshes associated with this
component, or 0 if no meshes exist.
|
double |
penetrationDistance(Vector3d nrm,
Matrix3d Dnrm,
Point3d p0)
Computes the penetration distance of a point
p0 into this
Wrappable, along with the normal nrm that points from
p0 to its nearest point on the surface. |
void |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
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 |
remove(ModelComponent comp) |
void |
removeConnector(BodyConnector c) |
boolean |
removeMeshComp(RigidMeshComp mc) |
RigidMeshComp |
removeMeshComp(java.lang.String name) |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
void |
resetEffectiveMass()
Resets the effective mass of this component to the nominal mass.
|
void |
scaleDistance(double s)
Scales all distance coordinates.
|
void |
scaleMass(double s)
Scales all mass units.
|
void |
scaleSurfaceMesh(double sx,
double sy,
double sz) |
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setCenterOfMass(Point3d com) |
void |
setCollidable(Collidable.Collidability c) |
void |
setCollidableIndex(int idx) |
void |
setDensity(double density)
Sets the density for the mesh, which is defined at the mass divided
by the mesh volume.
|
void |
setDisplayMode(CompositeComponent.NavpanelDisplay mode)
Sets the display mode for this component.
|
void |
setDistanceGridRes(Vector3i res)
Convenience method to call
DistanceGridComp.setResolution(maspack.matrix.Vector3i)
for this body's distance grid. |
void |
setDynamic(boolean dynamic) |
void |
setGridSurfaceRendering(boolean enable)
Enables or disables grid surface rendering.
|
void |
setInertia(double m,
double Jxx,
double Jyy,
double Jzz)
Explicitly sets the mass and rotational inertia of this body.
|
void |
setInertia(double m,
SymmetricMatrix3d J)
Explicitly sets the mass and rotational inertia of this body.
|
void |
setInertia(double m,
SymmetricMatrix3d J,
Point3d com)
Explicitly sets the mass, rotational inertia, and center of mass of this
body.
|
void |
setInertia(SpatialInertia M)
Explicitly sets the spatial inertia of this body.
|
void |
setInertiaFromDensity(double density)
Causes the inertia to be automatically computed from the mesh volume
and a given density.
|
void |
setInertiaFromMass(double mass)
Causes the inertia to be automatically computed from the mesh volume
and a given mass (with the density computed by dividing the mass
by the mesh volume).
|
void |
setInertialDamping(double d) |
void |
setInertialDampingMode(PropertyMode mode) |
void |
setInertiaMethod(RigidBody.InertiaMethod method)
Sets the
InertiaMethod method used to
determine the inertia for this RigidBody. |
void |
setMass(double mass)
Sets the mass for the mesh.
|
void |
setMesh(PolygonalMesh mesh)
Deprecated.
Use
setSurfaceMesh(PolygonalMesh) instead. |
void |
setMesh(PolygonalMesh mesh,
java.lang.String fileName)
Deprecated.
Use
setSurfaceMesh(PolygonalMesh,String) instead. |
void |
setMesh(PolygonalMesh mesh,
java.lang.String fileName,
AffineTransform3dBase X)
Deprecated.
|
void |
setPose(double x,
double y,
double z,
double roll,
double pitch,
double yaw) |
int |
setPosState(double[] buf,
int idx)
Replace updatePosState() with updateSlavePosStates() so we don't update
attachments when doing general state uodates.
|
void |
setRotationalInertia(SymmetricMatrix3d J)
Explicitly sets the rotational inertia of this body.
|
void |
setSubmeshesSelectable(boolean value) |
void |
setSurfaceMesh(PolygonalMesh mesh)
Sets the surface mesh for this body.
|
void |
setSurfaceMesh(PolygonalMesh mesh,
java.lang.String fileName)
Sets the surface mesh for this body.
|
void |
setSurfaceMesh(PolygonalMesh mesh,
java.lang.String fileName,
AffineTransform3dBase X)
Sets the surface mesh for this body.
|
void |
subEffectiveInertia(SpatialInertia M) |
void |
surfaceTangent(Point3d pr,
Point3d pa,
Point3d p1,
double lam0,
Vector3d sideNrm)
Computes the point
pt on the surface of this Wrappable such
that the line segment (pa,pt) is both tangent to the surface and as near
as possible to the line defined by the two points pa and p1. |
void |
transformCoordinateFrame(RigidTransform3d TNB)
Transform the body coordinate frame.
|
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 |
translateCoordinateFrame(Point3d off)
Shifts the coordinate frame by a specified offset.
|
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
void |
updateNameMap(java.lang.String newName,
java.lang.String oldName,
ModelComponent comp) |
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter.
|
add1DConstraintBlocks, add2DConstraintBlocks, addExternalForce, addForce, addForce, addFrameForce, addPointForce, addPointForce, addPosImpulse, addPosJacobian, addRelativeVelocity, addScaledExternalForce, addSolveBlock, addSolveBlocks, addTargetJacobian, addToPointVelocity, applyExternalForces, collectMasterComponents, computeAppliedWrench, computeForceOnMasters, computeFrameLocation, computeFramePosition, computeFramePosVel, computeFrameVelocity, computePointCoriolis, computePointLocation, computePointPosition, computePointPosVel, computePointVelocity, createFrameAttachment, createMassBlock, createPointAttachment, getAxisDrawStyle, getAxisLength, getBodyForce, getBodyVelocity, getBodyVelState, getExternalForce, getForce, getForce, getForce, getFrameDamping, getFrameDampingMode, getJacobianType, getMoment, getOrientation, getOrientation, getPosDerivative, getPose, getPose, getPosition, getPosState, getPosStateSize, getRenderFrame, getRotaryDamping, getRotaryDampingMode, getRotation, getSelection, getState, getTargetActivity, getTargetOrientation, getTargetPos, getTargetPose, getTargetPosition, getTargetVel, getTargetVelocity, getTraceablePositionProperty, getTraceables, getTransForce, getVelocity, getVelocity, getVelState, getVelStateSize, getWorldVelState, resetTargets, setAxisDrawStyle, setAxisLength, setBodyVelocity, setContactConstraint, setExternalForce, setForce, setForce, setFrameDamping, setFrameDampingMode, setOrientation, setPose, setPosition, setRandomForce, setRandomPosState, setRandomVelState, setRotaryDamping, setRotaryDampingMode, setRotation, setState, setState, setTargetActivity, setTargetOrientation, setTargetPos, setTargetPose, setTargetPosition, setTargetVel, setTargetVelocity, setVelocity, setVelocity, setVelState, transformPose, updateAttachmentPosStates, velocityLimitExceeded, zeroExternalForces, zeroForces
addAttachmentRequest, addConstrainer, addMasterAttachment, connectToHierarchy, disconnectFromHierarchy, getAttachment, getConstrainers, getMasterAttachments, getSolveIndex, hasState, isActive, isAttached, isControllable, isDynamic, isParametric, removeAttachmentRequest, removeConstrainer, removeMasterAttachment, setAttached, setSolveIndex, transformGeometry
defaultRenderPropsAreNull, getRenderHints, getRenderProps, isSelectable, isVisible, numSelectionQueriesNeeded, setRenderProps, setVisible, updateRenderProps
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, createTempFlag, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
transformPose
createFrameAttachment
createPointAttachment
addAttachmentRequest, removeAttachmentRequest
addConstrainer, addMasterAttachment, getAttachment, getConstrainers, getMasterAttachments, getSolveIndex, isActive, isAttached, isControllable, isDynamic, isParametric, removeConstrainer, removeMasterAttachment, setAttached, setSolveIndex
advanceState, getAuxVarDerivative, getAuxVarState, getStateVersion, hasState, numAuxVars, requiresAdvance, setAuxVarState
transformGeometry, transformPriority
isControllable
public static PropertyList myProps
public static boolean DEFAULT_SUBMESHES_SELECTABLE
public RigidBody()
public RigidBody(java.lang.String name)
public RigidBody(RigidTransform3d XBodyToWorld, SpatialInertia M, PolygonalMesh mesh, java.lang.String meshFileName)
public RigidBody(java.lang.String name, PolygonalMesh mesh, java.lang.String meshFilePath, double density, double scale)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class Frame
public boolean isMassConstant()
isMassConstant
in interface DynamicAgent
isMassConstant
in class Frame
public double getMass(double t)
DynamicAgent
getMass
in interface DynamicAgent
getMass
in class Frame
public void setSubmeshesSelectable(boolean value)
public boolean getSubmeshesSelectable()
public void getMass(Matrix M, double t)
DynamicAgent
getMass
in interface DynamicAgent
getMass
in class Frame
M
- matrix to return the mass int
- current timepublic SpatialInertia getEffectiveInertia()
public double getEffectiveMass()
DynamicAgent
getEffectiveMass
in interface DynamicAgent
getEffectiveMass
in class Frame
public void getEffectiveMass(Matrix M, double t)
DynamicAgent
getEffectiveMass
in interface DynamicAgent
getEffectiveMass
in class Frame
M
- matrix to return the mass int
- current timepublic int mulInverseEffectiveMass(Matrix M, double[] a, double[] f, int idx)
mulInverseEffectiveMass
in interface DynamicAgent
mulInverseEffectiveMass
in class Frame
public static int mulInverseEffectiveMass(SpatialInertia S, double[] a, double[] f, int idx)
public static int getEffectiveMassForces(VectorNd f, double t, FrameState state, SpatialInertia effectiveInertia, int idx)
public int getEffectiveMassForces(VectorNd f, double t, int idx)
DynamicAgent
f
, starting at the location
specified by idx
. Upon return, this method should
return the value of idx
incremented by the dimension
of the mass forces.getEffectiveMassForces
in interface DynamicAgent
getEffectiveMassForces
in class Frame
f
- vector to return the forces int
- current timeidx
- starting location within f
where forces should be storedidx
public void resetEffectiveMass()
DynamicAgent
resetEffectiveMass
in interface DynamicAgent
resetEffectiveMass
in class Frame
public void addEffectivePointMass(double m, Vector3d loc)
addEffectivePointMass
in class Frame
m
- mass of the pointloc
- location of the point (in local frame coordinates)public void addEffectiveFrameMass(SpatialInertia M, RigidTransform3d TFL)
addEffectiveFrameMass
in class Frame
M
- spatial inertia to be addedTFL
- location of the inertia (in local frame coordinates)public void subEffectiveInertia(SpatialInertia M)
public void getInverseMass(Matrix Minv, Matrix M)
DynamicAgent
getInverseMass
in interface DynamicAgent
getInverseMass
in class DynamicComponentBase
Minv
- matrix to return the inverse mass inM
- matrix containing the mass to be invertedpublic RigidBody.InertiaMethod getInertiaMethod()
public void setInertiaMethod(RigidBody.InertiaMethod method)
InertiaMethod
method used to
determine the inertia for this RigidBody.method
- inertia method for this RigidBodysetInertia(maspack.spatialmotion.SpatialInertia)
,
setInertiaFromDensity(double)
,
setInertiaFromMass(double)
public void getInertia(SpatialInertia M)
public void setCenterOfMass(Point3d com)
public void getCenterOfMass(Point3d com)
public Point3d getCenterOfMass()
public Point3d centerPoseOnCenterOfMass()
public void translateCoordinateFrame(Point3d off)
public void transformCoordinateFrame(RigidTransform3d TNB)
TNB
, such the if the
body's current pose is given by TBW
, then the new pose TNW
will be given by
TNW = TBW TNBThis method also updates the vertex positions of the body's meshes (using the inverse
TNB
), as
well as the inertia tensor.public void setInertiaFromDensity(double density)
null
then
the inertia remains unchanged. Subsequent (non-null
) changes
to the mesh will cause the inertia to be recomputed.
The inertia method is set to
DENSITY
.density
- desired uniform densitypublic void setInertiaFromMass(double mass)
null
the mass
of the inertia is updated but the otherwise the inertia and density
are left unchanged. Subsequent (non-null
) changes
to the mesh will cause the inertia to be recomputed.
The inertia method is set to MASS
.mass
- desired body masspublic double getVolume()
public void setDensity(double density)
DENSITY
or
MASS
, the other components of
the spatial inertia will also be updated.density
- new density valuepublic Range getDensityRange()
public double getDensity()
setInertiaFromDensity
, or is the
mass/volume ratio for the most recently defined mesh.public void setMass(double mass)
DENSITY
or
MASS
, the
other components of the spatial inertia will also be updated.mass
- new mass valuepublic double getMass()
getMass
in interface CollidableBody
public Range getMassRange()
public void setRotationalInertia(SymmetricMatrix3d J)
getDensity
) to be undefined).public void getRotationalInertia(SymmetricMatrix3d J)
public SymmetricMatrix3d getRotationalInertia()
public void setInertia(SpatialInertia M)
getDensity
) to be undefined).public void setInertia(double m, SymmetricMatrix3d J)
getDensity
) to be
undefined).public void setInertia(double m, SymmetricMatrix3d J, Point3d com)
getDensity
) to be undefined).public void setInertia(double m, double Jxx, double Jyy, double Jzz)
getDensity
) to be
undefined).public double getInertialDamping()
public void setInertialDamping(double d)
public PropertyMode getInertialDampingMode()
public void setInertialDampingMode(PropertyMode mode)
public boolean hasForce()
DynamicAgent
Any action that alters the return value of this method should
propagate a StructureChangeEvent
. This can be
a state-not-changed event if component's state structure
is not altered (which it typically won't be).
hasForce
in interface DynamicAgent
hasForce
in class Frame
true
if this component exerts its own forces.public RigidMeshComp getSurfaceMeshComp()
null
is returned.null
.public PolygonalMesh getMesh()
getSurfaceMesh()
instead.public PolygonalMesh getSurfaceMesh()
PolygonalMesh
. If no such mesh exists, then
null
is returned.getSurfaceMesh
in interface HasSurfaceMesh
public int numSurfaceMeshes()
HasSurfaceMesh
HasSurfaceMesh.getSurfaceMesh()
returns null
, then this method should return 0.numSurfaceMeshes
in interface HasSurfaceMesh
public PolygonalMesh[] getSurfaceMeshes()
HasSurfaceMesh
HasSurfaceMesh.getSurfaceMesh()
returns null
, then a
zero-length array should be returned.getSurfaceMeshes
in interface HasSurfaceMesh
public void setMesh(PolygonalMesh mesh)
setSurfaceMesh(PolygonalMesh)
instead.public void setMesh(PolygonalMesh mesh, java.lang.String fileName)
setSurfaceMesh(PolygonalMesh,String)
instead.public void setMesh(PolygonalMesh mesh, java.lang.String fileName, AffineTransform3dBase X)
setSurfaceMesh(PolygonalMesh,String,AffineTransform3dBase)
instead.public void setSurfaceMesh(PolygonalMesh mesh)
setSurfaceMesh(mesh,fileName,X)
with fileName
and
X
set to null
.mesh
- new surface meshpublic void setSurfaceMesh(PolygonalMesh mesh, java.lang.String fileName)
#setSurfaceMesh(mesh,fileName,X)
with X
set to null
.mesh
- new surface meshfileName
- optional file name to be associated with the meshpublic void setSurfaceMesh(PolygonalMesh mesh, java.lang.String fileName, AffineTransform3dBase X)
getSurfaceMesh()
returns non-null
), then this mesh
replaces the existing one, at the same location within the {\tt meshes}
sublist. Otherwise, a new surface mesh component is created and placed at
the top of the {\tt meshes} sublist.
If mesh
is null
, then the any existing surface mesh is
removed.
The arguments fileName
and X
specify an optional file
name and rigid or affine transform for the mesh. If specified, these are
used by scan(maspack.util.ReaderTokenizer, java.lang.Object)
and write(java.io.PrintWriter, maspack.util.NumberFormat, java.lang.Object)
for saving and restoring mesh
information. For details, see MeshComponent.getFileName()
and
MeshComponent.getFileTransform()
.
If the body's inertia method is RigidBody.InertiaMethod.MASS
or RigidBody.InertiaMethod.DENSITY
, then its inertia will be updated to reflect the
new mesh geometry.
mesh
- new surface meshfileName
- optional file name to be associated with the meshX
- optional affine transform to be associated with the meshpublic void scaleSurfaceMesh(double sx, double sy, double sz)
public MeshComponentList<RigidMeshComp> getMeshComps()
public RigidMeshComp getMeshComp(int idx)
public RigidMeshComp getMeshComp(java.lang.String name)
public RigidMeshComp addMesh(MeshBase mesh)
mesh
- Instance of MeshBasepublic RigidMeshComp addMesh(MeshBase mesh, boolean hasMass, boolean collidable)
mesh
- Instance of MeshBasehasMass
- true if to be used for mass/inertia calculationscollidable
- true if to be used for collisionspublic RigidMeshComp addMesh(MeshBase mesh, java.lang.String fileName, AffineTransform3dBase Xh, boolean hasMass, boolean collidable)
mesh
- Instance of MeshBasefileName
- name of file (can be null)Xh
- transform associated with meshhasMass
- if true, this mesh is used for computing mass and inertiapublic void addMeshComp(RigidMeshComp mc)
public int numMeshComps()
public boolean containsMeshComp(RigidMeshComp mc)
public boolean removeMeshComp(RigidMeshComp mc)
public RigidMeshComp removeMeshComp(java.lang.String name)
public void clearMeshComps()
public int setPosState(double[] buf, int idx)
setPosState
in interface DynamicAgent
setPosState
in class Frame
public void setPose(double x, double y, double z, double roll, double pitch, double yaw)
public void extrapolatePose(Twist vel, double h)
public DistanceGridComp getDistanceGridComp()
DistanceGridComp
object that in turn contains
a signed distance grid that can be used with a SignedDistanceCollider,
or null
if this Collidable
does not support a signed distance grid (i.e., if
CollidableBody.hasDistanceGrid()
returns false
).getDistanceGridComp
in interface CollidableBody
public void applyGravity(Vector3d gacc)
Frame
applyGravity
in interface DynamicAgent
applyGravity
in class Frame
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 postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
PostScannable
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 write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
scan
and complete
enough to allow full reconstruction of the element.write
in interface Scannable
write
in class ModelComponentBase
pw
- stream for writing the elementfmt
- numeric formating informationref
- optional reference object which can be used for producing references to
other objectsjava.io.IOException
- if an I/O error occuredpublic RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
createRenderProps
in class Frame
public void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
updateBounds
in class Frame
pmin
- minimum pointpmax
- maximum pointpublic void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class Frame
list
- list of objects to be renderedpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class Frame
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 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
addTransformableDependencies
in class Frame
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
transformGeometry
in class Frame
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
scaleDistance
in class Frame
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
scaleMass
in class Frame
s
- scaling factorpublic void setDynamic(boolean dynamic)
public void applyForces(double t)
ForceEffector
applyForces
in interface ForceEffector
applyForces
in class Frame
t
- time (seconds)public void addVelJacobian(SparseNumberedBlockMatrix S, 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
addVelJacobian
in class Frame
S
- solve matrix to which scaled velocity Jacobian is to be addeds
- scaling factor for velocity Jacobianpublic 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
isDuplicatable
in class Frame
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
getCopyReferences
in class Frame
refs
- list to which references are appendedancestor
- root node of the hierarchy from which references are to be excludedpublic RigidBody 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 Frame
flags
- flags to control the copyingcopyMap
- map to possible existing instances of referenced
componentspublic FrameMarker[] getFrameMarkers()
public void addConnector(BodyConnector c)
addConnector
in interface ConnectableBody
public void removeConnector(BodyConnector c)
removeConnector
in interface ConnectableBody
public boolean containsConnector(BodyConnector c)
containsConnector
in interface ConnectableBody
public java.util.List<BodyConnector> getConnectors()
getConnectors
in interface ConnectableBody
public boolean isFreeBody()
isFreeBody
in interface ConnectableBody
public static RigidBody createSphere(java.lang.String bodyName, double r, double density, int nslices)
bodyName
- name of the RigidBodyr
- radius of the spheredensity
- density of the bodynslices
- number of slices used in creating the meshpublic static RigidBody createIcosahedralSphere(java.lang.String bodyName, double r, double density, int ndivisions)
bodyName
- name of the RigidBodyr
- radius of the spheredensity
- density of the bodyndivisions
- number of divisions used in creating the meshpublic static RigidBody createEllipsoid(java.lang.String bodyName, double a, double b, double c, double density, int nslices)
bodyName
- name of the RigidBodya
- semi-axis length in the x directionb
- semi-axis length in the y directionc
- semi-axis length in the z directiondensity
- density of the bodynslices
- number of slices used in creating the meshpublic static RigidBody createBox(java.lang.String bodyName, double wx, double wy, double wz, double density)
bodyName
- name of the RigidBodywx
- width of the box in the x directionwy
- width of the box in the y directionwz
- width of the box in the z directiondensity
- density of the bodypublic static RigidBody createBox(java.lang.String bodyName, double wx, double wy, double wz, double density, boolean addNormals)
bodyName
- name of the RigidBodywx
- width of the box in the x directionwy
- width of the box in the y directionwz
- width of the box in the z directiondensity
- density of the bodypublic static RigidBody createBox(java.lang.String bodyName, double wx, double wy, double wz, int nx, int ny, int nz, double density, boolean addNormals)
bodyName
- name of the RigidBodywx
- width of the box in the x directionwy
- width of the box in the y directionwz
- width of the box in the z directionnx
- number of mesh divisions in the x directionny
- number of mesh divisions in the y directionnz
- number of mesh divisions in the z directiondensity
- density of the bodypublic static RigidBody createCylinder(java.lang.String bodyName, double r, double h, double density, int nsides)
bodyName
- name of the RigidBodyr
- cylinder radiush
- cylinder heightdensity
- density of the bodynsides
- number of sides used in creating the cylinder meshpublic static RigidBody createFromMesh(java.lang.String bodyName, PolygonalMesh mesh, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, PolygonalMesh mesh, java.lang.String meshFilePath, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, java.lang.String meshPath, double density, double scale)
public static RigidBody createFromMesh(java.lang.String bodyName, java.lang.Object obj, java.lang.String relPath, double density, double scale)
public PolygonalMesh getCollisionMesh()
CollidableBody
null
if there is no such mesh. If this method
returns null
, then no collisions will
be performed for this collidable, regardless any default or explicit
collision behaviors that have been arranged by the system.getCollisionMesh
in interface CollidableBody
public boolean hasDistanceGrid()
true
if this RigidBody supports a signed
distance grid that can be used with a SignedDistanceCollider.
The grid itself can be obtained with getDistanceGrid()
.hasDistanceGrid
in interface CollidableBody
true
if a signed distance grid is available
for this RigidBodypublic DistanceGrid getDistanceGrid()
null
if a grid is not available.
Aspects of the grid, including its visibility, resolution, and
mesh fit, can be controlled using properties of its encapsulating
DistanceGridComp
, returned by getDistanceGridComp()
.null
if a grid is
not available this RigidBodypublic Collidable.Collidability getCollidable()
Collidable
Collidable.Collidability
of this Collidable. This provides
control over whether external and/or internal collisions are enabled for
this Collidable. This setting takes precedence over default and
explicitly requested collision behaviors.
Note that for collisions to actually occur, they still need to be enabled through either a default or explicit collision behavior in the MechModel.
getCollidable
in interface Collidable
public Collidable getCollidableAncestor()
Collidable
null
.getCollidableAncestor
in interface Collidable
null
.public boolean isCompound()
Collidable
isCompound
in interface Collidable
true
if this collidable has sub-collidablespublic void setCollidable(Collidable.Collidability c)
public boolean isDeformable()
Collidable
true
if this collidable is deformable. Whether or
not a collidable is deformable determines how it responds to default
collision behaviors involving deformable and rigid collidables. Also,
self-collisions among sub-collidables of a collidable A are permitted
only if A is deformable.isDeformable
in interface Collidable
isDeformable
in interface ConnectableBody
true
if this collidable is deformablepublic void collectVertexMasters(java.util.List<ContactMaster> mlist, Vertex3d vtx)
mlist
. The vertex
should be a vertex of the mesh returned by CollidableBody.getCollisionMesh()
.
If CollidableBody.hasInvariantMasters()
returns true
, then the
contact masters will not depend on vtx
.
collectVertexMasters
in interface CollidableBody
mlist
- collected master componentsvtx
- vertex for which the master components are requestedpublic boolean hasInvariantMasters()
A collidable that has invariant contact masters typically has fewer dynamic degrees of freedom compared to one that does not.
hasInvariantMasters
in interface CollidableBody
true
if contact masters are constantpublic boolean containsContactMaster(CollidableDynamicComponent comp)
CollidableBody
containsContactMaster
in interface CollidableBody
comp
- component to test fortrue
if comp
is contained in
this Collidablepublic boolean allowCollision(ContactPoint cpnt, Collidable other, java.util.Set<Vertex3d> attachedVertices)
CollidableBody
true
if a collision between this Collidable
and other
should be allowed for the contact point
cpnt
. In making this decision, this method may
refer to attachedVertices
, which supplies a list
of vertices on this Collidable which are attached in some way
to the other Collidable.allowCollision
in interface CollidableBody
cpnt
- contact point being testedother
- opposing collidableattachedVertices
- list of vertices attached to other
.true
if the collision should be allowedpublic int getCollidableIndex()
getCollidableIndex
in interface CollidableBody
public void setCollidableIndex(int idx)
setCollidableIndex
in interface CollidableBody
public void surfaceTangent(Point3d pr, Point3d pa, Point3d p1, double lam0, Vector3d sideNrm)
pt
on the surface of this Wrappable such
that the line segment (pa,pt) is both tangent to the surface and as near
as possible to the line defined by the two points pa and p1.
To assist with the computation, pKcheck[kmax]t
can be assumed to lie
fairly close to p1
, and its projection onto the line can be
assumed to lie between p1
and another point p0 defined by
p0 = (1-lam0) pa + lam0 p1where
lam0
is a parameter between 0 and 1.surfaceTangent
in interface Wrappable
pr
- returns the tangent pointpa
- first point of the linep1
- second point of the linelam0
- parameter defining point p0 as defined abovesideNrm
- a normalized vector perpendicular to the plane defined by
pa
, p1
and pt
. Can be used
to help compute pt
public double penetrationDistance(Vector3d nrm, Matrix3d Dnrm, Point3d p0)
p0
into this
Wrappable, along with the normal nrm
that points from
p0
to its nearest point on the surface. The distance should
be negative if the point is inside the wrappable, and positive otherwise.
If the point is outside and further than some minimum distance,
then the method should return the constant Wrappable.OUTSIDE
.
If possible, the method should also compute the derivative of the
normal with respect to changes in p0
, and return this in
dnrm
. If this is not possible, dnrm
should be
set to 0.
penetrationDistance
in interface Wrappable
nrm
- returns the normal (should be normalized)Dnrm
- returns the derivative of the normal with respect to
changes in p0, or zero if this cannot be determined.p0
- point to determine penetration forWrappable.OUTSIDE
if the
point is further than some minimum distance from the wrappable.public double getCharacteristicRadius()
getCharacteristicRadius
in interface Wrappable
public void setDistanceGridRes(Vector3i res)
DistanceGridComp.setResolution(maspack.matrix.Vector3i)
for this body's distance grid.res
- x, y, and z cell divisions to be used in constructing the gridpublic Vector3i getDistanceGridRes()
DistanceGridComp.getResolution()
for this body's distance grid.public boolean getGridSurfaceRendering()
true
if grid surface rendering is enabledsetGridSurfaceRendering(boolean)
public void setGridSurfaceRendering(boolean enable)
DistanceGridComp
, returned by
getDistanceGridComp()
.enable
- if true
, enables grid surface rendering.getGridSurfaceRendering()
public void updateNameMap(java.lang.String newName, java.lang.String oldName, ModelComponent comp)
updateNameMap
in interface CompositeComponent
public ModelComponent findComponent(java.lang.String path)
findComponent
in interface CompositeComponent
path
- path leading to the subcomponentpublic void add(ModelComponent comp)
public boolean remove(ModelComponent comp)
public ModelComponent get(java.lang.String nameOrNumber)
get
in interface CompositeComponent
nameOrNumber
- name or number of the subcomponentpublic ModelComponent get(int idx)
get
in interface CompositeComponent
get
in interface IndexedComponentList
idx
- index of the subcomponentpublic ModelComponent getByNumber(int num)
getByNumber
in interface CompositeComponent
num
- number of the subcomponentpublic int getNumberLimit()
getNumberLimit
in interface CompositeComponent
public int indexOf(ModelComponent comp)
indexOf
in interface CompositeComponent
comp
- component whose index is requestedpublic int numComponents()
numComponents
in interface CompositeComponent
numComponents
in interface IndexedComponentList
public void componentChanged(ComponentChangeEvent e)
This method should propagate the notification up the component hierarchy
by calling notifyParentOfChange
.
componentChanged
in interface ComponentChangeListener
componentChanged
in interface CompositeComponent
e
- optional argument giving specific information about the changepublic CompositeComponent.NavpanelDisplay getNavpanelDisplay()
getNavpanelDisplay
in interface CompositeComponent
public void setDisplayMode(CompositeComponent.NavpanelDisplay mode)
NORMAL
.mode
- new display modepublic boolean hierarchyContainsReferences()
In particular, this means that one does not need to search outside the hierarchy when looking for dependencies.
hierarchyContainsReferences
in interface CompositeComponent
public java.util.Iterator<? extends HierarchyNode> getChildren()
getChildren
in interface HierarchyNode
getChildren
in class ModelComponentBase
public boolean hasChildren()
hasChildren
in interface HierarchyNode
hasChildren
in class ModelComponentBase