Skip to content

TransformPosition

This component belongs to the category of Engines. The TransformPosition engine transforms the positions of one DataFields into new positions after applying a transformation. This transformation can be either:

  • Projection on a plane (plane defined by an origin and a normal vector)
  • Translation, rotation, scale and some combinations of translation rotation and scale

Transform position of 3d points.

Vec3d

Templates:

  • Vec3d

Target: Sofa.Component.Engine.Transform

namespace: sofa::component::engine::transform

parents:

  • DataEngine

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the object belongs to
bbox this object bounding box
componentState The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). Undefined
listening if true, handle the events, otherwise ignore the events 0
method transformation method either translation or scale or rotation or random or projectOnPlane
seedValue the seed value for the random generator 0
maxRandomDisplacement the maximum displacement around initial position for the random transformation 1
filename filename of an affine matrix. Supported extensions are: .trm, .tfm, .xfm and .txt(read as .xfm)
Inputs
origin A 3d point on the plane/Center of the scale
input_position input array of 3d points
normal plane normal
translation translation vector
rotation rotation vector
scale scale factor 1 1 1
matrix 4x4 affine matrix [1 0 0 0,0 1 0 0,0 0 1 0,0 0 0 1]
fixedIndices Indices of the entries that are not transformed
Outputs
output_position output array of 3d points projected on a plane
Visualization
drawInput Draw input points 0
drawOutput Draw output points 0
pointSize Point size 1
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject

Examples

TransformPosition.scn

<Node name="root" gravity="0 0 -9.81" dt="0.05">
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.Engine.Transform"/> <!-- Needed to use components [TransformPosition] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [BarycentricMapping] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.MechanicalLoad"/> <!-- Needed to use components [PlaneForceField] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.SolidMechanics.FEM.Elastic"/> <!-- Needed to use components [HexahedronFEMForceField] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [SparseGridTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

    <DefaultAnimationLoop/>
    <VisualStyle displayFlags="showVisual showBehaviorModels" />
    <CollisionPipeline name="DefaultCollisionPipeline" verbose="0" draw="0" depth="6" />
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <MinProximityIntersection name="Proximity" alarmDistance="3" contactDistance="2" />
    <CollisionResponse name="Response" response="PenalityContactForceField" />
    <Node name="Object" gravity="0 -9.81 0">
        <EulerImplicitSolver name="Implicit Euler Solver"  rayleighStiffness="0.1" rayleighMass="0.1" />
        <CGLinearSolver  name="Conjugate Gradient" tolerance="1e-05" threshold="1e-05" iterations="5"/>
        <SparseGridTopology name="grid" fileTopology="mesh/dragon.obj" n="7 6 5" />
        <TransformPosition name="transfo" method="fromFile" filename="transfo.tfm" input_position="@grid.position"/>
        <MechanicalObject  name="Particles" restScale="1" position="@transfo.output_position" />
        <UniformMass  name="Mass" totalMass="1.0"/>
        <PlaneForceField  name="Plane" normal="0 0 1" d="-10" />
        <HexahedronFEMForceField  name="FEM" youngModulus="200" poissonRatio="0.45"/>
        <Node name="VisualNode" gravity="0 -9.81 0">
            <MeshOBJLoader name="meshLoader_0" filename="mesh/dragon.obj" handleSeams="1" />
            <OglModel name="Objective" src="@meshLoader_0" />
            <BarycentricMapping  name="Visual Mapping" output="@Objective"  />
        </Node>
    </Node>
    <Node name="Floor">
        <MeshOBJLoader name="ObjLoader" filename="mesh/floor.obj" />
        <OglModel name="VisualModel" src="@./ObjLoader" translation="0 0 -9" rotation="90 0 0"/>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', gravity="0 0 -9.81", dt="0.05")

   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
   root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
   root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Transform")
   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.Linear")
   root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   root.addObject('RequiredPlugin', name="Sofa.Component.MechanicalLoad")
   root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   root.addObject('RequiredPlugin', name="Sofa.Component.SolidMechanics.FEM.Elastic")
   root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
   root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('DefaultAnimationLoop', )
   root.addObject('VisualStyle', displayFlags="showVisual showBehaviorModels")
   root.addObject('CollisionPipeline', name="DefaultCollisionPipeline", verbose="0", draw="0", depth="6")
   root.addObject('BruteForceBroadPhase', )
   root.addObject('BVHNarrowPhase', )
   root.addObject('MinProximityIntersection', name="Proximity", alarmDistance="3", contactDistance="2")
   root.addObject('CollisionResponse', name="Response", response="PenalityContactForceField")

   object = root.addChild('Object', gravity="0 -9.81 0")

   object.addObject('EulerImplicitSolver', name="Implicit Euler Solver", rayleighStiffness="0.1", rayleighMass="0.1")
   object.addObject('CGLinearSolver', name="Conjugate Gradient", tolerance="1e-05", threshold="1e-05", iterations="5")
   object.addObject('SparseGridTopology', name="grid", fileTopology="mesh/dragon.obj", n="7 6 5")
   object.addObject('TransformPosition', name="transfo", method="fromFile", filename="transfo.tfm", input_position="@grid.position")
   object.addObject('MechanicalObject', name="Particles", restScale="1", position="@transfo.output_position")
   object.addObject('UniformMass', name="Mass", totalMass="1.0")
   object.addObject('PlaneForceField', name="Plane", normal="0 0 1", d="-10")
   object.addObject('HexahedronFEMForceField', name="FEM", youngModulus="200", poissonRatio="0.45")

   visual_node = Object.addChild('VisualNode', gravity="0 -9.81 0")

   visual_node.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/dragon.obj", handleSeams="1")
   visual_node.addObject('OglModel', name="Objective", src="@meshLoader_0")
   visual_node.addObject('BarycentricMapping', name="Visual Mapping", output="@Objective")

   floor = root.addChild('Floor')

   floor.addObject('MeshOBJLoader', name="ObjLoader", filename="mesh/floor.obj")
   floor.addObject('OglModel', name="VisualModel", src="@./ObjLoader", translation="0 0 -9", rotation="90 0 0")