MechanicalObject
mechanical state vectors This class can be overridden if needed for additional storage within template specializations.
The `MechanicalObject` component represents the mechanical state of an object in SOFA simulations, managing positions, velocities, forces, and constraints.
- module
- Sofa.Component.StateContainer
- namespace
- sofa::component::statecontainer
- include
- sofa/component/statecontainer/MechanicalObject.h
- inherits
-
- MechanicalState
- templates
-
- sofa::defaulttype::Rigid2Types
- sofa::defaulttype::Rigid3Types
- sofa::defaulttype::Vec3Types
- description
The MechanicalObject class in the SOFA (Simulation Open Framework Architecture) framework represents the mechanical properties and state of an object within a simulation. It is a crucial component used to define the physical characteristics, such as positions, velocities, forces, and constraints, for each discrete element or point mass that constitutes the object being simulated.
Mathematical Representation:
-
Positions (
x): The position vector $ extbf{x} = [x_0, x_1, ..., x_n]^T $ where each component $ x_i $ represents the spatial location of a point in 3D space. -
Velocities (
v): The velocity vector $ extbf{v} = [v_0, v_1, ..., v_n]^T $, where each component $ v_i $ is the time derivative of the position vector for each point. -
Forces (
f): The force vector $ extbf{f} = [f_0, f_1, ..., f_n]^T $, representing external forces acting on each discrete element. -
External Forces (
externalForces): External forces applied to the object are stored in a separate vector and accumulated into the total force during integration. -
Rest Positions (
x0): The rest position vector $ extbf{x}_0 = [x_{0,0}, x_{1,0}, ..., x_{n,0}]^T $ stores the initial or reference positions of each point in the object, used for calculating deformations and restoring forces. -
Constraints: Constraints are represented using matrices (e.g., Jacobian matrix
c) to encode linear relationships between points that must be satisfied during simulation steps. Each row of this matrix corresponds to a constraint equation involving certain degrees of freedom (DOFs).
Physics Representation: Newton's Equations of Motion:
The core physics behind the MechanicalObject can be derived from Newton’s second law:
$$ m rac{d^2x}{dt^2} = F_{net}(t) $$where $ m $ is mass, $ x $ is position, and $ F_{net}(t) $ includes both external forces (applied by the user or environment) and internal restoring forces due to material properties.
In discrete form within a time step $ riangle t $, this becomes an iterative update rule for positions and velocities:
$$ v(t + riangle t) = v(t) + rac{ riangle t}{m} F_{net}(t) $$ $$ x(t + riangle t) = x(t) + v(t + riangle t) * riangle t $$Integration Schemes:
The vOp method implements various vector operations, often used in integration schemes such as Euler or Runge-Kutta methods to update the states of the object over time. These operations handle accumulation of forces, addition of velocities, scaling by a factor (e.g., timestep), etc.
Visualization and Picking:
The draw method is responsible for rendering the mechanical state visually in 3D space, while pickParticles enables selecting specific points based on their positions relative to an input ray, useful for interactive simulations where user interaction with objects is needed.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
x |
VecCoord | |
position coordinates of the degrees of freedom |
v |
VecDeriv | |
velocity coordinates of the degrees of freedom |
f |
VecDeriv | |
force vector of the degrees of freedom |
x0 |
VecCoord | |
rest position coordinates of the degrees of freedom |
externalForces |
VecDeriv | |
externalForces vector of the degrees of freedom |
dx |
VecDeriv | |
dx vector of the degrees of freedom |
xfree |
VecCoord | |
free position coordinates of the degrees of freedom |
vfree |
VecDeriv | |
free velocity coordinates of the degrees of freedom |
c |
MatrixDeriv | |
constraints applied to the degrees of freedom |
m |
MatrixDeriv | |
mappingJacobian applied to the degrees of freedom |
reset_position |
VecCoord | |
reset position coordinates of the degrees of freedom |
reset_velocity |
VecDeriv | |
reset velocity coordinates of the degrees of freedom |
restScale |
SReal | |
optional scaling of rest position coordinates (to simulated pre-existing internal tension).(default = 1.0) |
d_useTopology |
bool | |
Shall this object rely on any active topology to initialize its size and positions |
showObject |
bool | |
Show objects. (default=false) |
showObjectScale |
float | |
Scale for object display. (default=0.1) |
showIndices |
bool | |
Show indices. (default=false) |
showIndicesScale |
float | |
Scale for indices display. (default=0.02) |
showVectors |
bool | |
Show velocity. (default=false) |
showVectorsScale |
float | |
Scale for vectors display. (default=0.0001) |
drawMode |
int | |
The way vectors will be drawn:\n- 0: Line\n- 1:Cylinder\n- 2: Arrow.\n\nThe DOFS will be drawn:\n- 0: point\n- >1: sphere. (default=0) |
d_color |
type::RGBAColor | |
Color for object display. (default=[1 1 1 1]) |
translation |
type::Vec3 | |
Translation of the DOFs |
rotation |
type::Vec3 | |
Rotation of the DOFs |
scale |
type::Vec3 | |
Scale of the DOFs in 3 dimensions |
translation2 |
type::Vec3 | |
Translation of the DOFs, applied after the rest position has been computed |
rotation2 |
type::Vec3 | |
Rotation of the DOFs, applied the after the rest position has been computed |
d_size |
int | |
Size of the vectors |
f_reserve |
int | |
Size to reserve when creating vectors. (default=0) |
data |
DataTypes | |
Links
| Name | Type | Help |
|---|---|---|
l_topology |
Link to the topology relevant for this object |
Methods
MechanicalObject<DataTypes> &
operator=
(const MechanicalObject<DataTypes> & )
void
parse
(core::objectmodel::BaseObjectDescription * arg)
void
init
()
void
reinit
()
void
storeResetState
()
void
reset
()
void
writeVec
(core::ConstVecId v, int & out)
void
readVec
(core::VecId v, int & in)
SReal
compareVec
(core::ConstVecId v, int & in)
void
writeState
(int & out)
Data<VecCoord> *
write
(core::VecCoordId v)
const Data<VecCoord> *
read
(core::ConstVecCoordId v)
Data<VecDeriv> *
write
(core::VecDerivId v)
const Data<VecDeriv> *
read
(core::ConstVecDerivId v)
Data<MatrixDeriv> *
write
(core::MatrixDerivId v)
const Data<MatrixDeriv> *
read
(core::ConstMatrixDerivId v)
void
initGnuplot
(const int path)
void
exportGnuplot
(SReal time)
void
resize
(int vsize)
void
reserve
(int vsize)
virtual
int
getSize
()
SReal
getPX
(int i)
SReal
getPY
(int i)
SReal
getPZ
(int i)
SReal
getVX
(int i)
SReal
getVY
(int i)
SReal
getVZ
(int i)
void
replaceValue
(const int inputIndex, const int outputIndex)
void
swapValues
(const int idx1, const int idx2)
void
renumberValues
(const int & index)
void
computeWeightedValue
(const int i, const int & ancestors, const int & coefs)
void
forcePointPosition
(const int i, const int & m_x)
void
applyTranslation
(const SReal dx, const SReal dy, const SReal dz)
void
applyRotation
(const SReal rx, const SReal ry, const SReal rz)
void
applyRotation
(const type::Quat<SReal> q)
void
applyScale
(const SReal sx, const SReal sy, const SReal sz)
void
getIndicesInSpace
(int & indices, Real xmin, Real xmax, Real ymin, Real ymax, Real zmin, Real zmax)
bool
addBBox
(SReal * minBBox, SReal * maxBBox)
void
computeBBox
(const core::ExecParams * params, bool onlyVisible)
void
copyToBaseVector
(linearalgebra::BaseVector * dest, core::ConstVecId src, unsigned int & offset)
void
copyFromBaseVector
(core::VecId dest, const linearalgebra::BaseVector * src, unsigned int & offset)
void
copyToBaseMatrix
(linearalgebra::BaseMatrix * dest, core::ConstMatrixDerivId src, unsigned int & offset)
void
addToBaseVector
(linearalgebra::BaseVector * dest, core::ConstVecId src, unsigned int & offset)
void
addFromBaseVectorSameSize
(core::VecId dest, const linearalgebra::BaseVector * src, unsigned int & offset)
void
addFromBaseVectorDifferentSize
(core::VecId dest, const linearalgebra::BaseVector * src, unsigned int & offset)
int
constraintBlocks
(const int & indices)
SReal
getConstraintJacobianTimesVecDeriv
(unsigned int line, core::ConstVecId id)
void
setTranslation
(SReal dx, SReal dy, SReal dz)
void
setRotation
(SReal rx, SReal ry, SReal rz)
void
setScale
(SReal sx, SReal sy, SReal sz)
type::Vec3
getTranslation
()
virtual
type::Vec3
getRotation
()
virtual
type::Vec3
getScale
()
void
beginIntegration
(SReal dt)
void
endIntegration
(const core::ExecParams * params, SReal dt)
void
accumulateForce
(const core::ExecParams * params, core::VecDerivId f)
void
vAvail
(const core::ExecParams * params, core::VecCoordId & v)
void
vAvail
(const core::ExecParams * params, core::VecDerivId & v)
void
vAlloc
(const core::ExecParams * params, core::VecCoordId v, const core::VecIdProperties & properties)
void
vAlloc
(const core::ExecParams * params, core::VecDerivId v, const core::VecIdProperties & properties)
void
vRealloc
(const core::ExecParams * params, core::VecCoordId v, const core::VecIdProperties & properties)
void
vRealloc
(const core::ExecParams * params, core::VecDerivId v, const core::VecIdProperties & properties)
void
vFree
(const core::ExecParams * params, core::VecCoordId v)
void
vFree
(const core::ExecParams * params, core::VecDerivId v)
void
vInit
(const core::ExecParams * params, core::VecCoordId v, core::ConstVecCoordId vSrc)
void
vInit
(const core::ExecParams * params, core::VecDerivId v, core::ConstVecDerivId vSrc)
void
vOp
(const core::ExecParams * params, core::VecId v, core::ConstVecId a, core::ConstVecId b, SReal f)
void
vMultiOp
(const core::ExecParams * params, const VMultiOp & ops)
void
vThreshold
(core::VecId a, SReal threshold)
SReal
vDot
(const core::ExecParams * params, core::ConstVecId a, core::ConstVecId b)
SReal
vSum
(const core::ExecParams * params, core::ConstVecId a, unsigned int l)
SReal
vMax
(const core::ExecParams * params, core::ConstVecId a)
int
vSize
(const core::ExecParams * params, core::ConstVecId v)
void
resetForce
(const core::ExecParams * params, core::VecDerivId f)
void
resetAcc
(const core::ExecParams * params, core::VecDerivId a)
void
resetConstraint
(const core::ConstraintParams * cparams)
void
getConstraintJacobian
(const core::ConstraintParams * cparams, sofa::linearalgebra::BaseMatrix * J, unsigned int & off)
void
buildIdentityBlocksInJacobian
(const int & list_n, core::MatrixDerivId & mID)
void
printDOF
(core::ConstVecId , int & , int firstIndex, int range)
unsigned int
printDOFWithElapsedTime
(core::ConstVecId , unsigned int , unsigned int , int & )
void
draw
(const core::visual::VisualParams * vparams)
void
handleStateChange
()
bool
pickParticles
(const core::ExecParams * params, double rayOx, double rayOy, double rayOz, double rayDx, double rayDy, double rayDz, double radius0, double dRadius, int & particles)
bool
isIndependent
()
void
setVecCoord
(core::ConstVecCoordId , Data<VecCoord> * )
void
setVecDeriv
(core::ConstVecDerivId , Data<VecDeriv> * )
void
setVecMatrixDeriv
(core::ConstMatrixDerivId , Data<MatrixDeriv> * )
void
vAvailImpl
(core::TVecId<vtype, core::V_WRITE> & v, int & dataContainer)
void
vAllocImpl
(core::TVecId<vtype, core::V_WRITE> v, const core::VecIdProperties & properties)
void
vReallocImpl
(core::TVecId<vtype, core::V_WRITE> v, const core::VecIdProperties & properties)
void
vFreeImpl
(core::TVecId<vtype, core::V_WRITE> v)
void
vInitImpl
(const core::ExecParams * params, core::TVecId<vtype, core::V_WRITE> vId, core::TVecId<vtype, core::V_READ> vSrcId)
int
getWriteOnlyAccessor
(core::VecId v)
int
getWriteAccessor
(core::VecId v)
int
getReadAccessor
(core::ConstVecId v)
void
drawIndices
(const core::visual::VisualParams * vparams)
void
drawVectors
(const core::visual::VisualParams * vparams)
void
setVecIdProperties
(core::TVecId<vtype, vaccess> v, const core::VecIdProperties & properties, core::BaseData * vec_d)
{
"name": "MechanicalObject",
"namespace": "sofa::component::statecontainer",
"module": "Sofa.Component.StateContainer",
"include": "sofa/component/statecontainer/MechanicalObject.h",
"doc": "mechanical state vectors\n\nThis class can be overridden if needed for additional storage within template specializations.",
"inherits": [
"MechanicalState"
],
"templates": [
"sofa::defaulttype::Rigid2Types",
"sofa::defaulttype::Rigid3Types",
"sofa::defaulttype::Vec3Types"
],
"data_fields": [
{
"name": "x",
"type": "VecCoord",
"xmlname": "position",
"help": "position coordinates of the degrees of freedom"
},
{
"name": "v",
"type": "VecDeriv",
"xmlname": "velocity",
"help": "velocity coordinates of the degrees of freedom"
},
{
"name": "f",
"type": "VecDeriv",
"xmlname": "force",
"help": "force vector of the degrees of freedom"
},
{
"name": "x0",
"type": "VecCoord",
"xmlname": "rest_position",
"help": "rest position coordinates of the degrees of freedom"
},
{
"name": "externalForces",
"type": "VecDeriv",
"xmlname": "externalForce",
"help": "externalForces vector of the degrees of freedom"
},
{
"name": "dx",
"type": "VecDeriv",
"xmlname": "derivX",
"help": "dx vector of the degrees of freedom"
},
{
"name": "xfree",
"type": "VecCoord",
"xmlname": "free_position",
"help": "free position coordinates of the degrees of freedom"
},
{
"name": "vfree",
"type": "VecDeriv",
"xmlname": "free_velocity",
"help": "free velocity coordinates of the degrees of freedom"
},
{
"name": "c",
"type": "MatrixDeriv",
"xmlname": "constraint",
"help": "constraints applied to the degrees of freedom"
},
{
"name": "m",
"type": "MatrixDeriv",
"xmlname": "mappingJacobian",
"help": "mappingJacobian applied to the degrees of freedom"
},
{
"name": "reset_position",
"type": "VecCoord",
"xmlname": "reset_position",
"help": "reset position coordinates of the degrees of freedom"
},
{
"name": "reset_velocity",
"type": "VecDeriv",
"xmlname": "reset_velocity",
"help": "reset velocity coordinates of the degrees of freedom"
},
{
"name": "restScale",
"type": "SReal",
"xmlname": "restScale",
"help": "optional scaling of rest position coordinates (to simulated pre-existing internal tension).(default = 1.0)"
},
{
"name": "d_useTopology",
"type": "bool",
"xmlname": "useTopology",
"help": "Shall this object rely on any active topology to initialize its size and positions"
},
{
"name": "showObject",
"type": "bool",
"xmlname": "showObject",
"help": "Show objects. (default=false)"
},
{
"name": "showObjectScale",
"type": "float",
"xmlname": "showObjectScale",
"help": "Scale for object display. (default=0.1)"
},
{
"name": "showIndices",
"type": "bool",
"xmlname": "showIndices",
"help": "Show indices. (default=false)"
},
{
"name": "showIndicesScale",
"type": "float",
"xmlname": "showIndicesScale",
"help": "Scale for indices display. (default=0.02)"
},
{
"name": "showVectors",
"type": "bool",
"xmlname": "showVectors",
"help": "Show velocity. (default=false)"
},
{
"name": "showVectorsScale",
"type": "float",
"xmlname": "showVectorsScale",
"help": "Scale for vectors display. (default=0.0001)"
},
{
"name": "drawMode",
"type": "int",
"xmlname": "drawMode",
"help": "The way vectors will be drawn:\\n- 0: Line\\n- 1:Cylinder\\n- 2: Arrow.\\n\\nThe DOFS will be drawn:\\n- 0: point\\n- >1: sphere. (default=0)"
},
{
"name": "d_color",
"type": "type::RGBAColor",
"xmlname": "showColor",
"help": "Color for object display. (default=[1 1 1 1])"
},
{
"name": "translation",
"type": "type::Vec3",
"xmlname": "translation",
"help": "Translation of the DOFs"
},
{
"name": "rotation",
"type": "type::Vec3",
"xmlname": "rotation",
"help": "Rotation of the DOFs"
},
{
"name": "scale",
"type": "type::Vec3",
"xmlname": "scale3d",
"help": "Scale of the DOFs in 3 dimensions"
},
{
"name": "translation2",
"type": "type::Vec3",
"xmlname": "translation2",
"help": "Translation of the DOFs, applied after the rest position has been computed"
},
{
"name": "rotation2",
"type": "type::Vec3",
"xmlname": "rotation2",
"help": "Rotation of the DOFs, applied the after the rest position has been computed"
},
{
"name": "d_size",
"type": "int",
"xmlname": "size",
"help": "Size of the vectors"
},
{
"name": "f_reserve",
"type": "int",
"xmlname": "reserve",
"help": "Size to reserve when creating vectors. (default=0)"
},
{
"name": "data",
"type": "DataTypes"
}
],
"links": [
{
"name": "l_topology",
"target": "BaseMeshTopology",
"kind": "single",
"xmlname": "topology",
"help": "Link to the topology relevant for this object"
}
],
"methods": [
{
"name": "operator=",
"return_type": "MechanicalObject<DataTypes> &",
"params": [
{
"name": "",
"type": "const MechanicalObject<DataTypes> &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "parse",
"return_type": "void",
"params": [
{
"name": "arg",
"type": "core::objectmodel::BaseObjectDescription *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "init",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reinit",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "storeResetState",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reset",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeVec",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::ConstVecId"
},
{
"name": "out",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "readVec",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::VecId"
},
{
"name": "in",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "compareVec",
"return_type": "SReal",
"params": [
{
"name": "v",
"type": "core::ConstVecId"
},
{
"name": "in",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeState",
"return_type": "void",
"params": [
{
"name": "out",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "write",
"return_type": "Data<VecCoord> *",
"params": [
{
"name": "v",
"type": "core::VecCoordId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "read",
"return_type": "const Data<VecCoord> *",
"params": [
{
"name": "v",
"type": "core::ConstVecCoordId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "write",
"return_type": "Data<VecDeriv> *",
"params": [
{
"name": "v",
"type": "core::VecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "read",
"return_type": "const Data<VecDeriv> *",
"params": [
{
"name": "v",
"type": "core::ConstVecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "write",
"return_type": "Data<MatrixDeriv> *",
"params": [
{
"name": "v",
"type": "core::MatrixDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "read",
"return_type": "const Data<MatrixDeriv> *",
"params": [
{
"name": "v",
"type": "core::ConstMatrixDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "initGnuplot",
"return_type": "void",
"params": [
{
"name": "path",
"type": "const int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "exportGnuplot",
"return_type": "void",
"params": [
{
"name": "time",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "resize",
"return_type": "void",
"params": [
{
"name": "vsize",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reserve",
"return_type": "void",
"params": [
{
"name": "vsize",
"type": "int"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getSize",
"return_type": "int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getPX",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getPY",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getPZ",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getVX",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getVY",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getVZ",
"return_type": "SReal",
"params": [
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "replaceValue",
"return_type": "void",
"params": [
{
"name": "inputIndex",
"type": "const int"
},
{
"name": "outputIndex",
"type": "const int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "swapValues",
"return_type": "void",
"params": [
{
"name": "idx1",
"type": "const int"
},
{
"name": "idx2",
"type": "const int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "renumberValues",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "computeWeightedValue",
"return_type": "void",
"params": [
{
"name": "i",
"type": "const int"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "coefs",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "forcePointPosition",
"return_type": "void",
"params": [
{
"name": "i",
"type": "const int"
},
{
"name": "m_x",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "applyTranslation",
"return_type": "void",
"params": [
{
"name": "dx",
"type": "const SReal"
},
{
"name": "dy",
"type": "const SReal"
},
{
"name": "dz",
"type": "const SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "applyRotation",
"return_type": "void",
"params": [
{
"name": "rx",
"type": "const SReal"
},
{
"name": "ry",
"type": "const SReal"
},
{
"name": "rz",
"type": "const SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "applyRotation",
"return_type": "void",
"params": [
{
"name": "q",
"type": "const type::Quat<SReal>"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "applyScale",
"return_type": "void",
"params": [
{
"name": "sx",
"type": "const SReal"
},
{
"name": "sy",
"type": "const SReal"
},
{
"name": "sz",
"type": "const SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getIndicesInSpace",
"return_type": "void",
"params": [
{
"name": "indices",
"type": "int &"
},
{
"name": "xmin",
"type": "Real"
},
{
"name": "xmax",
"type": "Real"
},
{
"name": "ymin",
"type": "Real"
},
{
"name": "ymax",
"type": "Real"
},
{
"name": "zmin",
"type": "Real"
},
{
"name": "zmax",
"type": "Real"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addBBox",
"return_type": "bool",
"params": [
{
"name": "minBBox",
"type": "SReal *"
},
{
"name": "maxBBox",
"type": "SReal *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "computeBBox",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "onlyVisible",
"type": "bool"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "copyToBaseVector",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "linearalgebra::BaseVector *"
},
{
"name": "src",
"type": "core::ConstVecId"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "copyFromBaseVector",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "core::VecId"
},
{
"name": "src",
"type": "const linearalgebra::BaseVector *"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "copyToBaseMatrix",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "linearalgebra::BaseMatrix *"
},
{
"name": "src",
"type": "core::ConstMatrixDerivId"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addToBaseVector",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "linearalgebra::BaseVector *"
},
{
"name": "src",
"type": "core::ConstVecId"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addFromBaseVectorSameSize",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "core::VecId"
},
{
"name": "src",
"type": "const linearalgebra::BaseVector *"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addFromBaseVectorDifferentSize",
"return_type": "void",
"params": [
{
"name": "dest",
"type": "core::VecId"
},
{
"name": "src",
"type": "const linearalgebra::BaseVector *"
},
{
"name": "offset",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "constraintBlocks",
"return_type": "int",
"params": [
{
"name": "indices",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getConstraintJacobianTimesVecDeriv",
"return_type": "SReal",
"params": [
{
"name": "line",
"type": "unsigned int"
},
{
"name": "id",
"type": "core::ConstVecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTranslation",
"return_type": "void",
"params": [
{
"name": "dx",
"type": "SReal"
},
{
"name": "dy",
"type": "SReal"
},
{
"name": "dz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setRotation",
"return_type": "void",
"params": [
{
"name": "rx",
"type": "SReal"
},
{
"name": "ry",
"type": "SReal"
},
{
"name": "rz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setScale",
"return_type": "void",
"params": [
{
"name": "sx",
"type": "SReal"
},
{
"name": "sy",
"type": "SReal"
},
{
"name": "sz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTranslation",
"return_type": "type::Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getRotation",
"return_type": "type::Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getScale",
"return_type": "type::Vec3",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "beginIntegration",
"return_type": "void",
"params": [
{
"name": "dt",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "endIntegration",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "dt",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "accumulateForce",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "f",
"type": "core::VecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vAvail",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecCoordId &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vAvail",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecDerivId &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vAlloc",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecCoordId"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vAlloc",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecDerivId"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vRealloc",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecCoordId"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vRealloc",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecDerivId"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vFree",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecCoordId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vFree",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vInit",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecCoordId"
},
{
"name": "vSrc",
"type": "core::ConstVecCoordId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vInit",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecDerivId"
},
{
"name": "vSrc",
"type": "core::ConstVecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vOp",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::VecId"
},
{
"name": "a",
"type": "core::ConstVecId"
},
{
"name": "b",
"type": "core::ConstVecId"
},
{
"name": "f",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vMultiOp",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "ops",
"type": "const VMultiOp &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vThreshold",
"return_type": "void",
"params": [
{
"name": "a",
"type": "core::VecId"
},
{
"name": "threshold",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vDot",
"return_type": "SReal",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "a",
"type": "core::ConstVecId"
},
{
"name": "b",
"type": "core::ConstVecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vSum",
"return_type": "SReal",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "a",
"type": "core::ConstVecId"
},
{
"name": "l",
"type": "unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vMax",
"return_type": "SReal",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "a",
"type": "core::ConstVecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "vSize",
"return_type": "int",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "v",
"type": "core::ConstVecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "resetForce",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "f",
"type": "core::VecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "resetAcc",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "a",
"type": "core::VecDerivId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "resetConstraint",
"return_type": "void",
"params": [
{
"name": "cparams",
"type": "const core::ConstraintParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getConstraintJacobian",
"return_type": "void",
"params": [
{
"name": "cparams",
"type": "const core::ConstraintParams *"
},
{
"name": "J",
"type": "sofa::linearalgebra::BaseMatrix *"
},
{
"name": "off",
"type": "unsigned int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "buildIdentityBlocksInJacobian",
"return_type": "void",
"params": [
{
"name": "list_n",
"type": "const int &"
},
{
"name": "mID",
"type": "core::MatrixDerivId &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "printDOF",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::ConstVecId"
},
{
"name": "",
"type": "int &"
},
{
"name": "firstIndex",
"type": "int"
},
{
"name": "range",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "printDOFWithElapsedTime",
"return_type": "unsigned int",
"params": [
{
"name": "",
"type": "core::ConstVecId"
},
{
"name": "",
"type": "unsigned int"
},
{
"name": "",
"type": "unsigned int"
},
{
"name": "",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "draw",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "handleStateChange",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "pickParticles",
"return_type": "bool",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "rayOx",
"type": "double"
},
{
"name": "rayOy",
"type": "double"
},
{
"name": "rayOz",
"type": "double"
},
{
"name": "rayDx",
"type": "double"
},
{
"name": "rayDy",
"type": "double"
},
{
"name": "rayDz",
"type": "double"
},
{
"name": "radius0",
"type": "double"
},
{
"name": "dRadius",
"type": "double"
},
{
"name": "particles",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isIndependent",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setVecCoord",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::ConstVecCoordId"
},
{
"name": "",
"type": "Data<VecCoord> *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "setVecDeriv",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::ConstVecDerivId"
},
{
"name": "",
"type": "Data<VecDeriv> *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "setVecMatrixDeriv",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::ConstMatrixDerivId"
},
{
"name": "",
"type": "Data<MatrixDeriv> *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vAvailImpl",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::TVecId<vtype, core::V_WRITE> &"
},
{
"name": "dataContainer",
"type": "int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vAllocImpl",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::TVecId<vtype, core::V_WRITE>"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vReallocImpl",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::TVecId<vtype, core::V_WRITE>"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vFreeImpl",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::TVecId<vtype, core::V_WRITE>"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vInitImpl",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "vId",
"type": "core::TVecId<vtype, core::V_WRITE>"
},
{
"name": "vSrcId",
"type": "core::TVecId<vtype, core::V_READ>"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "getWriteOnlyAccessor",
"return_type": "int",
"params": [
{
"name": "v",
"type": "core::VecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "getWriteAccessor",
"return_type": "int",
"params": [
{
"name": "v",
"type": "core::VecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "getReadAccessor",
"return_type": "int",
"params": [
{
"name": "v",
"type": "core::ConstVecId"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "drawIndices",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "drawVectors",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "setVecIdProperties",
"return_type": "void",
"params": [
{
"name": "v",
"type": "core::TVecId<vtype, vaccess>"
},
{
"name": "properties",
"type": "const core::VecIdProperties &"
},
{
"name": "vec_d",
"type": "core::BaseData *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": true,
"access": "protected"
}
],
"description": "Represents the mechanical properties and state of an object in a simulation.",
"parameters": [
{
"name": "position",
"type": "VecCoord",
"default_value": "[0, 0, 0]",
"description": "The initial position coordinates for each particle or point."
},
{
"name": "velocity",
"type": "VecDeriv",
"default_value": "[0, 0, 0]",
"description": "The initial velocity vector for each particle or point."
},
{
"name": "force",
"type": "VecDeriv",
"default_value": "[0, 0, 0]",
"description": "The force applied to each particle or point. Used during integration."
},
{
"name": "externalForce",
"type": "VecDeriv",
"default_value": "[0, 0, 0]",
"description": "External forces to be accumulated into the main force vector."
},
{
"name": "reset_position",
"type": "VecCoord",
"default_value": "",
"description": "Restores the state of positions when using the ResetState event. If not set, no reset for position is performed."
},
{
"name": "reset_velocity",
"type": "VecDeriv",
"default_value": "",
"description": "Restores the state of velocities when using the ResetState event. If not set and velocity is not zero, a full clear of velocities is performed."
},
{
"name": "rest_position",
"type": "VecCoord",
"default_value": "[0, 0, 0]",
"description": "The rest position for each particle or point, used when applying transformations."
}
],
"returns": [],
"example": [
{
"code": "<MechanicalObject position='[1.0,2.34,0.5]' velocity='[-0.01, -0.01]' />",
"description": "A simple example of a MechanicalObject with specified positions and velocities."
}
],
"notes": "- The MechanicalObject component is essential for defining the mechanical properties and state of objects in Sofa simulations.\n- It can represent various types of physical entities like particles, rigid bodies, deformable objects, etc., depending on the context it's used in.\n- Position and velocity are required to simulate motion and interaction within a physics engine. The position attribute defines where each point is located, while velocity indicates how fast and in what direction these points are moving.\n- External forces can be applied via the externalForce field which gets accumulated into the main force vector during integration steps.\n- Rest positions (rest_position) help define the default or relaxed state of deformable objects.",
"maths": "The `MechanicalObject` class in the SOFA (Simulation Open Framework Architecture) framework represents the mechanical properties and state of an object within a simulation. It is a crucial component used to define the physical characteristics, such as positions, velocities, forces, and constraints, for each discrete element or point mass that constitutes the object being simulated.\n\n**Mathematical Representation:**\n\n1. **Positions (`x`):** The position vector \\( \textbf{x} = [x_0, x_1, ..., x_n]^T \\) where each component \\( x_i \\) represents the spatial location of a point in 3D space.\n\n2. **Velocities (`v`):** The velocity vector \\( \textbf{v} = [v_0, v_1, ..., v_n]^T \\), where each component \\( v_i \\) is the time derivative of the position vector for each point.\n\n3. **Forces (`f`):** The force vector \\( \textbf{f} = [f_0, f_1, ..., f_n]^T \\), representing external forces acting on each discrete element.\n\n4. **External Forces (`externalForces`):** External forces applied to the object are stored in a separate vector and accumulated into the total force during integration.\n\n5. **Rest Positions (`x0`):** The rest position vector \\( \textbf{x}_0 = [x_{0,0}, x_{1,0}, ..., x_{n,0}]^T \\) stores the initial or reference positions of each point in the object, used for calculating deformations and restoring forces.\n\n6. **Constraints:** Constraints are represented using matrices (e.g., Jacobian matrix `c`) to encode linear relationships between points that must be satisfied during simulation steps. Each row of this matrix corresponds to a constraint equation involving certain degrees of freedom (DOFs).\n\n**Physics Representation: Newton's Equations of Motion:**\n\nThe core physics behind the MechanicalObject can be derived from Newton’s second law:\n\\[ m \frac{d^2x}{dt^2} = F_{net}(t) \\]\nwhere \\( m \\) is mass, \\( x \\) is position, and \\( F_{net}(t) \\) includes both external forces (applied by the user or environment) and internal restoring forces due to material properties.\n\nIn discrete form within a time step \\( \triangle t \\), this becomes an iterative update rule for positions and velocities:\n\\[ v(t + \triangle t) = v(t) + \frac{\triangle t}{m} F_{net}(t) \\]\n\\[ x(t + \triangle t) = x(t) + v(t + \triangle t) * \triangle t \\]\n\n**Integration Schemes:**\nThe `vOp` method implements various vector operations, often used in integration schemes such as Euler or Runge-Kutta methods to update the states of the object over time. These operations handle accumulation of forces, addition of velocities, scaling by a factor (e.g., timestep), etc.\n\n**Visualization and Picking:**\nThe `draw` method is responsible for rendering the mechanical state visually in 3D space, while `pickParticles` enables selecting specific points based on their positions relative to an input ray, useful for interactive simulations where user interaction with objects is needed.\n",
"abstract": "The `MechanicalObject` component represents the mechanical state of an object in SOFA simulations, managing positions, velocities, forces, and constraints.",
"sheet": "# MechanicalObject\n\n## Overview\nThe `MechanicalObject` is a core component that encapsulates the mechanical properties and state of an object within a simulation. It handles positions (`x`), velocities (`v`), forces (`f`), rest positions (`x0`), external forces, constraints, and other related data fields.\n\n## Mathematical Model\nThe `MechanicalObject` class represents the mechanical state through several key vectors:\n- **Positions:** The position vector \\(\\mathbf{x} = [x_0, x_1, ..., x_n]^T\\), where each component \\(x_i\\) is a spatial location in 3D space.\n- **Velocities:** The velocity vector \\(\\mathbf{v} = [v_0, v_1, ..., v_n]^T\\), representing the time derivative of positions.\n- **Forces:** The force vector \\(\\mathbf{f} = [f_0, f_1, ..., f_n]^T\\) includes external forces acting on each discrete element.\n- **Rest Positions:** The rest position vector \\(\\mathbf{x}_0 = [x_{0,0}, x_{1,0}, ..., x_{n,0}]^T\\), storing initial positions for calculating deformations and restoring forces.\n\nNewton's second law is used to update the state over time:\n\\[ m \\frac{d^2x}{dt^2} = F_{net}(t) \\]\nIn discrete form within a timestep \\(\\Delta t\\), this becomes an iterative update rule for positions and velocities:\n\\[ v(t + \\Delta t) = v(t) + \\frac{\\Delta t}{m} F_{net}(t) \\]\n\\[ x(t + \\Delta t) = x(t) + v(t + \\Delta t) * \\Delta t \\]\n\n## Parameters and Data\nThe `MechanicalObject` exposes several significant data fields:\n- **x:** Position coordinates of the degrees of freedom (`VecCoord`).\n- **v:** Velocity coordinates of the degrees of freedom (`VecDeriv`).\n- **f:** Force vector of the degrees of freedom (`VecDeriv`).\n- **x0:** Rest position coordinates of the degrees of freedom (`VecCoord`).\n- **externalForces:** External forces vector of the degrees of freedom (`VecDeriv`).\n- **dx:** Derivative of positions (`VecDeriv`).\n- **xfree:** Free position coordinates of the degrees of freedom (`VecCoord`).\n- **vfree:** Free velocity coordinates of the degrees of freedom (`VecDeriv`).\n- **c:** Constraints applied to the degrees of freedom (`MatrixDeriv`).\n- **m:** Mapping Jacobian applied to the degrees of freedom (`MatrixDeriv`).\n- **reset_position:** Reset position coordinates of the degrees of freedom (`VecCoord`).\n- **reset_velocity:** Reset velocity coordinates of the degrees of freedom (`VecDeriv`).\n- **restScale:** Optional scaling of rest positions (default = 1.0).\n- **useTopology:** Whether to rely on active topology for initialization.\n- **showObject:** Show object visualization (default=false).\n- **showIndices:** Show indices (default=false).\n- **showVectors:** Show velocity vectors (default=false).\n- **drawMode:** Drawing mode for vectors and DOFs (default=0).\n- **showColor:** Color for object display.\n- **translation:** Translation of the DOFs (`type::Vec3`).\n- **rotation:** Rotation of the DOFs (`type::Vec3`).\n- **scale:** Scale of the DOFs in 3 dimensions (`type::Vec3`).\n\n## Dependencies and Connections\nThe `MechanicalObject` typically requires a link to a topology component (`BaseMeshTopology`) for defining the structure and connectivity of the object. It interacts with other components such as force fields, constraints, and solvers to update its state during simulation.\n"
}