About PositionBasedDynamics

PositionBasedDynamics is an open-source library which enables the physically-based simulation of mechanical effects. In the last years position-based simulation methods have become popular in the graphics community. In contrast to classical simulation approaches these methods compute the position changes in each simulation step directly, based on the solution of a quasi-static problem. Therefore, position-based approaches are fast, stable and controllable which make them well-suited for use in interactive environments. However, these methods are generally not as accurate as force-based methods but still provide visual plausibility. Hence, the main application areas of position-based simulation are virtual reality, computer games and special effects in movies and commercials.

Main features

  • Physically-based simulation with position-based constraint handling.

  • Simple interface

  • Demos

  • Library is free even for commercial applications.

  • Collision detection based on cubic signed distance fields

  • Library supports many constraints:

    • Elastic rods:

      • bend-twist constraint

      • stretch-shear constraint

      • Cosserat constraint

    • Deformable solids:

      • point-point distance constraint (PBD & XPBD)

      • point-edge distance constraint

      • point-triangle distance constraint

      • edge-edge distance constraint

      • dihedral bending constraint

      • isometric bending constraint (PBD & XPBD)

      • volume constraint (PBD & XPBD)

      • shape matching

      • FEM-based PBD (2D & 3D)

      • strain-based dynamics (2D & 3D)

    • Fluids:

      • position-based fluids

    • Rigid bodies:

      • contact constraints

      • ball joint

      • ball-on-line-joint

      • hinge joint

      • target angle motor hinge joint

      • target velocity motor hinge joint

      • universal joint

      • slider joint

      • target position motor slider joint

      • target velocity motor slider joint

      • ball joint between rigid body and particle

      • distance joint

      • damper joint

      • implicit spring

    • Generic constraints

License

The MIT License (MIT)

Copyright (c) 2015-present, PositionBasedDynamics contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Getting started

This page should give you a short overview of PositionBasedDynamics.

Demos

After building the PositionBasedDynamics library, there are several demos which can by executed in the binary folder. To execute a demo, you can call, e.g.:

cd ../bin
./BarDemo

SceneLoaderDemo

This special demo reads a PositionBasedDynamics scene file and performs a simulation of the scene. You can start this simulator, e.g., by calling:

cd ../bin
./SceneLoaderDemo ../data/Scenes/CarScene.json

The scene file format is explained here.

Hotkeys

  • Space: pause/contiunue simulation

  • r: reset simulation

  • w: wireframe rendering of meshes

  • ESC: exit

Python bindings

PositionBasedDynamics implements bindings for python using pybind11. See the getting started guide.

Impatient installation guide

In order to install, simply clone the repository and run pip install on the repository. It is recommended, that you set up a virtual environment for this, because cache files will be stored in the directory of the python installation along with models and scene files.

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git
pip install PositionBasedDynamics/

PositionBasedDynamics Scene Files

A PositionBasedDynamics scene file is a json file which can contain the following blocks:

  • Name

  • Camera parameters

  • Simulation

  • TriangleModels

  • TetModels

  • RigidBodies

  • Joints

Name

Each scene has a name.

Example code:

"Name": "ExampleScene"

Camera parameters

Here parameters for the initial camera position can be defined.

  • cameraPosition (vec3): Initial position of the camera.

  • cameraLookat (vec3): Lookat point of the camera.

Simulation

This part contains the general settings of the simulation.

Example code:

"Simulation": 
	{
		"pause": false,
		"pauseAt": 10.0,
    "timeStepSize": 0.01,
		"numberOfStepsPerRenderUpdate": 4,
		"subSteps": 5,
		"maxIterations" : 1,
		"maxIterationsV" : 5,
		"velocityUpdateMethod" : 0,
		"contactTolerance": 0.0,
		"tetModelSimulationMethod": 2,
		"clothSimulationMethod": 2,
		"clothBendingMethod": 2,
		"contactStiffnessRigidBody" : 1.0,
		"contactStiffnessParticleRigidBody": 100.0,
		"cloth_stiffness": 1.0,
		"cloth_bendingStiffness": 0.005,
		"cloth_xxStiffness": 1.0,
		"cloth_yyStiffness": 1.0,
		"cloth_xyStiffness": 1.0,
		"cloth_xyPoissonRatio": 0.3,
		"cloth_yxPoissonRatio": 0.3,
		"cloth_normalizeStretch": 0,
		"cloth_normalizeShear": 0, 
		"solid_stiffness": 1.0,
		"solid_poissonRatio": 0.2,
		"solid_normalizeStretch": 0,
		"solid_normalizeShear": 0
	}

General:

  • pause (bool): Pause simulation at beginning (default: true).

  • pauseAt (float): Pause simulation at the given time. When the value is negative, the simulation is not paused (default: -1).

Simulation:

  • timeStepSize (float): The time step size used for the time integration. (default: 0.005).

  • gravitation (vec3): Vector to define the gravitational acceleration (default: [0,-9.81,0]).

  • velocityUpdateMethod (int) (default: 1):

    • 0: First Order Update

    • 1: Second Order Update

  • maxIterations (int): Number of iterations of the PBD solver (default: 1).

  • maxIterationsV (int): Number of iterations of the velocity solver (default: 5).

  • subSteps (int): Number of sub steps of the PBD solver (default: 5).

Cloth Simulation

  • clothSimulationMethod (int): Cloth simulation method (default: 2):

    • 0: None

      • 1: Distance constraints

      • 2: FEM based PBD

      • 3: Strain based dynamics

      • 4: XPBD distance constraints

  • clothBendingMethod (int): Cloth bending method (default: 2):

  • 0: None

  • 1: Dihedral angle

  • 2: Isometric bending

  • 3: Isometric bending (XPBD)

  • cloth_stiffness (float): Stiffness coefficient for the distance constraints (if there are any in the simulation) (default: 1.0).

  • cloth_xxStiffness (float): XX stiffness of orthotropic cloth models (only used for FEM based PBD) (default: 1.0).

  • cloth_yyStiffness (float): YY stiffness of orthotropic cloth models (only used for FEM based PBD) (default: 1.0).

  • cloth_xyPoissonRatio (float): XY stiffness of orthotropic cloth models (only used for FEM based PBD) (default: 1.0).

  • cloth_xyStiffness (float): XY Poisson ratio of orthotropic cloth models (only used for FEM based PBD) (default: 0.3).

  • cloth_yyStiffness (float): YX Poisson ratio of orthotropic cloth models (only used for FEM based PBD) (default: 0.3).

  • cloth_bendingStiffness (float): Bending stiffness of cloth models (default: 0.01).

  • cloth_normalizeStretch (bool): Normalize stretch (only used for strain based dynamics) (default: false).

  • cloth_normalizeShear (bool): Normalize shear (only used for strain based dynamics) (default: false).

Solid Simulation

  • solidSimulationMethod (int): Solid simulation method (default: 2):

    • 0: None

      • 1: Distance & volume constraints

      • 2: FEM based PBD

    • 3: FEM based XPBD

      • 4: Strain based dynamics (no inversion handling)

    • 5: Shape Matching (no inversion handling)

      • 6: XPBD distance constraints

  • solid_stiffness (float): Stiffness/Young’s modulus of solid models (default: 1.0).

  • solid_poissonRatio (float): Poisson ratio of solid models (only used for FEM based PBD/XPBD) (default: 0.3).

  • solid_volumeStiffness (float): Stiffness coefficient for the volume constraints (if there are any in the simulation) (default: 1.0).

  • solid_normalizeStretch (bool): Normalize stretch (only used for strain based dynamics) (default: false).

  • solid_normalizeShear (bool): Normalize shear (only used for strain based dynamics) (default: false).

Rod Simulation

  • rod_stretchingStiffness (float): Stretching stiffness/Youngs modulus of elastic rod models (default: 1.0).

  • rod_shearingStiffnessX (float): X shearing stiffness of elastic rod models (default: 1.0).

  • rod_shearingStiffnessY (float): Y Shearing stiffness of elastic rod models (default: 1.0).

  • rod_bendingStiffnessX (float): X bending stiffness of elastic rod models (default: 0.5).

  • rod_bendingStiffnessY (float): Y bending stiffness of elastic rod models (default: 0.5).

  • rod_twistingStiffness (float): Twisting stiffness of elastic rod models (default: 0.5).

Contact Handling

  • contactTolerance (float): Tolerance of the collision detection (default: 0.01).

  • contactStiffnessRigidBody (float): Stiffness coefficient for rigid-rigid contact resolution (default: 1.0).

  • contactStiffnessParticleRigidBody (float): Stiffness coefficient for particle-rigid contact resolution (default: 100.0).

Visualization:

  • numberOfStepsPerRenderUpdate (int): Number of simulation steps per rendered frame

  • renderTets (bool): Render tet models (default: false).

  • renderTets0 (bool): Render initial state of tet models (default: false).

  • renderContacts (bool): Render contact points and normals (default: false).

  • renderAABB (bool): Render axis-aligned bounding boxes (default: false).

  • renderSDF (bool): Render signed distance fields (SDFs) (default: false).

  • renderBVH (int): Render bounding volume hierarchies (BVHs) until given depth (default: -1).

  • renderBVHDepthTets (int): Render bounding volume hierarchies (BVHs) of tets until given depth (default: -1).

Export

  • exportOBJ (bool): Enable/disable OBJ file export (default: false).

  • exportPLY (bool): Enable/disable PLY file export (default: false).

  • exportFPS (float): Frame rate of file export (default: 25).

Triangle Models

The simulation library supports triangle models to simulate cloth. In the following example a triangle mesh is loaded to simulate a quadratic piece of cloth where two particles are fixed.

Example code:

"TriangleModels": [
  {
    "id": 0,
    "geometryFile": "../models/plane_50x50.obj",
    "translation": [5,8,0],
    "rotationAxis": [1, 0, 0],
    "rotationAngle": 0.0,
    "scale": [10, 10, 10],
    "staticParticles": [0,49],
    "restitution" : 0.1,
    "friction" : 0.1
  }
]
  • id (int): ID of the triangle model (default: 0).

  • geometryFile (string): File path of a triangle mesh file which should be loaded (default: “”).

  • translation (vec3): Translation vector of the triangle model (default: [0,0,0]).

  • scale (vec3): Scaling vector of the triangle model (default: [1,1,1]).

  • rotationAxis (vec3): Axis used to rotate the triangle model after loading (default: [0,0,0]).

  • rotationAngle (float): Rotation angle for the initial rotation of the triangle model (default: 0.0).

  • staticParticles (array): List of particle indices to define static particles that do not move during the simulation (default: []).

  • restitution (float): Resitution coefficient of the triangle model (default: 0.1).

  • friction (float): Friction coefficient of the triangle model (default: 0.2).

Tet Models

The simulation library supports tet models to simulate deformable solids. In the following example a tet mesh is loaded to simulate an elastic Armadillo model.

Example code:

"TetModels": [
  {
    "id": 0,
    "nodeFile": "../models/armadillo_4k.node",
    "eleFile": "../models/armadillo_4k.ele",
    "visFile": "../models/armadillo.obj",
    "translation": [0,8,0],
    "rotationAxis": [1, 0, 0],
    "rotationAngle": 1.57,
    "scale": [2, 2, 2],
    "staticParticles": [],
    "restitution" : 0.1,
    "friction" : 0.1,
    "collisionObjectType": 5,
    "collisionObjectFileName": "",
    "collisionObjectScale": [
        1,
        1,
        1
    ],
    "testMesh": 1
  }
]
  • id (int): ID of the tet model (default: 0).

  • nodeFile (string): File path of a tet nodes file which should be loaded. Such a tet file can be generated from a surface mesh using TetGen (default: “”).

  • eleFile (string): File path of a tet elements file which should be loaded. Such a tet file can be generated from a surface mesh using TetGen (default: “”).

  • visFile (string): File path of a visualization triangle mesh file which should be loaded. This mesh is used only for the visualization and the mesh export (default: “”).

  • translation (vec3): Translation vector of the tet model (default: [0,0,0]).

  • scale (vec3): Scaling vector of the tet model (default: [1,1,1]).

  • rotationAxis (vec3): Axis used to rotate the tet model after loading (default: [0,0,0]).

  • rotationAngle (float): Rotation angle for the initial rotation of the tet model (default: 0.0).

  • staticParticles (array): List of particle indices to define static particles that do not move during the simulation (default: []).

  • restitution (float): Resitution coefficient of the tet model (default: 0.1).

  • friction (float): Friction coefficient of the tet model (default: 0.2).

  • collisionObjectType (int): The PBD simulator uses a collision detection based on signed distance functions or signed distance fields (SDF). If simple shapes like spheres and boxes are simulated an analytic signed distance function can be used for the detection. For arbitrary geometries a signed distance field is precomputed. Therefore, the correct type of geometry has to be chosen here (default: 0):

    • 0: no collision object

    • 1: sphere

    • 2: box

    • 3: cylinder

    • 4: torus

    • 5: Signed Distance Field (SDF)

    • 6: hollow sphere

    • 7: hollow box

  • collisionObjectFileName (string): File path of a geometry file which contains the collision geometry of the solid. This is used to generate an SDF if collisionObjectType 5 is chosen (default: “”).

  • testMesh (bool): Defines if the vertices of the solid geometry are tested against the signed distance fields of other objects for collisions (default: true).

  • collisionObjectScale (vec3): Scaling vector of the collision object of the solid. In most cases this should be the same value as for “scale” (default: [1,1,1]).

  • invertSDF (bool): Invert the signed distance field, flips inside/outside (default: false)

  • thicknessSDF (float): Additional thickness of a signed distance field. The geometry is extended by this distance (default: 0.1).

  • resolutionSDF (vec3): Resolution of the signed distance field. Using a higher resolution means that the original geometry can be represented more accurately. Since the field is precomputed, a higher resolution does not directly affect the simulation performance (defaut: [10,10,10]).

RigidBodies

Here, the static and dynamic rigid bodies are defined for the simulation. If you want to connect two rigid bodies by a joint, make sure to give them an ID. The ID can then be usd for the joint definition.

Example code:

"RigidBodies": [
    {
        "angularVelocity": [0, 0, 0],
        "collisionObjectFileName": "",
        "collisionObjectScale": [500, 1, 500],
        "collisionObjectType": 2,
        "density": 500,
        "friction": 0.3,
        "geometryFile": "../models/cube.obj",
        "flatShading": true,
        "id": 1,
        "isDynamic": false,
        "restitution": 0.5,
        "rotationAngle": 0.0,
        "rotationAxis": [1, 0, 0],
        "scale": [500, 1, 500],
        "testMesh": 1,
        "translation": [0, -0.5, 0],
        "velocity": [0, 0, 0]
    }
]
  • id (int): ID of the rigid body which is required for joint definitions (default: 0).

  • translation (vec3): Translation vector of the rigid body (default: [0,0,0]).

  • scale (vec3): Scaling vector of the rigid body (default: [1,1,1]).

  • rotationAxis (vec3): Axis used to rotate the rigid body after loading (default: [0,0,0]).

  • rotationAngle (float): Rotation angle for the initial rotation of the rigid body (default: 0.0).

  • isDynamic (bool): Defines if the body is static or dynamic.

  • density (float): Density of the rigid body (default: 1.0).

  • flatShading (bool): Enables/disables flat shading (default: false).

  • velocity (vec3): Initial velocity of the rigid body (default: [0,0,0]).

  • angularVelocity (vec3): Initial angular velocity of the rigid body (default: [0,0,0]).

  • restitution (float): Resitution coefficient of the rigid body (default: 0.6).

  • friction (float): Friction coefficient of the rigid body (default: 0.2).

  • collisionObjectType (int): The PBD simulator uses a collision detection based on signed distance functions or signed distance fields (SDF). If simple shapes like spheres and boxes are simulated an analytic signed distance function can be used for the detection. For arbitrary geometries a signed distance field is precomputed. Therefore, the correct type of geometry has to be chosen here (default: 0):

    • 0: no collision object

    • 1: sphere

    • 2: box

    • 3: cylinder

    • 4: torus

    • 5: Signed Distance Field (SDF)

    • 6: hollow sphere

    • 7: hollow box

  • collisionObjectFileName (string): File path of a geometry file which contains the collision geometry of the rigid body. This is used to generate an SDF if collisionObjectType 5 is chosen (default: “”).

  • testMesh (bool): Defines if the vertices of the rigid body geometry are tested against the signed distance fields of other objects for collisions (default: true).

  • collisionObjectScale (vec3): Scaling vector of the collision object of the rigid body. In most cases this should be the same value as for “scale” (default: [1,1,1]).

  • invertSDF (bool): Invert the signed distance field, flips inside/outside (default: false)

  • thicknessSDF (float): Additional thickness of a signed distance field. The geometry is extended by this distance (default: 0.1).

  • resolutionSDF (vec3): Resolution of the signed distance field. Using a higher resolution means that the original geometry can be represented more accurately. Since the field is precomputed, a higher resolution does not directly affect the simulation performance (defaut: [10,10,10]).

Joints

BallJoints

This joint links two rigid bodies in a common point so that both can rotate around this point.

Example code:

"BallJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Position of the common connector point.

BallOnLineJoints

This joint is like a ball joint that can move on a given line.

Example code:

"BallOnLineJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0],
      "axis": [1,0,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Point on the line.

  • axis (vec3): Direction vector of the line.

HingeJoints

This joint links two rigid bodies so that both can rotate around a common axis.

Example code:

"HingeJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0],
      "axis": [1,0,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Point on the rotation axis.

  • axis (vec3): Direction vector of the rotation axis.

UniversalJoints

This joint links two rigid bodies so that both can rotate around two common axes.

Example code:

"HingeJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0],
      "axis1": [1,0,0],
      "axis2": [0,1,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Point on both rotation axes.

  • axis1 (vec3): Direction vector of the first rotation axis.

  • axis2 (vec3): Direction vector of the second rotation axis.

SliderJoints

This joint links two rigid bodies so that they can slide on a common axis.

Example code:

"SliderJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "axis": [1,0,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • axis (vec3): Direction vector of the slider axis.

RigidBodyParticleBallJoints

This joint links a rigid body and a particle by a ball joint so that the rigid body can rotate around the particle.

Example code:

"RigidBodyParticleBallJoints": [
  {
      "rbID": 1,
      "particleID": 2
  }
]
  • rbID (int): ID of the rigid body of the joint.

  • particleID (int): ID of the particle of the joint.

  • position (vec3): Position of the common connector point.

RigidBodySprings

This joint links two rigid bodies by a spring.

Example code:

"RigidBodySprings": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position1": [1,0,0],
      "position2": [2,0,0],
      "stiffness": 10000.0
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position1 (vec3): Position of connector point in body 1.

  • position2 (vec3): Position of connector point in body 2.

  • stiffness (float): Stiffness of the spring.

DistanceJoints

This joint links two rigid bodies by a distance constraint so that the connector points in both bodies have a constant distance during the simulation.

Example code:

"DistanceJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position1": [1,0,0],
      "position2": [2,0,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position1 (vec3): Position of connector point in body 1.

  • position2 (vec3): Position of connector point in body 2.

DamperJoints

This joint links two rigid bodies so that they can slide on a common axis while a spring force is also acting on this axis.

Example code:

"DamperJoints": [
  {
      "bodyID1": 2,
      "bodyID2": 3,
      "axis": [0,1,0],
      "stiffness": 500000.0
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • axis (vec3): Direction vector of the slider axis.

  • stiffness (float): Stiffness of the spring.

TargetAngleMotorHingeJoints

This joint links two rigid bodies by a angular motor so that both can rotate around a common axis. Moreover, a target angle can be defined.

Example code:

"TargetAngleMotorHingeJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0],
      "axis": [1,0,0],
      "repeatSequence": true,
      "targetSequence": [0,0,2,0.707,8,0.707,12,-0.707,18,-0.707,20,0]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Point on the rotation axis.

  • axis (vec3): Direction vector of the rotation axis.

  • target (float): Target angle of the motor. Either you can define a target angle or a target angle sequence. If both are defined, only the target angle is considered.

  • targetSequence (array): This array defines pairs (time,target angle). So in the example above at time 0 the target angle is 0, at time 2 the angle is 0.707 and so on. In this way a sequence of angles for an animation can be defined (see also the CarScene.json example).

  • repeatSequence (bool): Defines if the targetSequence is repeated in a loop.

TargetVelocityMotorHingeJoints

This joint links two rigid bodies by a angular motor so that both can rotate around a common axis. Moreover, a target angular velocity can be defined.

Example code:

"TargetVelocityMotorHingeJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "position": [0,1,0],
      "axis": [1,0,0],
      "repeatSequence": false,
      "targetSequence": [0,0,2,0.5,3,2]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • position (vec3): Point on the rotation axis.

  • axis (vec3): Direction vector of the rotation axis.

  • target (float): Target angular velocity of the motor. Either you can define a target velocity or a target velocity sequence. If both are defined, only the target velocity is considered.

  • targetSequence (array): This array defines pairs (time,target angular velocity). So in the example above at time 0 the target velocity is 0, at time 2 the angle is 0.5 and so on. In this way a sequence of velocities for an animation can be defined.

  • repeatSequence (bool): Defines if the targetSequence is repeated in a loop.

TargetPositionMotorSliderJoints

This joint links two rigid bodies by a slider motor so that both can slide on a common axis. Moreover, a target position can be defined.

Example code:

"TargetPositionMotorSliderJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "axis": [1,0,0],
      "repeatSequence": true,
      "targetSequence": [0,0,2,0.5,3,2]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • axis (vec3): Direction vector of the slider axis.

  • target (float): Target position of the motor. Either you can define a target position or a target position sequence. If both are defined, only the target position is considered.

  • targetSequence (array): This array defines pairs (time,target position). So in the example above at time 0 the target position is 0, at time 2 the position is 0.5 and so on. In this way a sequence of positions for an animation can be defined.

  • repeatSequence (bool): Defines if the targetSequence is repeated in a loop.

TargetVelocityMotorSliderJoints

This joint links two rigid bodies by a slider motor so that both can slide on a common axis. Moreover, a target velocity can be defined.

Example code:

"TargetPositionMotorSliderJoints": [
  {
      "bodyID1": 1,
      "bodyID2": 2,
      "axis": [1,0,0],
      "repeatSequence": true,
      "targetSequence": [0,0,2,0.5,3,2]
  }
]
  • bodyID1 (int): ID of the first rigid body of the joint.

  • bodyID2 (int): ID of the second rigid body of the joint.

  • axis (vec3): Direction vector of the slider axis.

  • target (float): Target velocity of the motor. Either you can define a target velocity or a target velocity sequence. If both are defined, only the target velocity is considered.

  • targetSequence (array): This array defines pairs (time,target velocity). So in the example above at time 0 the target velocity is 0, at time 2 the velocity is 0.5 and so on. In this way a sequence of velocities for an animation can be defined.

  • repeatSequence (bool): Defines if the targetSequence is repeated in a loop.

Installation Instructions - Linux

Ubuntu Fresh Install

Installation List

sudo apt install git cmake xorg-dev freeglut3-dev build-essential

Python Bindings

If you plan on using the python bindings by specifying -DUSE_PYTHON_BINDINGS=On, then you should also have a working python installation in your path. This installs an additional tool pipx, which allows the installation of packages as executables in virtualized environments.

sudo apt install python3-dev python3-pip python3-venv
python3 -m pip install pipx
python3 -m pipx ensurepath

Alternatively to this you may also install other Python Distributions such as Anaconda (personal preference).

Building Instructions

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git
cd PositionBasedDynamics
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHON_BINDINGS=<On|Off> ..
make -j 4

Run Executable

Run any demo in the folder bin, e.g.:

cd ../bin
./SceneLoaderDemo ../data/Scenes/CarScene.json

On some systems it may be necessary to define an OpenGL override like so

cd ../bin
MESA_GL_VERSION_OVERRIDE=3.3 ./SceneLoaderDemo ../data/Scenes/CarScene.json

The command loads the selected scene. To start the simulation disable the pause mode by clicking the checkbox or pressing [Space]. More hotkeys are listed here.

Using Bindings

Assuming that the python bindings were generated in the default location Project Root/build/lib/pypbd.cpython-38-x86_64-linux-gnu.so, you can use the bindings by adding this path to sys.path within your python script, or by calling your scripts within the directory containing the .so file. You can test that the bindings work using the following command.

cd lib
python3 -c "import pypbd"

Installing Bindings

If you followed the above instructions for building PositionBasedDynamics using CMake and generated the python bindings, then these commands should work automatically.

Note: You don’t have to clone the repository again. This only shows, that the command should be run in the project root directory. It is also recommended, that you create and activate a virtual environment before installing, so that your base python installation is not affected by any new generated files.

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git
cd PositionBasedDynamics
python setup.py bdist_wheel
pip install build/dist/*.whl

If you specified any additional CMake variables in the form of -DVAR_NAME=Value, you can just append them after bdist_wheel

Alternatively you may also run the following command, which essentially combines all of the above commands into a single command.

pip install git+https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git

Drawbacks: You lose the ability for incremental rebuilds, i.e. if you want to modify the source code and build the bindings anew, you would have to build the entire project every time.

Installation Instructions - Windows

Visual Studio

Dependencies

To build PositionBasedDynamics on Windows you need to install CMake and git.

Python Bindings

If you plan on using the python bindings by specifying -DUSE_PYTHON_BINDINGS=On, then you should also have a working Python installation in your path. Moreover, you require the Python Package Installer (pip).

Building Instructions

First, clone the repository by

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git

Then run cmake-gui and set “Where is the source code:” to the [PositionBasedDynamics-dir] and “Where to build the binaries:” to [PositionBasedDynamics-dir]/build.

Now run Configure and select the correct Visual Studio version. Ensure that you choose a x64 build on a 64bit system. Finally, run Generate and open the project. Now you can build the project in Visual Studio. Note that you have to select the “Release” build, if you want to have an optimized executable.

Run Executable

Execute any demo in the folder “bin” to start the simulator. Alternatively, you can start the simulation by loading a json scene file in the command line:

./SceneLoaderDemo ../data/Scenes/CarScene.json

The command loads the selected scene. To start the simulation disable the pause mode by clicking the checkbox or pressing [Space]. More hotkeys are listed here.

Using Bindings

Assuming that the python bindings were generated in the default location [PositionBasedDynamics-dir]/build/lib/pypbd.cp37-win_amd64.pyd, you can use the bindings by adding this path to sys.path within your python script, or by calling your scripts within the directory containing the .pyd file. You can test that the bindings work using the following command.

cd lib
python3 -c "import pypbd"

Installing Bindings

If you followed the above instructions for building PositionBasedDynamics using CMake and generated the python bindings, then these commands should work automatically.

Note: You don’t have to clone the repository again. This only shows, that the command should be run in the project root directory. It is also recommended, that you create and activate a virtual environment before installing, so that your base python installation is not affected by any new generated files.

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git
cd PositionBasedDynamics
python setup.py bdist_wheel
pip install build/dist/pyPBD-2.1.0-cp38-cp38-win_amd64.whl

If you specified any additional CMake variables in the form of -DVAR_NAME=Value, you can just append them after bdist_wheel

Alternatively you may also run the following command, which essentially combines all of the above commands into a single command.

pip install git+https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git

Drawbacks: You lose the ability for incremental rebuilds, i.e. if you want to modify the source code and build the bindings anew, you would have to build the entire project every time.

CMake Options

This page should give you a short overview over the CMake options of PositionBasedDynamics.

USE_DOUBLE_PRECISION

If this flag is enabled, then all computations with floating point values are performed using double precision (double). Otherwise single precision (float) is used.

USE_OpenMP

Enable the OpenMP parallelization which lets the simulation run in parallel on all available cores of the CPU.

USE_PYTHON_BINDINGS

Generate a shared library object which can be imported into python scripts and exposes C++ functionality to the python interpreter. Default:On Options:<On|Off>

pyPBD

Python bindings for the PositionBasedDynamics library

Requirements

Currently the generation of python bindings is only tested on

  • Linux Debian, gcc 8.3, Python 3.7/3.8 (Anaconda), CMake 3.13

  • Windows 10, Visual Studio 15/17/19, Python 3.7/3.8 (Anaconda), CMake 3.13

Note that the compiler, the python installation as well as cmake have to be available from the command line for the installation process to work. MacOS builds should work but have not been tested.

Installation

In order to install it is advised that you create a new virtual environment so that any faults during installation can not mess up your python installation. This is done as follows for

conda

conda create --name venv python=3.7
conda activate venv

virtualenv

python3 -m virtualenv venv --python=python3.7
source venv/bin/activate

Now you can clone the repository by

git clone https://github.com/InteractiveComputerGraphics/PositionBasedDynamics.git

And finally you should be able to install PositionBasedDynamics using pip. The trailing slash is important otherwise pip will try to download the package, which is not supported yet at least. Also note, that pip install PositionBasedDynamics should be called from one directory above the cloned source directory and not within the directory itself.

pip install PositionBasedDynamics/

While pip install is useful if PositionBasedDynamics should only be installed once, for development purposes it might be more sensible to build differently. Change into the PositionBasedDynamics directory and build a python wheel file as follows

cd PositionBasedDynamics
python setup.py bdist_wheel
pip install -I build/dist/*.whl

When building a new version of PositionBasedDynamics simply run these commands again and the installation will be updated. The compile times will be lower, because the build files from previous installations remain. If you are getting compile errors please try to compile the pypbd target of the CMake project separately.

Now check your installation by running

python -c "import pypbd"

Note: You may have to install numpy. Future releases may already contain numpy as a dependency.

pip install numpy

Examples

In the folder “pyPBD/examples” you can find several examples which use the Python interface.

Library API

Page Hierarchy

Class Hierarchy

File Hierarchy

Full API

Namespaces

Namespace Eigen

Namespace GenParam

Namespace PBD

Classes

Namespace PBD::PBD

Contents

Namespace std

Namespace Utilities

Classes and Structs

Struct CollisionDetection::CollisionObject

Nested Relationships

This struct is a nested type of Class CollisionDetection.

Inheritance Relationships
Derived Type
Struct Documentation
struct CollisionObject

Subclassed by PBD::CollisionDetection::CollisionObjectWithoutGeometry

Public Functions

inline virtual ~CollisionObject()
virtual int &getTypeId() const = 0

Public Members

AABB m_aabb
unsigned int m_bodyIndex
unsigned int m_bodyType

Public Static Attributes

static const unsigned int RigidBodyCollisionObjectType = 0
static const unsigned int TriangleModelCollisionObjectType = 1
static const unsigned int TetModelCollisionObjectType = 2

Struct CollisionDetection::CollisionObjectWithoutGeometry

Nested Relationships

This struct is a nested type of Class CollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct CollisionObjectWithoutGeometry : public PBD::CollisionDetection::CollisionObject

Public Functions

inline virtual int &getTypeId() const
inline virtual ~CollisionObjectWithoutGeometry()

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct CubicSDFCollisionDetection::CubicSDFCollisionObject

Nested Relationships

This struct is a nested type of Class CubicSDFCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct CubicSDFCollisionObject : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

CubicSDFCollisionObject()
virtual ~CubicSDFCollisionObject()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

std::string m_sdfFile
Vector3r m_scale
GridPtr m_sdf

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::ContactData

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Struct Documentation
struct ContactData

Public Members

char m_type
unsigned int m_index1
unsigned int m_index2
Vector3r m_cp1
Vector3r m_cp2
Vector3r m_normal
Real m_dist
Real m_restitution
Real m_friction
unsigned int m_elementIndex1
unsigned int m_elementIndex2
Vector3r m_bary1
Vector3r m_bary2

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionBox

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionBox : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionBox()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector3r m_box

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionCylinder

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionCylinder : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionCylinder()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector2r m_dim

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionHollowBox

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionHollowBox : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionHollowBox()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector3r m_box
Real m_thickness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionHollowSphere

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionHollowSphere : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionHollowSphere()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Real m_radius
Real m_thickness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
  • public CollisionObject

Derived Types
Struct Documentation
struct DistanceFieldCollisionObject : public CollisionObject

Subclassed by PBD::CubicSDFCollisionDetection::CubicSDFCollisionObject, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionBox, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionCylinder, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionHollowBox, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionHollowSphere, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObjectWithoutGeometry, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionSphere, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionTorus

Public Functions

inline DistanceFieldCollisionObject()
inline virtual ~DistanceFieldCollisionObject()
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual void approximateNormal(const Eigen::Vector3d &x, const Real tolerance, Vector3r &n)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance) = 0
void initTetBVH(const Vector3r *vertices, const unsigned int numVertices, const unsigned int *indices, const unsigned int numTets, const Real tolerance)

Public Members

bool m_testMesh
Real m_invertSDF
PointCloudBSH m_bvh
TetMeshBSH m_bvhTets
TetMeshBSH m_bvhTets0

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionObjectWithoutGeometry

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionObjectWithoutGeometry : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionObjectWithoutGeometry()
inline virtual int &getTypeId() const
inline virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
inline virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionSphere

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionSphere : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionSphere()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Real m_radius

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct DistanceFieldCollisionDetection::DistanceFieldCollisionTorus

Nested Relationships

This struct is a nested type of Class DistanceFieldCollisionDetection.

Inheritance Relationships
Base Type
Struct Documentation
struct DistanceFieldCollisionTorus : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionTorus()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector2r m_radii

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Struct Interval

Struct Documentation
struct Interval

Public Members

int start
int end

Struct KDTree::Node

Nested Relationships

This struct is a nested type of Template Class KDTree.

Struct Documentation
struct Node

Public Functions

inline Node(unsigned int b_, unsigned int n_)
Node() = default
inline bool is_leaf() const

Public Members

std::array<int, 2> children
unsigned int begin
unsigned int n

Struct KDTree::QueueItem

Nested Relationships

This struct is a nested type of Template Class KDTree.

Struct Documentation
struct QueueItem

Public Members

unsigned int n
unsigned int d

Struct LineModel::OrientedEdge

Nested Relationships

This struct is a nested type of Class LineModel.

Struct Documentation
struct OrientedEdge

Public Functions

inline OrientedEdge()
inline OrientedEdge(unsigned int p0, unsigned int p1, unsigned int q0)

Public Members

unsigned int m_vert[2]
unsigned int m_quat

Struct NeighborhoodSearchSpatialHashing::HashEntry

Nested Relationships

This struct is a nested type of Class NeighborhoodSearchSpatialHashing.

Struct Documentation
struct HashEntry

Public Functions

inline HashEntry()

Public Members

unsigned long timestamp
std::vector<unsigned int> particleIndices

Struct Node

Struct Documentation
struct Node

Node in the simulated tree structure

Public Functions

inline Node()

Public Members

bool isconstraint
void *object
Matrix6r D
Matrix6r Dinv
Matrix6r J
std::vector<Node*> children
Node *parent
Vector6r soln
int index
Eigen::LDLT<Matrix6r> DLDLT

Struct TetModel::Attachment

Nested Relationships

This struct is a nested type of Class TetModel.

Struct Documentation
struct Attachment

Public Members

unsigned int m_index
unsigned int m_triIndex
Real m_bary[3]
Real m_dist
Real m_minError

Struct AverageTime

Struct Documentation
struct AverageTime

Struct to store the total time and the number of steps in order to compute the average time.

Public Members

double totalTime
unsigned int counter
std::string name

Struct IndexedFaceMesh::Edge

Nested Relationships

This struct is a nested type of Class IndexedFaceMesh.

Struct Documentation
struct Edge

Public Members

std::array<unsigned int, 2> m_face
std::array<unsigned int, 2> m_vert

Struct IndexedTetMesh::Edge

Nested Relationships

This struct is a nested type of Class IndexedTetMesh.

Struct Documentation
struct Edge

Public Members

std::array<unsigned int, 2> m_vert

Struct IndexedTetMesh::Face

Nested Relationships

This struct is a nested type of Class IndexedTetMesh.

Struct Documentation
struct Face

Public Members

std::array<unsigned int, 3> m_edges
std::array<unsigned int, 2> m_tets

Struct IndexedTetMesh::Tet

Nested Relationships

This struct is a nested type of Class IndexedTetMesh.

Struct Documentation
struct Tet

Public Members

std::array<unsigned int, 6> m_edges
std::array<unsigned int, 4> m_faces

Struct MeshFaceIndices

Struct Documentation
struct MeshFaceIndices

Struct to store the position and normal indices.

Public Members

std::array<int, 3> posIndices
std::array<int, 3> texIndices
std::array<int, 3> normalIndices

Struct SceneLoader::BallJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct BallJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position

Struct SceneLoader::BallOnLineJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct BallOnLineJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis

Struct SceneLoader::DamperJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct DamperJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_stiffness

Struct SceneLoader::DistanceJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct DistanceJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position1
Vector3r m_position2

Struct SceneLoader::HingeJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct HingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis

Struct SceneLoader::RigidBodyData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct RigidBodyData

Public Members

unsigned int m_id
std::string m_modelFile
bool m_flatShading
bool m_isDynamic
Real m_density
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
Vector3r m_v
Vector3r m_omega
Real m_restitutionCoeff
Real m_frictionCoeff
int m_collisionObjectType
std::string m_collisionObjectFileName
bool m_testMesh
Vector3r m_collisionObjectScale
bool m_invertSDF
Real m_thicknessSDF
Eigen::Matrix<unsigned int, 3, 1, Eigen::DontAlign> m_resolutionSDF
nlohmann::json m_json

Struct SceneLoader::RigidBodyParticleBallJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct RigidBodyParticleBallJointData

Public Members

unsigned int m_bodyID[2]

Struct SceneLoader::RigidBodySpringData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct RigidBodySpringData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position1
Vector3r m_position2
Real m_stiffness

Struct SceneLoader::SceneData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct SceneData

Public Members

std::string m_sceneName
Vector3r m_camPosition
Vector3r m_camLookat
Real m_timeStepSize
Vector3r m_gravity
std::vector<RigidBodyData> m_rigidBodyData
std::vector<TriangleModelData> m_triangleModelData
std::vector<TetModelData> m_tetModelData
std::vector<BallJointData> m_ballJointData
std::vector<BallOnLineJointData> m_ballOnLineJointData
std::vector<HingeJointData> m_hingeJointData
std::vector<UniversalJointData> m_universalJointData
std::vector<SliderJointData> m_sliderJointData
std::vector<RigidBodyParticleBallJointData> m_rigidBodyParticleBallJointData
std::vector<TargetAngleMotorHingeJointData> m_targetAngleMotorHingeJointData
std::vector<TargetVelocityMotorHingeJointData> m_targetVelocityMotorHingeJointData
std::vector<TargetPositionMotorSliderJointData> m_targetPositionMotorSliderJointData
std::vector<TargetVelocityMotorSliderJointData> m_targetVelocityMotorSliderJointData
std::vector<DamperJointData> m_damperJointData
std::vector<RigidBodySpringData> m_rigidBodySpringData
std::vector<DistanceJointData> m_distanceJointData

Struct SceneLoader::SliderJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct SliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis

Struct SceneLoader::TargetAngleMotorHingeJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TargetAngleMotorHingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat

Struct SceneLoader::TargetPositionMotorSliderJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TargetPositionMotorSliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat

Struct SceneLoader::TargetVelocityMotorHingeJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TargetVelocityMotorHingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat

Struct SceneLoader::TargetVelocityMotorSliderJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TargetVelocityMotorSliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat

Struct SceneLoader::TetModelData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TetModelData

Public Members

unsigned int m_id
std::string m_modelFileTet
std::string m_modelFileNodes
std::string m_modelFileElements
std::string m_modelFileVis
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
std::vector<unsigned int> m_staticParticles
Real m_restitutionCoeff
Real m_frictionCoeff
int m_collisionObjectType
std::string m_collisionObjectFileName
bool m_testMesh
Vector3r m_collisionObjectScale
bool m_invertSDF
Real m_thicknessSDF
Eigen::Matrix<unsigned int, 3, 1, Eigen::DontAlign> m_resolutionSDF
nlohmann::json m_json

Struct SceneLoader::TriangleModelData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct TriangleModelData

Public Members

unsigned int m_id
std::string m_modelFile
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
std::vector<unsigned int> m_staticParticles
Real m_restitutionCoeff
Real m_frictionCoeff
nlohmann::json m_json

Struct SceneLoader::UniversalJointData

Nested Relationships

This struct is a nested type of Class SceneLoader.

Struct Documentation
struct UniversalJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis[2]

Struct TimingHelper

Struct Documentation
struct TimingHelper

Struct to store a time measurement.

Public Members

std::chrono::time_point<std::chrono::high_resolution_clock> start
std::string name

Class AABB

Class Documentation
class AABB

Public Functions

inline AABB &operator=(const AABB &aabb)

Public Members

Vector3r m_p[2]

Public Static Functions

static inline bool pointInAABB(const AABB &a, const Vector3r &p)
static inline void getEdge(const AABB &a, char i, Vector3r &p1, Vector3r &p2)
static inline void getEdgeIndex(char i, char &p1, char &p2)
static inline void cornerPoint(const AABB &a, char i, Vector3r &p)
static inline FORCE_INLINE bool intersection (const AABB &a1, const AABB &a2)

Class BallJoint

Inheritance Relationships
Base Type
Class Documentation
class BallJoint : public PBD::Constraint

Public Functions

inline BallJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class BallOnLineJoint

Inheritance Relationships
Base Type
Class Documentation
class BallOnLineJoint : public PBD::Constraint

Public Functions

inline BallOnLineJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &dir)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 10, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class BendTwistConstraint

Inheritance Relationships
Base Type
Class Documentation
class BendTwistConstraint : public PBD::Constraint

Public Functions

inline BendTwistConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int quaternion1, const unsigned int quaternion2, const Real twistingStiffness, const Real bendingStiffness1, const Real bendingStiffness2)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Quaternionr m_restDarbouxVector
Real m_bendingStiffness1
Real m_bendingStiffness2
Real m_twistingStiffness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class BoundingSphere

Class Documentation
class BoundingSphere

Computes smallest enclosing spheres of pointsets using Welzl’s algorithm : Tassilo Kugelstadt.

Public Functions

inline BoundingSphere()

default constructor sets the center and radius to zero.

inline BoundingSphere(Vector3r const &x, const Real r)

constructor which sets the center and radius

Parameters
  • x – 3d coordiantes of the center point

  • r – radius of the sphere

inline BoundingSphere(const Vector3r &a)

constructs a sphere for one point (with radius 0)

Parameters

a – 3d coordinates of point a

inline BoundingSphere(const Vector3r &a, const Vector3r &b)

constructs the smallest enclosing sphere for two points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

inline BoundingSphere(const Vector3r &a, const Vector3r &b, const Vector3r &c)

constructs the smallest enclosing sphere for three points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

  • c – 3d coordinates of point c

inline BoundingSphere(const Vector3r &a, const Vector3r &b, const Vector3r &c, const Vector3r &d)

constructs the smallest enclosing sphere for four points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

  • c – 3d coordinates of point c

  • d – 3d coordinates of point d

inline BoundingSphere(const std::vector<Vector3r> &p)

constructs the smallest enclosing sphere a given pointset

Parameters

p – vertices of the points

inline Vector3r const &x() const

Getter for the center of the sphere.

Returns

const reference of the sphere center

inline Vector3r &x()

Access function for center of the sphere.

Returns

reference of the sphere center

inline Real r() const

Getter for the radius.

Returns

Radius of the sphere

inline Real &r()

Access function for the radius.

Returns

Reference to the radius of the sphere

inline void setPoints(const std::vector<Vector3r> &p)

constructs the smallest enclosing sphere a given pointset

Parameters

p – vertices of the points

inline bool overlaps(BoundingSphere const &other) const

intersection test for two spheres

Parameters

other – other sphere to be tested for intersection

Returns

returns true when this sphere and the other sphere are intersecting

inline bool contains(BoundingSphere const &other) const

tests whether the given sphere other is contained in the sphere

Parameters

other – bounding sphere

Returns

returns true when the other is contained in this sphere or vice versa

inline bool contains(Vector3r const &other) const

tests whether the given point other is contained in the sphere

Parameters

other – 3d coordinates of a point

Returns

returns true when the point is contained in the sphere

Class BVHTest

Class Documentation
class BVHTest

Public Types

using TraversalCallback = std::function<void(unsigned int node_index1, unsigned int node_index2)>

Public Static Functions

static void traverse(PointCloudBSH const &b1, TetMeshBSH const &b2, TraversalCallback func)
static void traverse(PointCloudBSH const &b1, const unsigned int node_index1, TetMeshBSH const &b2, const unsigned int node_index2, TraversalCallback func)

Class CollisionDetection

Inheritance Relationships
Base Type
  • public ParameterObject

Derived Type
Class Documentation
class CollisionDetection : public ParameterObject

Subclassed by PBD::DistanceFieldCollisionDetection

Public Types

typedef void (*ContactCallbackFunction)(const unsigned int contactType, const unsigned int bodyIndex1, const unsigned int bodyIndex2, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff, void *userData)
typedef void (*SolidContactCallbackFunction)(const unsigned int contactType, const unsigned int bodyIndex1, const unsigned int bodyIndex2, const unsigned int tetIndex, const Vector3r &bary, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff, void *userData)

Public Functions

CollisionDetection()
virtual ~CollisionDetection()
void init()
void cleanup()
inline Real getTolerance() const
inline void setTolerance(Real val)
void addRigidBodyContact(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
void addParticleRigidBodyContact(const unsigned int particleIndex, const unsigned int rbIndex, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
void addParticleSolidContact(const unsigned int particleIndex, const unsigned int solidIndex, const unsigned int tetIndex, const Vector3r &bary, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
virtual void addCollisionObject(const unsigned int bodyIndex, const unsigned int bodyType)
inline std::vector<CollisionObject*> &getCollisionObjects()
virtual void collisionDetection(SimulationModel &model) = 0
void setContactCallback(CollisionDetection::ContactCallbackFunction val, void *userData)
void setSolidContactCallback(CollisionDetection::SolidContactCallbackFunction val, void *userData)
void updateAABBs(SimulationModel &model)
void updateAABB(SimulationModel &model, CollisionDetection::CollisionObject *co)

Public Static Attributes

static int CONTACT_TOLERANCE = -1
static const unsigned int RigidBodyContactType = 0
static const unsigned int ParticleContactType = 1
static const unsigned int ParticleRigidBodyContactType = 2
static const unsigned int ParticleSolidContactType = 3

Protected Functions

void updateAABB(const Vector3r &p, AABB &aabb)
virtual void initParameters()

Protected Attributes

Real m_tolerance
ContactCallbackFunction m_contactCB
SolidContactCallbackFunction m_solidContactCB
void *m_contactCBUserData
void *m_solidContactCBUserData
std::vector<CollisionObject*> m_collisionObjects
struct CollisionObject

Subclassed by PBD::CollisionDetection::CollisionObjectWithoutGeometry

Public Functions

inline virtual ~CollisionObject()
virtual int &getTypeId() const = 0

Public Members

AABB m_aabb
unsigned int m_bodyIndex
unsigned int m_bodyType

Public Static Attributes

static const unsigned int RigidBodyCollisionObjectType = 0
static const unsigned int TriangleModelCollisionObjectType = 1
static const unsigned int TetModelCollisionObjectType = 2
struct CollisionObjectWithoutGeometry : public PBD::CollisionDetection::CollisionObject

Public Functions

inline virtual int &getTypeId() const
inline virtual ~CollisionObjectWithoutGeometry()

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class Constraint

Inheritance Relationships
Derived Types
Class Documentation
class Constraint

Subclassed by PBD::BallJoint, PBD::BallOnLineJoint, PBD::BendTwistConstraint, PBD::DamperJoint, PBD::DihedralConstraint, PBD::DirectPositionBasedSolverForStiffRodsConstraint, PBD::DistanceConstraint, PBD::DistanceConstraint_XPBD, PBD::DistanceJoint, PBD::FEMTetConstraint, PBD::FEMTriangleConstraint, PBD::HingeJoint, PBD::IsometricBendingConstraint, PBD::IsometricBendingConstraint_XPBD, PBD::MotorJoint, PBD::RigidBodyParticleBallJoint, PBD::RigidBodySpring, PBD::ShapeMatchingConstraint, PBD::SliderJoint, PBD::StrainTetConstraint, PBD::StrainTriangleConstraint, PBD::StretchBendingTwistingConstraint, PBD::StretchShearConstraint, PBD::UniversalJoint, PBD::VolumeConstraint, PBD::VolumeConstraint_XPBD, PBD::XPBD_FEMTetConstraint

Public Functions

inline Constraint(const unsigned int numberOfBodies)
inline unsigned int numberOfBodies() const
inline virtual ~Constraint()
virtual int &getTypeId() const = 0
inline virtual bool initConstraintBeforeProjection(SimulationModel &model)
inline virtual bool updateConstraint(SimulationModel &model)
inline virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)
inline virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

std::vector<unsigned int> m_bodies

indices of the linked bodies

Class CubicKernel

Class Documentation
class CubicKernel

Public Static Functions

static inline Real getRadius()
static inline void setRadius(Real val)
static inline Real W(const Vector3r &r)
static inline Vector3r gradW(const Vector3r &r)
static inline Real W_zero()

Protected Static Attributes

static Real m_radius
static Real m_k
static Real m_l
static Real m_W_zero

Class CubicSDFCollisionDetection

Inheritance Relationships
Base Type
Class Documentation
class CubicSDFCollisionDetection : public PBD::DistanceFieldCollisionDetection

Collision detection based on cubic signed distance fields.

Public Types

using Grid = Discregrid::CubicLagrangeDiscreteGrid
using GridPtr = std::shared_ptr<Discregrid::CubicLagrangeDiscreteGrid>

Public Functions

CubicSDFCollisionDetection()
virtual ~CubicSDFCollisionDetection()
virtual bool isDistanceFieldCollisionObject(CollisionObject *co) const
void addCubicSDFCollisionObject(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const std::string &sdfFile, const Vector3r &scale, const bool testMesh = true, const bool invertSDF = false)
void addCubicSDFCollisionObject(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, GridPtr sdf, const Vector3r &scale, const bool testMesh = true, const bool invertSDF = false)
struct CubicSDFCollisionObject : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

CubicSDFCollisionObject()
virtual ~CubicSDFCollisionObject()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

std::string m_sdfFile
Vector3r m_scale
GridPtr m_sdf

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DamperJoint

Inheritance Relationships
Base Type
Class Documentation
class DamperJoint : public PBD::Constraint

Public Functions

inline DamperJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis, const Real stiffness)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> m_jointInfo
Real m_lambda

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DihedralConstraint

Inheritance Relationships
Base Type
Class Documentation
class DihedralConstraint : public PBD::Constraint

Public Functions

inline DihedralConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_restAngle
Real m_stiffness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DirectPositionBasedSolverForStiffRods

Class Documentation
class DirectPositionBasedSolverForStiffRods

Public Static Functions

static bool init_DirectPositionBasedSolverForStiffRodsConstraint(std::vector<RodConstraint*> &rodConstraints, std::vector<RodSegment*> &rodSegments, Interval *&intervals, int &numberOfIntervals, std::list<Node*> *&forward, std::list<Node*> *&backward, Node *&root, const std::vector<Vector3r> &constraintPositions, const std::vector<Real> &averageRadii, const std::vector<Real> &youngsModuli, const std::vector<Real> &torsionModuli, std::vector<Vector6r> &RHS, std::vector<Vector6r> &lambdaSums, std::vector<std::vector<Matrix3r>> &bendingAndTorsionJacobians, std::vector<Vector3r> &corr_x, std::vector<Quaternionr> &corr_q)

Initialize the zero-stretch, bending, and torsion constraints of the rod. Computes constraint connectors in segment space, computes the diagonal stiffness matrices and the Darboux vectors of the initial state. Initializes the forward and backward lists of nodes for the direct solver

Parameters
  • rodConstraints – contains the combined zero-stretch, bending and torsion constraints of the rod. The set of constraints must by acyclic.

  • rodSegments – contains the segments of the rod

  • forward – list of nodes in the acyclic tree of rod segments and zero-stretch, bending and torsion constraints so that parent nodes occur later in the list than their children

  • backward – list of nodes in the acyclic tree of rod segments and zero-stretch, bending and torsion constraints. The reverse of the forward list.

  • constraintPositions – positions of the rod’s constraints in world coordinates

  • averageRadii – the average radii at the constraint positions of the rod. Value in Meters (m)

  • averageSegmentLengths – vector of the average lengths of the two rod segments connected by a constraint of the rod. Value in Meters (m)

  • youngsModuli – vector of the Young’s modulus of every constraint of the rod. The Young’s modulus of the rod material measures stiffness against bending. Value in Pascal (Pa)

  • torsionModuli – vector of the torsion modulus of every constraint of the rod. The torsion modulus (also called shear modulus) of the rod material measures stiffness against torsion. Value in Pascal (Pa)

  • RHS – vector with entries for each constraint. In concatenation these entries represent the right hand side of the system of equations to be solved. (eq. 22 in the paper)

  • lambdaSums – contains entries of the sum of all lambda updates for each constraint in the rod during one time step which is needed by the solver to handle compliance in the correct way (cf. the right hand side of eq. 22 in the paper).

  • bendingAndTorsionJacobians – this vector is used to temporary save the Jacobians of the bending and torsion part of each constraint during the solution process of the system of equations. Allocating this vector outside of the solve-method avoids repeated reallocation between iterations of the solver

  • corr_x – vector of position corrections for every segment of the rod (part of delta-x in eq. 22 in the paper)

  • corr_q – vector of rotation corrections for every segment of the rod (part of delta-x in eq. 22 in the paper)

static bool update_DirectPositionBasedSolverForStiffRodsConstraint(const std::vector<RodConstraint*> &rodConstraints, const std::vector<RodSegment*> &rodSegments)

Update the constraint info data.

Parameters
  • rodConstraints – contains the combined zero-stretch, bending and torsion constraints of the rod.

  • rodSegments – contains the segments of the rod

static bool initBeforeProjection_DirectPositionBasedSolverForStiffRodsConstraint(const std::vector<RodConstraint*> &rodConstraints, const Real inverseTimeStepSize, std::vector<Vector6r> &lambdaSums)

Initialize the constraint before the projection iterations in each time step.

Parameters
  • rodConstraints – contains the combined zero-stretch, bending and torsion constraints of the rod.

  • inverseTimeStepSize – inverse of the current time step size used to compute compliance (see computation of alpha-tilde in eq. 17)

  • lambdaSums – contains entries of the sum of all lambda updates for each constraint in the rod during one time step which is needed by the solver to handle compliance in the correct way (cf. the right hand side of eq. 22 in the paper).

static bool solve_DirectPositionBasedSolverForStiffRodsConstraint(const std::vector<RodConstraint*> &rodConstraints, std::vector<RodSegment*> &rodSegments, const Interval *intervals, const int &numberOfIntervals, std::list<Node*> *forward, std::list<Node*> *backward, std::vector<Vector6r> &RHS, std::vector<Vector6r> &lambdaSums, std::vector<std::vector<Matrix3r>> &bendingAndTorsionJacobians, std::vector<Vector3r> &corr_x, std::vector<Quaternionr> &corr_q)

Determine the position and orientation corrections for all combined zero-stretch, bending and twisting constraints of the rod (eq. 22 in the paper).

Parameters
  • rodConstraints – contains the combined zero-stretch, bending and torsion constraints of the rod. The set of constraints must by acyclic.

  • rodSegments – contains the segments of the rod

  • forward – list of nodes in the acyclic tree of rod segments and zero-stretch, bending and torsion constraints so that parent nodes occur later in the list than their children

  • backward – list of nodes in the acyclic tree of rod segments and zero-stretch, bending and torsion constraints. The reverse of the forward list.

  • RHS – vector with entries for each constraint. In concatenation these entries represent the right hand side of the system of equations to be solved. (eq. 22 in the paper)

  • lambdaSums – contains entries of the sum of all lambda updates for each constraint in the rod during one time step which is needed by the solver to handle compliance in the correct way.

  • bendingAndTorsionJacobians – this vector is used to temporary save the Jacobians of the bending and torsion part of each constraint during the solution process of the system of equations. Allocating this vector outside of the solve-method avoids repeated reallocation between iterations of the solver

  • corr_x – vector of position corrections for every segment of the rod (part of delta-x in eq. 22 in the paper)

  • corr_q – vector of rotation corrections for every segment of the rod (part of delta-x in eq. 22 in the paper)

static bool init_StretchBendingTwistingConstraint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &constraintPosition, const Real averageRadius, const Real averageSegmentLength, const Real youngsModulus, const Real torsionModulus, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo, Vector3r &stiffnessCoefficientK, Vector3r &restDarbouxVector)

Initialize the zero-stretch, bending, and torsion constraint. Computes constraint connectors in segment space, computes the diagonal stiffness matrix and the Darboux vector of the initial state.

Parameters
  • x0 – center of mass of body 0

  • q0 – rotation of body 0

  • x1 – center of mass of body 1

  • q1 – rotation of body 1

  • constraintPosition – position of the constraint in world coordinates

  • averageRadius – the average radius of the two rod segments connected by the constraint. Value in Meters (m)

  • averageSegmentLength – the average length of the two rod segments connected by the constraint. Value in Meters (m)

  • youngsModulus – the Young’s modulus of the rod material measures stiffness against bending. Value in Pascal (Pa)

  • torsionModulus – the torsion modulus (also called shear modulus) of the rod material measures stiffness against torsion. Value in Pascal (Pa)

  • jointInfo – joint information which is required by the solver.This information is generated in this method and updated each time the bodies change their state by update_StretchBendingTwistingConstraint().

  • stiffnessCoefficientK – diagonal matrix with material parameters for bending and torsion stiffness (eq. 5 in the paper)

  • restDarbouxVector – the rest Darboux vector computed in this method with the initial constraint configuration

static bool initBeforeProjection_StretchBendingTwistingConstraint(const Vector3r &stiffnessCoefficientK, const Real inverseTimeStepSize, const Real averageSegmentLength, Vector3r &stretchCompliance, Vector3r &bendingAndTorsionCompliance, Vector6r &lambdaSum)

Initialize the constraint before the projection iterations in each time step.

Parameters
  • stiffnessCoefficientK – diagonal matrix with material parameters for bending and torsion stiffness (eq. 5 in the paper)

  • inverseTimeStepSize – inverse of the current time step size used to compute compliance (see computation of alpha-tilde in eq. 17)

  • bendingAndTorsionCompliance – the compliance of the bending and torsion constraint part (eq. 24 in the paper)

  • stretchCompliance – the compliance of the stretch constraint part (eq. 24 in the paper)

  • lambdaSum – the sum of all lambda updates of this constraint during one time step which is needed by the solver to handle compliance in the correct way. Is set to zero. (see eq. 19 in the paper)

static bool update_StretchBendingTwistingConstraint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo)

Update the joint info data.

Parameters
  • x0 – center of mass of body 0

  • q0 – rotation of body 0

  • x1 – center of mass of body 1

  • q1 – rotation of body 1

  • jointInfo – joint information which is required by the solver.This information is updated by calling this method.

static bool solve_StretchBendingTwistingConstraint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Vector3r &restDarbouxVector, const Real averageSegmentLength, const Vector3r &stretchCompliance, const Vector3r &bendingAndTorsionCompliance, const Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1, Vector6r &lambdaSum)

Determine the position and orientation corrections for the combined zero-stretch, bending and twisting constraint (eq. 23 in the paper).

Parameters
  • invMass0 – inverse mass of first body; inverse mass is zero if body is static

  • x0 – center of mass of body 0

  • inertiaInverseW0 – inverse inertia tensor (world space) of body 0

  • q0 – rotation of body 0

  • invMass1 – inverse mass of second body; inverse mass is zero if body is static

  • x1 – center of mass of body 1

  • inertiaInverseW1 – inverse inertia tensor (world space) of body 1

  • q1 – rotation of body 1

  • restDarbouxVector – the rest Darboux vector of the initial constraint configuration

  • averageSegmentLength – the average length of the two rod segments connected by the constraint

  • stretchCompliance – the compliance of the stretch constraint part (eq. 24 in the paper)

  • bendingAndTorsionCompliance – the compliance of the bending and torsion constraint part (eq. 24 in the paper)

  • jointInfo – joint information which is required by the solver.This information must be generated in the beginning by calling init_StretchBendingTwistingConstraint() and updated each time the bodies change their state by update_StretchBendingTwistingConstraint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

  • lambdaSum – the sum of all lambda updates of this constraint during one time step which is needed by the solver to handle compliance in the correct way. Must be set to zero before the position projection iterations start at each time step by calling initBeforeProjection_StretchBendingTwistingConstraint(). (see eq. 19 in the paper)

Class DirectPositionBasedSolverForStiffRodsConstraint

Inheritance Relationships
Base Type
Class Documentation
class DirectPositionBasedSolverForStiffRodsConstraint : public PBD::Constraint

Public Functions

inline DirectPositionBasedSolverForStiffRodsConstraint()
~DirectPositionBasedSolverForStiffRodsConstraint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const std::vector<std::pair<unsigned int, unsigned int>> &constraintSegmentIndices, const std::vector<Vector3r> &constraintPositions, const std::vector<Real> &averageRadii, const std::vector<Real> &averageSegmentLengths, const std::vector<Real> &youngsModuli, const std::vector<Real> &torsionModuli)
virtual bool initConstraintBeforeProjection(SimulationModel &model)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Protected Functions

void deleteNodes()

Protected Attributes

Node *root

root node

Interval *intervals

intervals of constraints

int numberOfIntervals

number of intervals

std::list<Node*> *forward

list to process nodes with increasing row index in the system matrix H (from the leaves to the root)

std::list<Node*> *backward

list to process nodes starting with the highest row index to row index zero in the matrix H (from the root to the leaves)

std::vector<RodConstraintImpl> m_Constraints
std::vector<RodConstraint*> m_rodConstraints
std::vector<RodSegmentImpl> m_Segments
std::vector<RodSegment*> m_rodSegments
std::vector<Vector6r> m_rightHandSide
std::vector<Vector6r> m_lambdaSums
std::vector<std::vector<Matrix3r>> m_bendingAndTorsionJacobians
std::vector<Vector3r> m_corr_x
std::vector<Quaternionr> m_corr_q

Class DirectPositionBasedSolverForStiffRodsConstraint::RodConstraintImpl

Nested Relationships

This class is a nested type of Class DirectPositionBasedSolverForStiffRodsConstraint.

Inheritance Relationships
Base Type
Class Documentation
class RodConstraintImpl : public PBD::RodConstraint

Public Functions

inline virtual unsigned int segmentIndex(unsigned int i)
inline virtual Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &getConstraintInfo()
inline virtual Real getAverageSegmentLength()
inline virtual Vector3r &getRestDarbouxVector()
inline virtual Vector3r &getStiffnessCoefficientK()
inline virtual Vector3r &getStretchCompliance()
inline virtual Vector3r &getBendingAndTorsionCompliance()

Public Members

std::vector<unsigned int> m_segments
Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> m_constraintInfo
Real m_averageRadius
Real m_averageSegmentLength
Vector3r m_restDarbouxVector
Vector3r m_stiffnessCoefficientK
Vector3r m_stretchCompliance
Vector3r m_bendingAndTorsionCompliance

Class DirectPositionBasedSolverForStiffRodsConstraint::RodSegmentImpl

Nested Relationships

This class is a nested type of Class DirectPositionBasedSolverForStiffRodsConstraint.

Inheritance Relationships
Base Type
Class Documentation
class RodSegmentImpl : public PBD::RodSegment

Public Functions

inline RodSegmentImpl(SimulationModel &model, unsigned int idx)
virtual bool isDynamic()
virtual Real Mass()
virtual const Vector3r &InertiaTensor()
virtual const Vector3r &Position()
virtual const Quaternionr &Rotation()

Public Members

SimulationModel &m_model
unsigned int m_segmentIdx

Class DistanceConstraint

Inheritance Relationships
Base Type
Class Documentation
class DistanceConstraint : public PBD::Constraint

Public Functions

inline DistanceConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_restLength
Real m_stiffness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DistanceConstraint_XPBD

Inheritance Relationships
Base Type
Class Documentation
class DistanceConstraint_XPBD : public PBD::Constraint

Public Functions

inline DistanceConstraint_XPBD()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_restLength
Real m_lambda
Real m_stiffness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DistanceFieldCollisionDetection

Inheritance Relationships
Base Type
Derived Type
Class Documentation
class DistanceFieldCollisionDetection : public PBD::CollisionDetection

Distance field collision detection.

Subclassed by PBD::CubicSDFCollisionDetection

Public Functions

DistanceFieldCollisionDetection()
virtual ~DistanceFieldCollisionDetection()
virtual void collisionDetection(SimulationModel &model)
virtual bool isDistanceFieldCollisionObject(CollisionObject *co) const
void addCollisionBox(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Vector3r &box, const bool testMesh = true, const bool invertSDF = false)
void addCollisionSphere(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Real radius, const bool testMesh = true, const bool invertSDF = false)
void addCollisionTorus(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Vector2r &radii, const bool testMesh = true, const bool invertSDF = false)
void addCollisionObjectWithoutGeometry(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const bool testMesh)
void addCollisionHollowSphere(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Real radius, const Real thickness, const bool testMesh = true, const bool invertSDF = false)
void addCollisionHollowBox(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Vector3r &box, const Real thickness, const bool testMesh = true, const bool invertSDF = false)
void addCollisionCylinder(const unsigned int bodyIndex, const unsigned int bodyType, const Vector3r *vertices, const unsigned int numVertices, const Vector2r &dim, const bool testMesh = true, const bool invertSDF = false)

Add collision cylinder

Parameters
  • bodyIndex – index of corresponding body

  • bodyType – type of corresponding body

  • dim – (radius, height) of cylinder

Protected Functions

void collisionDetectionRigidBodies(RigidBody *rb1, DistanceFieldCollisionObject *co1, RigidBody *rb2, DistanceFieldCollisionObject *co2, const Real restitutionCoeff, const Real frictionCoeff, std::vector<std::vector<ContactData>> &contacts_mt)
void collisionDetectionRBSolid(const ParticleData &pd, const unsigned int offset, const unsigned int numVert, DistanceFieldCollisionObject *co1, RigidBody *rb2, DistanceFieldCollisionObject *co2, const Real restitutionCoeff, const Real frictionCoeff, std::vector<std::vector<ContactData>> &contacts_mt)
void collisionDetectionSolidSolid(const ParticleData &pd, const unsigned int offset, const unsigned int numVert, DistanceFieldCollisionObject *co1, TetModel *tm2, DistanceFieldCollisionObject *co2, const Real restitutionCoeff, const Real frictionCoeff, std::vector<std::vector<ContactData>> &contacts_mt)
bool findRefTetAt(const ParticleData &pd, TetModel *tm, const DistanceFieldCollisionDetection::DistanceFieldCollisionObject *co, const Vector3r &X, unsigned int &tetIndex, Vector3r &barycentricCoordinates)
struct ContactData

Public Members

char m_type
unsigned int m_index1
unsigned int m_index2
Vector3r m_cp1
Vector3r m_cp2
Vector3r m_normal
Real m_dist
Real m_restitution
Real m_friction
unsigned int m_elementIndex1
unsigned int m_elementIndex2
Vector3r m_bary1
Vector3r m_bary2
struct DistanceFieldCollisionBox : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionBox()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector3r m_box

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionCylinder : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionCylinder()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector2r m_dim

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionHollowBox : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionHollowBox()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector3r m_box
Real m_thickness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionHollowSphere : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionHollowSphere()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Real m_radius
Real m_thickness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionObject : public CollisionObject

Subclassed by PBD::CubicSDFCollisionDetection::CubicSDFCollisionObject, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionBox, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionCylinder, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionHollowBox, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionHollowSphere, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObjectWithoutGeometry, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionSphere, PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionTorus

Public Functions

inline DistanceFieldCollisionObject()
inline virtual ~DistanceFieldCollisionObject()
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual void approximateNormal(const Eigen::Vector3d &x, const Real tolerance, Vector3r &n)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance) = 0
void initTetBVH(const Vector3r *vertices, const unsigned int numVertices, const unsigned int *indices, const unsigned int numTets, const Real tolerance)

Public Members

bool m_testMesh
Real m_invertSDF
PointCloudBSH m_bvh
TetMeshBSH m_bvhTets
TetMeshBSH m_bvhTets0
struct DistanceFieldCollisionObjectWithoutGeometry : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionObjectWithoutGeometry()
inline virtual int &getTypeId() const
inline virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
inline virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionSphere : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionSphere()
inline virtual int &getTypeId() const
virtual bool collisionTest(const Vector3r &x, const Real tolerance, Vector3r &cp, Vector3r &n, Real &dist, const Real maxDist = 0.0)
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Real m_radius

Public Static Attributes

static int TYPE_ID = IDFactory::getId()
struct DistanceFieldCollisionTorus : public PBD::DistanceFieldCollisionDetection::DistanceFieldCollisionObject

Public Functions

inline virtual ~DistanceFieldCollisionTorus()
inline virtual int &getTypeId() const
virtual double distance(const Eigen::Vector3d &x, const Real tolerance)

Public Members

Vector2r m_radii

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class DistanceJoint

Inheritance Relationships
Base Type
Class Documentation
class DistanceJoint : public PBD::Constraint

Public Functions

inline DistanceJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos1, const Vector3r &pos2)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> m_jointInfo
Real m_restLength

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class FEMTetConstraint

Inheritance Relationships
Base Type
Class Documentation
class FEMTetConstraint : public PBD::Constraint

Public Functions

inline FEMTetConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness, const Real poissonRatio)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Real m_poissonRatio
Real m_volume
Matrix3r m_invRestMat

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class FEMTriangleConstraint

Inheritance Relationships
Base Type
Class Documentation
class FEMTriangleConstraint : public PBD::Constraint

Public Functions

inline FEMTriangleConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const Real xyPoissonRatio, const Real yxPoissonRatio)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_area
Matrix2r m_invRestMat
Real m_xxStiffness
Real m_xyStiffness
Real m_yyStiffness
Real m_xyPoissonRatio
Real m_yxPoissonRatio

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class HingeJoint

Inheritance Relationships
Base Type
Class Documentation
class HingeJoint : public PBD::Constraint

Public Functions

inline HingeJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 7, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class IDFactory

Class Documentation
class IDFactory

Factory for unique ids.

Public Static Functions

static inline int getId()

Class IsometricBendingConstraint

Inheritance Relationships
Base Type
Class Documentation
class IsometricBendingConstraint : public PBD::Constraint

Public Functions

inline IsometricBendingConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Matrix4r m_Q

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class IsometricBendingConstraint_XPBD

Inheritance Relationships
Base Type
Class Documentation
class IsometricBendingConstraint_XPBD : public PBD::Constraint

Public Functions

inline IsometricBendingConstraint_XPBD()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Matrix4r m_Q
Real m_lambda

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Template Class KDTree

Nested Relationships
Class Documentation
template<typename HullType>
class KDTree

Public Types

using TraversalPredicate = std::function<bool(unsigned int node_index, unsigned int depth)>
using TraversalCallback = std::function<void(unsigned int node_index, unsigned int depth)>
using TraversalPriorityLess = std::function<bool(std::array<int, 2> const &nodes)>
using TraversalQueue = std::queue<QueueItem>

Public Functions

inline KDTree(std::size_t n, unsigned int maxPrimitivesPerLeaf = 1)
inline virtual ~KDTree()
inline Node const &node(unsigned int i) const
inline HullType const &hull(unsigned int i) const
inline unsigned int entity(unsigned int i) const
void construct()
void traverse_depth_first(TraversalPredicate pred, TraversalCallback cb, TraversalPriorityLess const &pless = nullptr) const
void traverse_breadth_first(TraversalPredicate const &pred, TraversalCallback const &cb, unsigned int start_node = 0, TraversalPriorityLess const &pless = nullptr, TraversalQueue &pending = TraversalQueue()) const
void traverse_breadth_first_parallel(TraversalPredicate pred, TraversalCallback cb) const
void update()

Protected Functions

void construct(unsigned int node, AlignedBox3r const &box, unsigned int b, unsigned int n)
void traverse_depth_first(unsigned int node, unsigned int depth, TraversalPredicate pred, TraversalCallback cb, TraversalPriorityLess const &pless) const
void traverse_breadth_first(TraversalQueue &pending, TraversalPredicate const &pred, TraversalCallback const &cb, TraversalPriorityLess const &pless = nullptr) const
unsigned int add_node(unsigned int b, unsigned int n)
virtual Vector3r const &entity_position(unsigned int i) const = 0
virtual void compute_hull(unsigned int b, unsigned int n, HullType &hull) const = 0
inline virtual void compute_hull_approx(unsigned int b, unsigned int n, HullType &hull) const

Protected Attributes

std::vector<unsigned int> m_lst
std::vector<Node> m_nodes
std::vector<HullType> m_hulls
unsigned int m_maxPrimitivesPerLeaf
struct Node

Public Functions

inline Node(unsigned int b_, unsigned int n_)
Node() = default
inline bool is_leaf() const

Public Members

std::array<int, 2> children
unsigned int begin
unsigned int n
struct QueueItem

Public Members

unsigned int n
unsigned int d

Class LineModel

Nested Relationships
Class Documentation
class LineModel

Public Types

typedef std::vector<OrientedEdge> Edges

Public Functions

LineModel()
virtual ~LineModel()
void updateConstraints()
Edges &getEdges()
unsigned int getIndexOffset() const
unsigned int getIndexOffsetQuaternions() const
void initMesh(const unsigned int nPoints, const unsigned int nQuaternions, const unsigned int indexOffset, const unsigned int indexOffsetQuaternions, unsigned int *indices, unsigned int *indicesQuaternions)
inline FORCE_INLINE Real getRestitutionCoeff () const
inline FORCE_INLINE void setRestitutionCoeff (Real val)
inline FORCE_INLINE Real getFrictionCoeff () const
inline FORCE_INLINE void setFrictionCoeff (Real val)

Protected Attributes

unsigned int m_indexOffset

offset which must be added to get the correct index in the particles array

unsigned int m_indexOffsetQuaternions

offset which must be added to get the correct index in the quaternions array

unsigned int m_nPoints
unsigned int m_nQuaternions
Edges m_edges
Real m_restitutionCoeff
Real m_frictionCoeff

Class MathFunctions

Class Documentation
class MathFunctions

Public Static Functions

static Real infNorm(const Matrix3r &A)

Return the inf norm of the matrix.

static Real oneNorm(const Matrix3r &A)

Return the one norm of the matrix.

static void eigenDecomposition(const Matrix3r &A, Matrix3r &eigenVecs, Vector3r &eigenVals)
static void polarDecomposition(const Matrix3r &A, Matrix3r &R, Matrix3r &U, Matrix3r &D)

Perform polar decomposition A = (U D U^T) R

static void polarDecompositionStable(const Matrix3r &M, const Real tolerance, Matrix3r &R)

Perform a polar decomposition of matrix M and return the rotation matrix R. This method handles the degenerated cases.

static void svdWithInversionHandling(const Matrix3r &A, Vector3r &sigma, Matrix3r &U, Matrix3r &VT)

Perform a singular value decomposition of matrix A: A = U * sigma * V^T. This function returns two proper rotation matrices U and V^T which do not contain a reflection. Reflections are corrected by the inversion handling proposed by Irving et al. 2004.

static Real cotTheta(const Vector3r &v, const Vector3r &w)
static void crossProductMatrix(const Vector3r &v, Matrix3r &v_hat)

Computes the cross product matrix of a vector.

Parameters
  • v – input vector

  • v_hat – resulting cross product matrix

static void extractRotation(const Matrix3r &A, Quaternionr &q, const unsigned int maxIter)

Implementation of the paper:

Matthias Müller, Jan Bender, Nuttapong Chentanez and Miles Macklin, “A Robust Method to Extract the Rotational Part of Deformations”, ACM SIGGRAPH Motion in Games, 2016

Class MotorJoint

Inheritance Relationships
Base Type
Derived Types
Class Documentation
class MotorJoint : public PBD::Constraint

Subclassed by PBD::TargetAngleMotorHingeJoint, PBD::TargetPositionMotorSliderJoint, PBD::TargetVelocityMotorHingeJoint, PBD::TargetVelocityMotorSliderJoint

Public Functions

inline MotorJoint()
inline virtual Real getTarget() const
inline virtual void setTarget(const Real val)
inline virtual std::vector<Real> &getTargetSequence()
inline virtual void setTargetSequence(const std::vector<Real> &val)
inline bool getRepeatSequence() const
inline void setRepeatSequence(bool val)

Public Members

Real m_target
std::vector<Real> m_targetSequence

Class NeighborhoodSearchSpatialHashing

Class Documentation
class NeighborhoodSearchSpatialHashing

Public Functions

NeighborhoodSearchSpatialHashing(const unsigned int numParticles = 0, const Real radius = 0.1, const unsigned int maxNeighbors = 60u, const unsigned int maxParticlesPerCell = 50u)
~NeighborhoodSearchSpatialHashing()
void cleanup()
void neighborhoodSearch(Vector3r *x)
void neighborhoodSearch(Vector3r *x, const unsigned int numBoundaryParticles, Vector3r *boundaryX)
void update()
unsigned int **getNeighbors() const
unsigned int *getNumNeighbors() const
inline const unsigned int getMaxNeighbors() const
unsigned int getNumParticles() const
void setRadius(const Real radius)
Real getRadius() const
inline FORCE_INLINE unsigned int n_neighbors (unsigned int i) const
inline FORCE_INLINE unsigned int neighbor (unsigned int i, unsigned int k) const

Public Static Functions

static inline FORCE_INLINE int floor (const Real v)
struct HashEntry

Public Functions

inline HashEntry()

Public Members

unsigned long timestamp
std::vector<unsigned int> particleIndices

Class OrientationData

Class Documentation
class OrientationData

This class encapsulates the state of all orientations of a quaternion model. All parameters are stored in individual arrays.

Public Functions

inline FORCE_INLINE OrientationData(void)
inline FORCE_INLINE ~OrientationData(void)
inline FORCE_INLINE void addQuaternion (const Quaternionr &vertex)
inline FORCE_INLINE Quaternionr & getQuaternion (const unsigned int i)
inline FORCE_INLINE const Quaternionr & getQuaternion (const unsigned int i) const
inline FORCE_INLINE void setQuaternion (const unsigned int i, const Quaternionr &pos)
inline FORCE_INLINE Quaternionr & getQuaternion0 (const unsigned int i)
inline FORCE_INLINE const Quaternionr & getQuaternion0 (const unsigned int i) const
inline FORCE_INLINE void setQuaternion0 (const unsigned int i, const Quaternionr &pos)
inline FORCE_INLINE Quaternionr & getLastQuaternion (const unsigned int i)
inline FORCE_INLINE const Quaternionr & getLastQuaternion (const unsigned int i) const
inline FORCE_INLINE void setLastQuaternion (const unsigned int i, const Quaternionr &pos)
inline FORCE_INLINE Quaternionr & getOldQuaternion (const unsigned int i)
inline FORCE_INLINE const Quaternionr & getOldQuaternion (const unsigned int i) const
inline FORCE_INLINE void setOldQuaternion (const unsigned int i, const Quaternionr &pos)
inline FORCE_INLINE Vector3r & getVelocity (const unsigned int i)
inline FORCE_INLINE const Vector3r & getVelocity (const unsigned int i) const
inline FORCE_INLINE void setVelocity (const unsigned int i, const Vector3r &vel)
inline FORCE_INLINE Vector3r & getAcceleration (const unsigned int i)
inline FORCE_INLINE const Vector3r & getAcceleration (const unsigned int i) const
inline FORCE_INLINE void setAcceleration (const unsigned int i, const Vector3r &accel)
inline FORCE_INLINE const Real getMass (const unsigned int i) const
inline FORCE_INLINE Real & getMass (const unsigned int i)
inline FORCE_INLINE void setMass (const unsigned int i, const Real mass)
inline FORCE_INLINE const Real getInvMass (const unsigned int i) const
inline FORCE_INLINE const unsigned int getNumberOfQuaternions () const
inline FORCE_INLINE void resize (const unsigned int newSize)

Resize the array containing the particle data.

inline FORCE_INLINE void reserve (const unsigned int newSize)

Reserve the array containing the particle data.

inline FORCE_INLINE void release ()

Release the array containing the particle data.

inline FORCE_INLINE unsigned int size () const

Release the array containing the particle data.

Class ParticleData

Class Documentation
class ParticleData

This class encapsulates the state of all particles of a particle model. All parameters are stored in individual arrays.

Public Functions

inline FORCE_INLINE ParticleData(void)
inline FORCE_INLINE ~ParticleData(void)
inline FORCE_INLINE void addVertex (const Vector3r &vertex)
inline FORCE_INLINE Vector3r & getPosition (const unsigned int i)
inline FORCE_INLINE const Vector3r & getPosition (const unsigned int i) const
inline FORCE_INLINE void setPosition (const unsigned int i, const Vector3r &pos)
inline FORCE_INLINE Vector3r & getPosition0 (const unsigned int i)
inline FORCE_INLINE const Vector3r & getPosition0 (const unsigned int i) const
inline FORCE_INLINE void setPosition0 (const unsigned int i, const Vector3r &pos)
inline FORCE_INLINE Vector3r & getLastPosition (const unsigned int i)
inline FORCE_INLINE const Vector3r & getLastPosition (const unsigned int i) const
inline FORCE_INLINE void setLastPosition (const unsigned int i, const Vector3r &pos)
inline FORCE_INLINE Vector3r & getOldPosition (const unsigned int i)
inline FORCE_INLINE const Vector3r & getOldPosition (const unsigned int i) const
inline FORCE_INLINE void setOldPosition (const unsigned int i, const Vector3r &pos)
inline FORCE_INLINE Vector3r & getVelocity (const unsigned int i)
inline FORCE_INLINE const Vector3r & getVelocity (const unsigned int i) const
inline FORCE_INLINE void setVelocity (const unsigned int i, const Vector3r &vel)
inline FORCE_INLINE Vector3r & getAcceleration (const unsigned int i)
inline FORCE_INLINE const Vector3r & getAcceleration (const unsigned int i) const
inline FORCE_INLINE void setAcceleration (const unsigned int i, const Vector3r &accel)
inline FORCE_INLINE const Real getMass (const unsigned int i) const
inline FORCE_INLINE Real & getMass (const unsigned int i)
inline FORCE_INLINE void setMass (const unsigned int i, const Real mass)
inline FORCE_INLINE const Real getInvMass (const unsigned int i) const
inline FORCE_INLINE const unsigned int getNumberOfParticles () const
inline FORCE_INLINE const std::vector< Vector3r > & getVertices () const
inline FORCE_INLINE void resize (const unsigned int newSize)

Resize the array containing the particle data.

inline FORCE_INLINE void reserve (const unsigned int newSize)

Reserve the array containing the particle data.

inline FORCE_INLINE void release ()

Release the array containing the particle data.

inline FORCE_INLINE unsigned int size () const

Release the array containing the particle data.

Class ParticleRigidBodyContactConstraint

Class Documentation
class ParticleRigidBodyContactConstraint

Public Functions

inline ParticleRigidBodyContactConstraint()
inline ~ParticleRigidBodyContactConstraint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int particleIndex, const unsigned int rbIndex, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real stiffness, const Real frictionCoeff)
virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

std::array<unsigned int, 2> m_bodies

indices of the linked bodies

Real m_stiffness
Real m_frictionCoeff
Real m_sum_impulses
Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> m_constraintInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class ParticleTetContactConstraint

Class Documentation
class ParticleTetContactConstraint

Public Functions

inline ParticleTetContactConstraint()
inline ~ParticleTetContactConstraint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int particleIndex, const unsigned int solidIndex, const unsigned int tetindex, const Vector3r &bary, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real frictionCoeff)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)
virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

std::array<unsigned int, 2> m_bodies

indices of the linked bodies

unsigned int m_solidIndex
unsigned int m_tetIndex
Vector3r m_bary
Real m_lambda
Real m_frictionCoeff
Eigen::Matrix<Real, 3, 3, Eigen::DontAlign> m_constraintInfo
Real m_invMasses[4]
std::array<Vector3r, 4> m_x
std::array<Vector3r, 4> m_v

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class BoundingSphere

Class Documentation
class BoundingSphere

Computes smallest enclosing spheres of pointsets using Welzl’s algorithm : Tassilo Kugelstadt.

Public Functions

inline BoundingSphere()

default constructor sets the center and radius to zero.

inline BoundingSphere(Vector3r const &x, const Real r)

constructor which sets the center and radius

Parameters
  • x – 3d coordiantes of the center point

  • r – radius of the sphere

inline BoundingSphere(const Vector3r &a)

constructs a sphere for one point (with radius 0)

Parameters

a – 3d coordinates of point a

inline BoundingSphere(const Vector3r &a, const Vector3r &b)

constructs the smallest enclosing sphere for two points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

inline BoundingSphere(const Vector3r &a, const Vector3r &b, const Vector3r &c)

constructs the smallest enclosing sphere for three points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

  • c – 3d coordinates of point c

inline BoundingSphere(const Vector3r &a, const Vector3r &b, const Vector3r &c, const Vector3r &d)

constructs the smallest enclosing sphere for four points

Parameters
  • a – 3d coordinates of point a

  • b – 3d coordinates of point b

  • c – 3d coordinates of point c

  • d – 3d coordinates of point d

inline BoundingSphere(const std::vector<Vector3r> &p)

constructs the smallest enclosing sphere a given pointset

Parameters

p – vertices of the points

inline Vector3r const &x() const

Getter for the center of the sphere.

Returns

const reference of the sphere center

inline Vector3r &x()

Access function for center of the sphere.

Returns

reference of the sphere center

inline Real r() const

Getter for the radius.

Returns

Radius of the sphere

inline Real &r()

Access function for the radius.

Returns

Reference to the radius of the sphere

inline void setPoints(const std::vector<Vector3r> &p)

constructs the smallest enclosing sphere a given pointset

Parameters

p – vertices of the points

inline bool overlaps(BoundingSphere const &other) const

intersection test for two spheres

Parameters

other – other sphere to be tested for intersection

Returns

returns true when this sphere and the other sphere are intersecting

inline bool contains(BoundingSphere const &other) const

tests whether the given sphere other is contained in the sphere

Parameters

other – bounding sphere

Returns

returns true when the other is contained in this sphere or vice versa

inline bool contains(Vector3r const &other) const

tests whether the given point other is contained in the sphere

Parameters

other – 3d coordinates of a point

Returns

returns true when the point is contained in the sphere

Class PointCloudBSH

Inheritance Relationships
Base Type
Class Documentation
class PointCloudBSH : public PBD::KDTree<BoundingSphere>

Public Types

using super = KDTree<BoundingSphere>

Public Functions

PointCloudBSH()
void init(const Vector3r *vertices, const unsigned int numVertices)
virtual Vector3r const &entity_position(unsigned int i) const final
virtual void compute_hull(unsigned int b, unsigned int n, BoundingSphere &hull) const final
virtual void compute_hull_approx(unsigned int b, unsigned int n, BoundingSphere &hull) const final

Class PositionBasedCosseratRods

Class Documentation
class PositionBasedCosseratRods

Public Static Functions

static bool solve_StretchShearConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Quaternionr &q0, Real invMassq0, const Vector3r &stretchingAndShearingKs, const Real restLength, Vector3r &corr0, Vector3r &corr1, Quaternionr &corrq0)

Determine the position and orientation corrections for the stretch and shear constraint constraint (eq. 37 in the paper).

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • q0 – Quaternionr at the center of the edge

  • invMassq0 – inverse mass of the quaternion

  • stretchingAndShearingKs – stiffness coefficients for stretching and shearing

  • restLength – rest edge length

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corrq0 – orientation correction of quaternion

static bool solve_BendTwistConstraint(const Quaternionr &q0, Real invMassq0, const Quaternionr &q1, Real invMassq1, const Vector3r &bendingAndTwistingKs, const Quaternionr &restDarbouxVector, Quaternionr &corrq0, Quaternionr &corrq1)

Determine the position corrections for the bending and torsion constraint constraint (eq. 40 in the paper).

Parameters
  • q0 – first quaternion

  • invMassq0 – inverse mass of the first quaternion

  • q1 – second quaternion

  • invMassq1 – inverse Mass of the second quaternion

  • bendingAndTwistingKs – stiffness coefficients for stretching and shearing

  • restDarbouxVector – rest Darboux vector

  • corrq0 – position correction of first particle

  • corrq1 – position correction of second particle

Class PositionBasedDynamics

Class Documentation
class PositionBasedDynamics

Public Static Functions

static bool solve_DistanceConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Real restLength, const Real stiffness, Vector3r &corr0, Vector3r &corr1)

Determine the position corrections for a distance constraint between two particles:\(C(\mathbf{p}_0, \mathbf{p}_1) = \| \mathbf{p}_0 - \mathbf{p}_1\| - l_0 = 0\) More information can be found in the following papers: [12], [2], [5], [6],

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • restLength – rest length of distance constraint

  • stiffness – stiffness coefficient

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

static bool solve_DihedralConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restAngle, const Real stiffness, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for a dihedral bending constraint. For a pair of adjacent triangles \((\mathbf{p}_1, \mathbf{p}_3, \mathbf{p}_2)\) and \((\mathbf{p}_1, \mathbf{p}_2, \mathbf{p}_4)\) with the common edge \((\mathbf{p}_3, \mathbf{p}_4)\) a bilateral bending constraint is added by the constraint function

\[\begin{equation*} C_{bend}(\mathbf{p}_1, \mathbf{p}_2,\mathbf{p}_3, \mathbf{p}_4) = \text{acos}\left( \frac{\mathbf{p}_{2,1} \times \mathbf{p}_{3,1}}{|\mathbf{p}_{2,1} \times \mathbf{p}_{3,1}|} \cdot \frac{\mathbf{p}_{2,1} \times \mathbf{p}_{4,1}}{|\mathbf{p}_{2,1} \times \mathbf{p}_{4,1}|}\right)-\varphi_0 \end{equation*}\]
and stiffness \(k_{bend}\). The scalar \(\varphi_0\) is the initial dihedral angle between the two triangles and \(k_{bend}\)

is a global user parameter defining the bending stiffness.

More information can be found in the following papers:

[12], [2], [5], [6],

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • restAngle – rest angle \(\varphi_0\)

  • stiffness – stiffness coefficient

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

static bool solve_VolumeConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restVolume, const Real stiffness, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for a constraint that conserves the volume of single tetrahedron. Such a constraint has the form

\[\begin{equation*} C(\mathbf{p}_1, \mathbf{p}_2, \mathbf{p}_3, \mathbf{p}_4) = \frac{1}{6} \left(\mathbf{p}_{2,1} \times \mathbf{p}_{3,1}\right) \cdot \mathbf{p}_{4,1} - V_0, \end{equation*}\]
where \(\mathbf{p}_1\), \(\mathbf{p}_2\), \(\mathbf{p}_3\) and \(\mathbf{p}_4\) are the four corners of the tetrahedron and \(V_0\)

is its rest volume.

More information can be found in the following papers:

[12], [2], [5], [6],

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • restVolume – rest angle \(V_0\)

  • stiffness – stiffness coefficient

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

static bool solve_EdgePointDistanceConstraint(const Vector3r &p, Real invMass, const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Real restDist, const Real compressionStiffness, const Real stretchStiffness, Vector3r &corr, Vector3r &corr0, Vector3r &corr1)

Determine the position corrections for a constraint that preserves a rest distance between a point and an edge.

Parameters
  • p – position of point particle

  • invMass – inverse mass of point particle

  • p0 – position of first edge particle

  • invMass0 – inverse mass of first edge particle

  • p1 – position of second edge particle

  • invMass1 – inverse mass of second edge particle

  • restDist – rest distance of point and edge

  • compressionStiffness – stiffness coefficient for compression

  • stretchStiffness – stiffness coefficient for stretching

  • corr – position correction of point particle

  • corr0 – position correction of first edge particle

  • corr1 – position correction of second edge particle

static bool solve_TrianglePointDistanceConstraint(const Vector3r &p, Real invMass, const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Real restDist, const Real compressionStiffness, const Real stretchStiffness, Vector3r &corr, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2)

Determine the position corrections for a constraint that preserves a rest distance between a point and a triangle.

Parameters
  • p – position of point particle

  • invMass – inverse mass of point particle

  • p0 – position of first triangle particle

  • invMass0 – inverse mass of first triangle particle

  • p1 – position of second triangle particle

  • invMass1 – inverse mass of second triangle particle

  • p2 – position of third triangle particle

  • invMass2 – inverse mass of third triangle particle

  • restDist – rest distance of point and triangle

  • compressionStiffness – stiffness coefficient for compression

  • stretchStiffness – stiffness coefficient for stretching

  • corr – position correction of point particle

  • corr0 – position correction of first triangle particle

  • corr1 – position correction of second triangle particle

  • corr2 – position correction of third triangle particle

static bool solve_EdgeEdgeDistanceConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restDist, const Real compressionStiffness, const Real stretchStiffness, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for a constraint that preserves a rest distance between two edges.

Parameters
  • p0 – position of first particle of edge 0

  • invMass0 – inverse mass of first particle of edge 0

  • p1 – position of second particle of edge 0

  • invMass1 – inverse mass of second particle of edge 0

  • p2 – position of first particle of edge 1

  • invMass2 – inverse mass of first particle of edge 1

  • p3 – position of second particle of edge 1

  • invMass3 – inverse mass of second particle of edge 1

  • restDist – rest distance between both edges

  • compressionStiffness – stiffness coefficient for compression

  • stretchStiffness – stiffness coefficient for stretching

  • corr0 – position correction of first particle of edge 0

  • corr1 – position correction of second particle of edge 0

  • corr2 – position correction of first particle of edge 1

  • corr3 – position correction of second particle of edge 1

static bool init_IsometricBendingConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Vector3r &p3, Matrix4r &Q)

Initialize the local stiffness matrix Q. The matrix is required by the solver step. It must only be recomputed if the rest shape changes.

Bending is simulated for the angle on (p2, p3) between the triangles (p0, p2, p3) and (p1, p3, p2).

Parameters
  • p0 – point 0 of stencil

  • p1 – point 1 of stencil

  • p2 – point 2 of stencil

  • p3 – point 3 of stencil

  • Q – returns the local stiffness matrix which is required by the solver

static bool solve_IsometricBendingConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Matrix4r &Q, const Real stiffness, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for the isometric bending constraint. This constraint can be used for almost inextensible surface models.

More information can be found in:

[6], [4]

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • Q – local stiffness matrix which must be initialized by calling init_IsometricBendingConstraint()

  • stiffness – stiffness coefficient for bending

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

static bool init_ShapeMatchingConstraint(const Vector3r x0[], const Real invMasses[], const int numPoints, Vector3r &restCm)

Initialize rest configuration infos for one shape matching cluster which are required by the solver step. It must only be reinitialized if the rest shape changes.

Parameters
  • x0 – rest configuration of all particles in the cluster

  • invMasses – inverse masses of all particles in the cluster

  • numPoints – number of particles in the cluster

  • restCm – returns the center of mass of the rest configuration

static bool solve_ShapeMatchingConstraint(const Vector3r x0[], const Vector3r x[], const Real invMasses[], const int numPoints, const Vector3r &restCm, const Real stiffness, const bool allowStretch, Vector3r corr[], Matrix3r *rot = NULL)

Determine the position corrections for a shape matching constraint.

More information can be found in:

[6], [2], [5], [11], [3], [8]

Parameters
  • x0 – rest configuration of all particles in the cluster

  • x – current configuration of all particles in the cluster

  • invMasses – invMasses inverse masses of all particles in the cluster

  • numPoints – number of particles in the cluster

  • restCm – center of mass of the rest configuration

  • stiffness – stiffness coefficient

  • allowStretch – allow stretching

  • corr – position corrections for all particles in the cluster

  • rot – returns determined rotation matrix

static bool init_StrainTriangleConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, Matrix2r &invRestMat)

Initialize rest configuration infos which are required by the solver step. Recomputation is only necessary when rest shape changes.

The triangle is defined in the xy plane.

Parameters
  • p0 – point 0 of triangle

  • p1 – point 1 of triangle

  • p2 – point 2 of triangle

  • invRestMat – returns a matrix required by the solver

static bool solve_StrainTriangleConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Matrix2r &invRestMat, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const bool normalizeStretch, const bool normalizeShear, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2)

Solve triangle constraint with strain based dynamics and return position corrections.

More information can be found in:

[6], [13]

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • invRestMat – precomputed matrix determined by init_StrainTriangleConstraint()

  • xxStiffness – stiffness coefficient for xx stretching

  • yyStiffness – stiffness coefficient for yy stretching

  • xyStiffness – stiffness coefficient for xy shearing

  • normalizeStretch – should stretching be normalized

  • normalizeShear – should shearing be normalized

  • corr0 – position correction for point 0

  • corr1 – position correction for point 1

  • corr2 – position correction for point 2

static bool init_StrainTetraConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Vector3r &p3, Matrix3r &invRestMat)

Initialize rest configuration infos which are required by the solver step. Recomputation is only necessary when rest shape changes.

Parameters
  • p0 – point 0 of tet

  • p1 – point 1 of tet

  • p2 – point 2 of tet

  • p3 – point 3 of tet

  • invRestMat – returns a matrix required by the solver

static bool solve_StrainTetraConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Matrix3r &invRestMat, const Vector3r &stretchStiffness, const Vector3r &shearStiffness, const bool normalizeStretch, const bool normalizeShear, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)
static void computeGradCGreen(Real restVolume, const Matrix3r &invRestMat, const Matrix3r &sigma, Vector3r *J)
static void computeGreenStrainAndPiolaStress(const Vector3r &x1, const Vector3r &x2, const Vector3r &x3, const Vector3r &x4, const Matrix3r &invRestMat, const Real restVolume, const Real mu, const Real lambda, Matrix3r &epsilon, Matrix3r &sigma, Real &energy)
static void computeGreenStrainAndPiolaStressInversion(const Vector3r &x1, const Vector3r &x2, const Vector3r &x3, const Vector3r &x4, const Matrix3r &invRestMat, const Real restVolume, const Real mu, const Real lambda, Matrix3r &epsilon, Matrix3r &sigma, Real &energy)
static bool init_FEMTriangleConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, Real &area, Matrix2r &invRestMat)

Implementation of the finite element method described in

Jan Bender, Dan Koschier, Patrick Charrier and Daniel Weber,

”Position-Based Simulation of Continuous Materials”,

Computers & Graphics 44, 2014

Initialize rest configuration infos which are required by the solver step. Recomputation is only necessary when rest shape changes.

static bool solve_FEMTriangleConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Real &area, const Matrix2r &invRestMat, const Real youngsModulusX, const Real youngsModulusY, const Real youngsModulusShear, const Real poissonRatioXY, const Real poissonRatioYX, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2)

Implementation of the finite element method described in

Jan Bender, Dan Koschier, Patrick Charrier and Daniel Weber,

”Position-Based Simulation of Continuous Materials”,

Computers & Graphics 44, 2014

Solve the continuum mechanical constraint defined for a triangle.

static bool init_FEMTetraConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Vector3r &p3, Real &volume, Matrix3r &invRestMat)

Implementation of the finite element method described in

Jan Bender, Dan Koschier, Patrick Charrier and Daniel Weber,

”Position-Based Simulation of Continuous Materials”,

Computers & Graphics 44, 2014

Initialize rest configuration infos which are required by the solver step. Recomputation is only necessary when rest shape changes.

static bool solve_FEMTetraConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restVolume, const Matrix3r &invRestMat, const Real youngsModulus, const Real poissonRatio, const bool handleInversion, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Implementation of the finite element method described in

Jan Bender, Dan Koschier, Patrick Charrier and Daniel Weber,

”Position-Based Simulation of Continuous Materials”,

Computers & Graphics 44, 2014

Solve the continuum mechanical constraint defined for a tetrahedron.

static bool init_ParticleTetContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Real invMass[], const Vector3r x[], const Vector3r v[], const Vector3r &bary, const Vector3r &normal, Eigen::Matrix<Real, 3, 3, Eigen::DontAlign> &constraintInfo)

Initialize contact between a particle and a tetrahedron and return info which is required by the solver step.

Parameters
  • invMass0 – inverse mass of particle which collides with tet

  • x0 – particle position

  • v0 – particle velocity

  • invMass – inverse masses of tet particles

  • x – positions of tet particles

  • v – velocities of tet particles

  • bary – barycentric coordinates of contact point in tet

  • normal – contact normal in body 1

  • constraintInfo

    Stores the local and global position of the contact points and the contact normal.

    The joint info contains the following columns:

    0: contact normal in body 1 (global)

    1: contact tangent (global)

    0,2: 1.0 / normal^T * K * normal

    1,2: maximal impulse in tangent direction

static bool solve_ParticleTetContactConstraint(const Real invMass0, const Vector3r &x0, const Real invMass[], const Vector3r x[], const Vector3r &bary, Eigen::Matrix<Real, 3, 3, Eigen::DontAlign> &constraintInfo, Real &lambda, Vector3r &corr0, Vector3r corr[])

Perform a solver step for a contact constraint between a particle and a tetrahedron. A contact constraint handles collisions and resting contacts between the bodies. The contact info must be generated in each time step.

Parameters
  • invMass0 – inverse mass of particle which collides with tet

  • x0 – particle position

  • invMass – inverse masses of tet particles

  • x – positions of tet particles

  • bary – barycentric coordinates of contact point in tet

  • constraintInfo – information which is required by the solver. This information must be generated in the beginning by calling init_RigidBodyContactConstraint().

  • corr0 – position correction of particle

  • corr – position corrections of tet particles

static bool velocitySolve_ParticleTetContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Real invMass[], const Vector3r x[], const Vector3r v[], const Vector3r &bary, const Real lambda, const Real frictionCoeff, Eigen::Matrix<Real, 3, 3, Eigen::DontAlign> &constraintInfo, Vector3r &corr_v0, Vector3r corr_v[])

Perform a solver step for a contact constraint between a particle and a tetrahedron. A contact constraint handles collisions and resting contacts between the bodies. The contact info must be generated in each time step.

Parameters
  • invMass0 – inverse mass of particle which collides with tet

  • x0 – particle position

  • v0 – particle velocity

  • invMass – inverse masses of tet particles

  • x – positions of tet particles

  • v – velocities of tet particles

  • bary – barycentric coordinates of contact point in tet

  • frictionCoeff – friction coefficient

  • constraintInfo – information which is required by the solver. This information must be generated in the beginning by calling init_RigidBodyContactConstraint().

  • corr_v0 – velocity correction of particle

  • corr_v – velocity corrections of tet particles

Class PositionBasedElasticRods

Class Documentation
class PositionBasedElasticRods

Public Static Functions

static bool solve_PerpendiculaBisectorConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Real stiffness, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2)

Determine the position corrections for a perpendicular bisector constraint:\(C(\mathbf{p}_0, \mathbf{p}_1, \mathbf{p}_2) = ( \mathbf{p}_1 - 0.5 (\mathbf{p}_0 + \mathbf{p}_1))^T (\mathbf{p}_1 - \mathbf{p}_0) = 0\)

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • stiffness – stiffness coefficient

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

static bool solve_GhostPointEdgeDistanceConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Real stiffness, const Real ghostEdgeRestLength, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2)

Determine the position corrections for a constraint that enforces a rest length between an edge and a ghost point:\(C(\mathbf{p}_0, \mathbf{p}_1, \mathbf{p}_2) = \| ( 0.5 (\mathbf{p}_0 + \mathbf{p}_1) - \mathbf{p}_2 \| - L_0 = 0\)

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • stiffness – stiffness coefficient

  • ghostEdgeRestLength – rest length

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

static bool solve_DarbouxVectorConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Vector3r &p4, Real invMass4, const Vector3r &bendingAndTwistingKs, const Real midEdgeLength, const Vector3r &restDarbouxVector, Vector3r &oa, Vector3r &ob, Vector3r &oc, Vector3r &od, Vector3r &oe)

Determine the position corrections for the Darboux vector constraint (eq. 21 in the paper). See the paper appendix for derivation details

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • p4 – position of fifth particle

  • invMass4 – inverse mass of fifth particle

  • bendingAndTwistingKs – stiffness coefficients for bending and twisting

  • midEdgeLength – average edge length

  • restDarbouxVector – Darboux vector in rest state

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

  • corr4 – position correction of fifth particle

static bool computeMaterialFrame(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, Matrix3r &frame)

Computes the material frame (eq. 3 in the paper)

static bool computeDarbouxVector(const Matrix3r &dA, const Matrix3r &dB, const Real mid_edge_length, Vector3r &darboux_vector)

Computes the Darboux Vector (eq. 10 in the paper)

static bool computeMaterialFrameDerivative(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Matrix3r &d, Matrix3r &d1p0, Matrix3r &d1p1, Matrix3r &d1p2, Matrix3r &d2p0, Matrix3r &d2p1, Matrix3r &d2p2, Matrix3r &d3p0, Matrix3r &d3p1, Matrix3r &d3p2)

Computes the material frame derivatives (eq. 43, 44 and 45 in the appendix)

static bool computeDarbouxGradient(const Vector3r &darboux_vector, const Real length, const Matrix3r &dA, const Matrix3r &dB, const Matrix3r[3][3], const Matrix3r[3][3], Matrix3r &omega_pa, Matrix3r &omega_pb, Matrix3r &omega_pc, Matrix3r &omega_pd, Matrix3r &omega_pe)

Compute the Darboux gradient in respect to each point (eq. 49-53 in the appendix)

Class PositionBasedFluids

Class Documentation
class PositionBasedFluids

Public Static Functions

static bool computePBFDensity(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, Real &density_err, Real &density)

Perform an SPH computation of the density of a fluid particle:

\[\begin{equation*} \rho_i = \sum_j m_j W(\mathbf{x}_i-\mathbf{x}_j). \end{equation*}\]
An additional term is added for neighboring boundary particles according to [1]

in order to perform boundary handling.

Remark: A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers: [9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • density_err – returns the clamped density error (can be used for enforcing a maximal global density error)

  • density – return the density

static bool computePBFLagrangeMultiplier(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const Real density, const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, Real &lambda)

Compute Lagrange multiplier \(\lambda_i\) for a fluid particle which is required by the solver step:

\[\begin{equation*} \lambda_i = -\frac{C_i(\mathbf{x}_1,...,\mathbf{x}_n)}{\sum_k \|\nabla_{\mathbf{x}_k} C_i\|^2 + \varepsilon} \end{equation*}\]
with the constraint gradient:
\[\begin{split}\begin{equation*} \nabla_{\mathbf{x}_k}C_i = \frac{m_j}{\rho_0} \begin{cases} \sum\limits_j \nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = i \\ -\nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = j. \end{cases} \end{equation*}\end{split}\]
Remark: The computation of the gradient is extended for neighboring boundary particles according to [1]

to perform a boundary handling. A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers:

[9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • density – density of current fluid particle

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • lambda – returns the Lagrange multiplier

static bool solveDensityConstraint(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, const Real lambda[], Vector3r &corr)

Perform a solver step for a fluid particle:

\[\begin{equation*} \Delta\mathbf{x}_{i} = \frac{m_j}{\rho_0}\sum\limits_j{\left(\lambda_i + \lambda_j\right)\nabla W(\mathbf{x}_i-\mathbf{x}_j, h)}, \end{equation*}\]
where \(h\) is the smoothing length of the kernel function \(W\)

.

Remark: The computation of the position correction is extended for neighboring boundary particles according to

[1]

to perform a boundary handling. A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers:

[9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • lambda – Lagrange multipliers

  • corr – returns the position correction for the current fluid particle

Class PositionBasedGenericConstraints

Class Documentation
class PositionBasedGenericConstraints

Generic constraints provide the possibility to experiment with new constraint functions very easily. Only a callback for the constraint function and optionally for the gradient of the constraint must be provided.

Examples and more details can be found here: pageGenericConstraints

Public Static Functions

template<unsigned int numberOfParticles, unsigned int dim>
static bool solve_GenericConstraint(const Real invMass[numberOfParticles], const Vector3r x[numberOfParticles], void *userData, void (*constraintFct)(const unsigned int numParticles, const Real invMass[], const Vector3r x[], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), void (*gradientFct)(const unsigned int i, const unsigned int numParticles, const Real invMass[], const Vector3r x[], void *userData, Eigen::Matrix<Real, dim, 3> &jacobian), Vector3r corr_x[numberOfParticles])

Determine the position corrections for a constraint function with a known gradient function.

More information can be found here: secGenericConstraintsCGFct

Parameters
  • invMass – inverse mass of constrained particles

  • x – positions of constrained particles

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • gradientFct – gradient callback

  • corr_x – position corrections of constrained particles

template<unsigned int numberOfParticles, unsigned int dim>
static bool solve_GenericConstraint(const Real invMass[numberOfParticles], const Vector3r x[numberOfParticles], void *userData, void (*constraintFct)(const unsigned int numParticles, const Real invMass[], const Vector3r x[], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), Vector3r corr_x[numberOfParticles])

Determine the position corrections for a constraint function. This method approximates the gradient using finite differences. Note that it is faster to define the gradient function explicitly.

More information can be found here: secGenericConstraintsCFct

Parameters
  • invMass – inverse mass of constrained particles

  • x – positions of constrained particles

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • corr_x – position corrections of constrained particles

template<unsigned int numberOfParticles, unsigned int dim>
static void approximateGradient(const unsigned int i, const Real invMass[], const Vector3r x[], void *userData, void (*constraintFct)(const unsigned int numParticles, const Real invMass[], const Vector3r x[], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), Eigen::Matrix<Real, dim, 3> &jacobian)

Determines the Jacobian of the i-th particle with finite differences.

Parameters
  • i – index of particle for which the gradient should be computed

  • invMass – inverse mass of constrained particles

  • x – positions of constrained particles

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • jacobian – Jacobian of the i-th particle

template<unsigned int numberOfRigidBodies, unsigned int dim>
static bool solve_GenericConstraint(const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, void (*constraintFct)(const unsigned int numRigidBodies, const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), void (*gradientFct)(const unsigned int i, const unsigned int numRigidBodies, const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, Eigen::Matrix<Real, dim, 6> &jacobian), Vector3r corr_x[numberOfRigidBodies], Quaternionr corr_q[numberOfRigidBodies])

Determine the position corrections for a constraint function with a known gradient function.

More information can be found here: secGenericConstraintsCGFct

Parameters
  • invMass – inverse mass of constrained rigid bodies

  • x – positions of constrained rigid bodies

  • inertiaInverseW – inverse inertia tensor in world coordinates of the rigid bodies

  • q – rotation of the rigid bodies

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • gradientFct – gradient callback

  • corr_x – position corrections of the constrained rigid bodies

  • corr_q – rotation corrections of the constrained rigid bodies

template<unsigned int numberOfRigidBodies, unsigned int dim>
static bool solve_GenericConstraint(const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, void (*constraintFct)(const unsigned int numParticles, const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), Vector3r corr_x[numberOfRigidBodies], Quaternionr corr_q[numberOfRigidBodies])

Determine the position corrections for a constraint function. This method approximates the gradient using finite differences. Note that it is faster to define the gradient function explicitly.

More information can be found here: secGenericConstraintsCFct

Parameters
  • invMass – inverse mass of constrained rigid bodies

  • x – positions of constrained rigid bodies

  • inertiaInverseW – inverse inertia tensor in world coordinates of the rigid bodies

  • q – rotation of the rigid bodies

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • corr_x – position corrections of the constrained rigid bodies

  • corr_q – rotation corrections of the constrained rigid bodies

template<unsigned int numberOfRigidBodies, unsigned int dim>
static void approximateGradient(const unsigned int i, const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, void (*constraintFct)(const unsigned int numParticles, const Real invMass[numberOfRigidBodies], const Vector3r x[numberOfRigidBodies], const Matrix3r inertiaInverseW[numberOfRigidBodies], const Quaternionr q[numberOfRigidBodies], void *userData, Eigen::Matrix<Real, dim, 1> &constraintValue), Eigen::Matrix<Real, dim, 6> &jacobian)

Determines the Jacobian of the i-th rigid body with finite differences.

Parameters
  • i – index of rigid body for which the gradient should be computed

  • invMass – inverse mass of constrained rigid bodies

  • x – positions of constrained rigid bodies

  • inertiaInverseW – inverse inertia tensor in world coordinates of the rigid bodies

  • q – rotation of the rigid bodies

  • userData – user data which is required in the callback functions

  • constraintFct – constraint callback

  • jacobian – Jacobian of the i-th rigid body

static void computeMatrixG(const Quaternionr &q, Eigen::Matrix<Real, 4, 3> &G)

Compute matrix that is required to transform quaternion in a 3D representation.

Class PositionBasedRigidBodyDynamics

Class Documentation
class PositionBasedRigidBodyDynamics

Public Static Functions

static bool init_BallJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &jointPosition, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo)

Initialize ball joint and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointPosition – position of ball joint

  • jointInfo – Stores the local and global positions of the connector points. The first two columns store the local connectors in body 0 and 1, respectively, while the last two columns contain the global connector positions which have to be updated in each simulation step by calling update_BallJoint()

    .

    The joint info contains the following columns:

    0: connector in body 0 (local)

    1: connector in body 1 (local)

    2: connector in body 0 (global)

    3: connector in body 1 (global)

static bool update_BallJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &ballJointInfo)

Update ball joint info which is required by the solver step. The ball joint info must be generated in the initialization process of the model by calling the function init_BallJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • ballJointInfo – ball joint information which should be updated

static bool solve_BallJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &ballJointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a ball joint which links two rigid bodies. A ball joint removes three translational degrees of freedom between the bodies. The ball joint info must be generated in the initialization process of the model by calling the function init_BallJoint() and updated each time the bodies change their state by update_BallJoint()

.

More information can be found in:

[7]

doxyoutput/xml/balljoint.jpgdoxyoutput/xml/balljoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • ballJointInfo – Ball joint information which is required by the solver. This information must be generated in the beginning by calling init_BallJoint() and updated each time the bodies change their state by update_BallJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_BallOnLineJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &position, const Vector3r &direction, Eigen::Matrix<Real, 3, 10, Eigen::DontAlign> &jointInfo)

Initialize ball-on-line-joint and return information which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • position – position of joint

  • direction – direction of line

  • jointInfo – Stores the local and global positions of the connector points. The first two columns store the local connectors in body 0 and 1, respectively. The next three columns contain a coordinate system for the constraint correction (a full coordinate system where the x-axis is the slider axis) in local coordinates. The last five columns contain the global connector positions and the constraint coordinate system in world space which have to be updated in each simulation step by calling update_BallOnLineJoint()

    .

    The joint info contains the following columns:

    0: connector in body 0 (local)

    1: connector in body 1 (local)

    2-4: coordinate system of body 0 (local)

    5: connector in body 0 (global)

    6: connector in body 1 (global)

    7-9: coordinate system of body 0 (global)

static bool update_BallOnLineJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 3, 10, Eigen::DontAlign> &jointInfo)

Update ball-on-line-joint information which is required by the solver step. The ball-on-line-joint info must be generated in the initialization process of the model by calling the function init_BallOnLineJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – ball-on-line-joint information which should be updated

static bool solve_BallOnLineJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 3, 10, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a ball-on-line-joint which links two rigid bodies. A ball-on-line-joint removes two translational degrees of freedom between the bodies. The joint info must be generated in the initialization process of the model by calling the function init_BallOnLineJoint() and updated each time the bodies change their state by update_BallOnLineJoint()

.

More information can be found in:

[7]

doxyoutput/xml/ballonlinejoint.jpgdoxyoutput/xml/ballonlinejoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • jointInfo – Ball joint information which is required by the solver. This information must be generated in the beginning by calling init_BallJoint() and updated each time the bodies change their state by update_BallJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_HingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &hingeJointPosition, const Vector3r &hingeJointAxis, Eigen::Matrix<Real, 4, 7, Eigen::DontAlign> &hingeJointInfo)

Initialize hinge joint and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • hingeJointPosition – position of hinge joint

  • hingeJointAxis – axis of hinge joint

  • hingeJointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0-1: projection matrix Pr for the rotational part

    2: connector in body 0 (local)

    3: connector in body 1 (local)

    4: connector in body 0 (global)

    5: connector in body 1 (global)

    6: hinge axis in body 0 (local) used for rendering

    The joint info stores first the info of the first body (the connector point and a full coordinate system where the x-axis is the hinge axis) and then the info of the second body (the connector point and the hinge axis). The info must be updated in each simulation step by calling

    update_HingeJoint().

static bool update_HingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 7, Eigen::DontAlign> &hingeJointInfo)

Update hinge joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_HingeJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • hingeJointInfo – hinge joint information which should be updated

static bool solve_HingeJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 4, 7, Eigen::DontAlign> &hingeJointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a hinge joint which links two rigid bodies. A hinge joint removes three translational and two rotational degrees of freedom between the bodies. The hinge joint info must be generated in the initialization process of the model by calling the function init_HingeJoint() and updated each time the bodies change their state by update_HingeJoint()

.

More information can be found in:

[7]

doxyoutput/xml/hingejoint.jpgdoxyoutput/xml/hingejoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • hingeJointInfo – Hinge joint information which is required by the solver. This information must be generated in the beginning by calling init_HingeJoint() and updated each time the bodies change their state by update_HingeJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_UniversalJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &jointPosition, const Vector3r &jointAxis0, const Vector3r &jointAxis1, Eigen::Matrix<Real, 3, 8, Eigen::DontAlign> &jointInfo)

Initialize universal joint and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointPosition – position of universal joint

  • jointAxis0 – first axis of universal joint

  • jointAxis1 – second axis of universal joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0: connector in body 0 (local)

    1: connector in body 1 (local)

    2: constraint axis 0 in body 0 (local)

    3: constraint axis 1 in body 1 (local)

    4: connector in body 0 (global)

    5: connector in body 1 (global)

    6: constraint axis 0 in body 0 (global)

    7: constraint axis 1 in body 1 (global)

    The info must be updated in each simulation step by calling

    update_UniversalJoint().

static bool update_UniversalJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 3, 8, Eigen::DontAlign> &jointInfo)

Update universal joint info which is required by the solver step. The joint info must be generated in the initializatgion process of the model by calling the function init_UniversalJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – universal joint information which should be updated

static bool solve_UniversalJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 3, 8, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a universal joint which links two rigid bodies. A universal joint removes three translational and one rotational degree of freedom between the bodies. The universal joint info must be generated in the initialization process of the model by calling the function init_UniversalJoint() and updated each time the bodies change their state by update_UniversalJoint()

.

More information can be found in:

[7]

doxyoutput/xml/universaljoint.jpgdoxyoutput/xml/universaljoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • jointInfo – Universal joint information which is required by the solver. This information must be generated in the beginning by calling init_UniversalJoint() and updated each time the bodies change their state by update_UniversalJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_SliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &sliderJointAxis, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Initialize slider joint and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • sliderJointAxis – axis of slider joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    jointInfo contains

    0: coordinate system in body 0, where the x-axis is the slider axis (local)

    1: coordinate system in body 0, where the x-axis is the slider axis (global)

    2: 2D vector d = P * (x0 - x1), where P projects the vector onto a plane perpendicular to the slider axis

    3-5: projection matrix Pr for the rotational part

    The info must be updated in each simulation step by calling update_SliderJoint().

static bool update_SliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Update slider joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_SliderJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – slider joint information which should be updated

static bool solve_SliderJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a slider joint which links two rigid bodies. A slider joint removes two translational and three rotational degrees of freedom between the bodies. The slider joint info must be generated in the initialization process of the model by calling the function init_SliderJoint() and updated each time the bodies change their state by update_SliderJoint()

.

More information can be found in:

[7]

doxyoutput/xml/sliderjoint.jpgdoxyoutput/xml/sliderjoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • jointInfo – Slider joint information which is required by the solver. This information must be generated in the beginning by calling init_SliderJoint() and updated each time the bodies change their state by update_SliderJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_TargetPositionMotorSliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &sliderJointAxis, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Initialize a motor slider joint which is able to enforce a target position and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • sliderJointAxis – axis of slider joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0: slider axis in body 0 (local)

    1: slider axis in body 0 (global)

    2: distance vector d = (x0 - x1)

    3-5: projection matrix Pr for the rotational part

    The info must be updated in each simulation step by calling

    update_TargetPositionMotorSliderJoint().

static bool update_TargetPositionMotorSliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Update motor slider joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_TargetPositionMotorSliderJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – slider joint information which should be updated

static bool solve_TargetPositionMotorSliderJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Real targetPosition, const Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a motor slider joint which links two rigid bodies. A motor slider joint removes two translational and three rotational degrees of freedom between the bodies. Moreover, a target position can be enforced on the remaining translation axis. The motor slider joint info must be generated in the initialization process of the model by calling the function init_TargetPositionMotorSliderJoint() and updated each time the bodies change their state by update_TargetPositionMotorSliderJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorsliderjoint.jpgdoxyoutput/xml/motorsliderjoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • targetPosition – target position of the servo motor

  • jointInfo – Motor slider joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetPositionMotorSliderJoint() and updated each time the bodies change their state by update_TargetPositionMotorSliderJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_TargetVelocityMotorSliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &sliderJointAxis, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Initialize a motor slider joint which is able to enforce a target velocity and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • sliderJointAxis – axis of slider joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0: coordinate system in body 0, where the x-axis is the slider axis (local)

    1: coordinate system in body 0, where the x-axis is the slider axis (global)

    2: 2D vector d = P * (x0 - x1), where P projects the vector onto a plane perpendicular to the slider axis

    3-5: projection matrix Pr for the rotational part

    The info must be updated in each simulation step by calling

    update_TargetVelocityMotorSliderJoint().

static bool update_TargetVelocityMotorSliderJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Update motor slider joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorSliderJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – slider joint information which should be updated

static bool solve_TargetVelocityMotorSliderJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a motor slider joint which links two rigid bodies. A motor slider joint removes two translational and three rotational degrees of freedom between the bodies. Moreover, a target velocity can be enforced on the remaining translation axis. The motor slider joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorSliderJoint() and updated each time the bodies change their state by update_TargetVelocityMotorSliderJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorsliderjoint.jpgdoxyoutput/xml/motorsliderjoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • jointInfo – Motor slider joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetVelocityMotorSliderJoint() and updated each time the bodies change their state by update_TargetVelocityMotorSliderJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool velocitySolve_TargetVelocityMotorSliderJoint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Vector3r &omega0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Vector3r &omega1, const Real targetVelocity, const Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo, Vector3r &corr_v0, Vector3r &corr_omega0, Vector3r &corr_v1, Vector3r &corr_omega1)

Perform a velocity solver step for a motor slider joint which links two rigid bodies. A motor slider joint removes two translational and three rotational degrees of freedom between the bodies. Moreover, a target velocity can be enforced on the remaining translation axis. The motor slider joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorSliderJoint() and updated each time the bodies change their state by update_TargetVelocityMotorSliderJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorsliderjoint.jpgdoxyoutput/xml/motorsliderjoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • omega0 – angular velocity of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • omega1 – angular velocity of second body

  • targetVelocity – target velocity of the motor

  • jointInfo – Motor slider joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetVelocityMotorSliderJoint() and updated each time the bodies change their state by update_TargetVelocityMotorSliderJoint().

  • corr_v0 – velocity correction of first body

  • corr_omega0 – angular velocity correction of first body

  • corr_v1 – velocity correction of second body

  • corr_omega1 – angular velocity correction of second body

static bool init_TargetAngleMotorHingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &hingeJointPosition, const Vector3r &hingeJointAxis, Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo)

Initialize a motor hinge joint which is able to enforce a target angle and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • hingeJointPosition – position of hinge joint

  • hingeJointAxis – axis of hinge joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0-2: projection matrix Pr for the rotational part

    3: connector in body 0 (local)

    4: connector in body 1 (local)

    5: connector in body 0 (global)

    6: connector in body 1 (global)

    7: hinge axis in body 0 (local) used for rendering

    The info must be updated in each simulation step by calling

    update_TargetAngleMotorHingeJoint().

static bool update_TargetAngleMotorHingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo)

Update motor hinge joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_TargetAngleMotorHingeJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – motor hinge joint information which should be updated

static bool solve_TargetAngleMotorHingeJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Real targetAngle, const Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a motor hinge joint which links two rigid bodies. A motor hinge joint removes three translational and two rotational degrees of freedom between the bodies. Moreover, a target angle can be enforced on the remaining rotation axis. The motor hinge joint info must be generated in the initialization process of the model by calling the function init_TargetAngleMotorHingeJoint() and updated each time the bodies change their state by update_TargetAngleMotorHingeJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorhingejoint.jpgdoxyoutput/xml/motorhingejoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • targetAngle – target angle of the servo motor

  • jointInfo – Motor hinge joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetAngleMotorHingeJoint() and updated each time the bodies change their state by update_TargetAngleMotorHingeJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_TargetVelocityMotorHingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &hingeJointPosition, const Vector3r &hingeJointAxis, Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo)

Initialize a motor hinge joint which is able to enforce a target velocity and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • hingeJointPosition – position of hinge joint

  • hingeJointAxis – axis of hinge joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0-1: projection matrix Pr for the rotational part

    2: connector in body 0 (local)

    3: connector in body 1 (local)

    4: connector in body 0 (global)

    5: connector in body 1 (global)

    6: hinge axis in body 0 (local)

    7: hinge axis in body 0 (global)

    The info must be updated in each simulation step by calling update_TargetVelocityMotorHingeJoint().

static bool update_TargetVelocityMotorHingeJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo)

Update motor hinge joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorHingeJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – motor hinge joint information which should be updated

static bool solve_TargetVelocityMotorHingeJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a motor hinge joint which links two rigid bodies. A motor hinge joint removes three translational and two rotational degrees of freedom between the bodies. Moreover, a target velocity can be enforced on the remaining rotation axis by calling the function velocitySolve_TargetVelocityMotorHingeJoint(). The motor hinge joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorHingeJoint() and updated each time the bodies change their state by update_TargetVelocityMotorHingeJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorhingejoint.jpgdoxyoutput/xml/motorhingejoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • jointInfo – Motor hinge joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetVelocityMotorHingeJoint() and updated each time the bodies change their state by update_TargetVelocityMotorHingeJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool velocitySolve_TargetVelocityMotorHingeJoint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Matrix3r &inertiaInverseW0, const Vector3r &omega0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Vector3r &omega1, const Real targetAngularVelocity, const Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> &jointInfo, Vector3r &corr_v0, Vector3r &corr_omega0, Vector3r &corr_v1, Vector3r &corr_omega1)

Perform a velocity solver step for a motor hinge joint which links two rigid bodies. A motor hinge joint removes three translational and two rotational degrees of freedom between the bodies. Moreover, a target velocity can be enforced on the remaining rotation axis. The motor hinge joint info must be generated in the initialization process of the model by calling the function init_TargetVelocityMotorHingeJoint() and updated each time the bodies change their state by update_TargetVelocityMotorHingeJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorhingejoint.jpgdoxyoutput/xml/motorhingejoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • omega0 – angular velocity of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • omega1 – angular velocity of second body

  • targetAngularVelocity – target angular velocity of the motor

  • jointInfo – Motor hinge joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetVelocityMotorHingeJoint() and updated each time the bodies change their state by update_TargetVelocityMotorHingeJoint().

  • corr_v0 – velocity correction of first body

  • corr_omega0 – angular velocity correction of first body

  • corr_v1 – velocity correction of second body

  • corr_omega1 – angular velocity correction of second body

static bool init_RigidBodyParticleBallJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, Eigen::Matrix<Real, 3, 2, Eigen::DontAlign> &jointInfo)

Initialize ball joint between a rigid body and a particle at the position of the particle and return info which is required by the solver step.

Parameters
  • x0 – center of mass of the rigid body

  • q0 – rotation of the rigid body body

  • x1 – position of the particle

  • jointInfo – Stores the local and global position of the connector point in the rigid body. The info must be updated in each simulation step by calling update_RigidBodyParticleBallJoint()

    .

    The joint info contains the following columns:

    0: connector in rigid body (local)

    1: connector in rigid body (global)

static bool update_RigidBodyParticleBallJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, Eigen::Matrix<Real, 3, 2, Eigen::DontAlign> &jointInfo)

Update joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_RigidBodyParticleBallJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of the rigid body

  • q0 – rotation of the rigid body body

  • x1 – position of the particle

  • jointInfo – ball joint information which should be updated

static bool solve_RigidBodyParticleBallJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Eigen::Matrix<Real, 3, 2, Eigen::DontAlign> &jointInfo, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1)

Perform a solver step for a ball joint which links a rigid body and a particle. The joint info must be generated in the initialization process of the model by calling the function init_RigidBodyParticleBallJoint() and updated each time the rigid body changes its state by update_RigidBodyParticleBallJoint()

.

More information can be found in:

[7]

Parameters
  • invMass0 – inverse mass of rigid body

  • x0 – center of mass of rigid body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of rigid body

  • q0 – rotation of rigid body

  • invMass1 – inverse mass of particle

  • x1 – position of particle

  • jointInfo – Joint information which is required by the solver. This information must be generated in the beginning by calling init_RigidBodyParticleBallJoint() and updated each time the rigid body changes its state by update_RigidBodyParticleBallJoint().

  • corr_x0 – position correction of the center of mass of the rigid body

  • corr_q0 – rotation correction of the rigid body

  • corr_x1 – position correction of the particle

static bool init_RigidBodyContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Vector3r &omega0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Vector3r &omega1, const Vector3r &cp0, const Vector3r &cp1, const Vector3r &normal, const Real restitutionCoeff, Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> &constraintInfo)

Initialize contact between two rigid bodies and return info which is required by the solver step.

Parameters
  • invMass0 – inverse mass of rigid body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • omega0 – angular velocity of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • omega1 – angular velocity of second body

  • cp0 – contact point of body 0

  • cp1 – contact point of body 1

  • normal – contact normal in body 1

  • restitutionCoeff – coefficient of restitution

  • constraintInfo

    Stores the local and global position of the contact points and the contact normal.

    The joint info contains the following columns:

    0: connector in body 0 (global)

    1: connector in body 1 (global)

    2: contact normal in body 1 (global)

    3: contact tangent (global)

    0,4: 1.0 / normal^T * K * normal

    1,4: maximal impulse in tangent direction

    2,4: goal velocity in normal direction after collision

static bool velocitySolve_RigidBodyContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Matrix3r &inertiaInverseW0, const Vector3r &omega0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Vector3r &omega1, const Real stiffness, const Real frictionCoeff, Real &sum_impulses, Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> &constraintInfo, Vector3r &corr_v0, Vector3r &corr_omega0, Vector3r &corr_v1, Vector3r &corr_omega1)

Perform a solver step for a contact constraint between two rigid bodies. A contact constraint handles collisions and resting contacts between the bodies. The contact info must be generated in each time step.

Parameters
  • invMass0 – inverse mass of rigid body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • omega0 – angular velocity of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • omega1 – angular velocity of second body

  • stiffness – stiffness parameter of penalty impulse

  • frictionCoeff – friction coefficient

  • sum_impulses – sum of all correction impulses in normal direction

  • constraintInfo – information which is required by the solver. This information must be generated in the beginning by calling init_RigidBodyContactConstraint().

  • corr_v0 – velocity correction of first body

  • corr_omega0 – angular velocity correction of first body

  • corr_v1 – velocity correction of second body

  • corr_omega1 – angular velocity correction of second body

static bool init_ParticleRigidBodyContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Vector3r &omega1, const Vector3r &cp0, const Vector3r &cp1, const Vector3r &normal, const Real restitutionCoeff, Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> &constraintInfo)

Initialize contact between a rigid body and a particle and return info which is required by the solver step.

Parameters
  • invMass0 – inverse mass of rigid body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • omega1 – angular velocity of second body

  • cp0 – contact point of body 0

  • cp1 – contact point of body 1

  • normal – contact normal in body 1

  • restitutionCoeff – coefficient of restitution

  • constraintInfo

    Stores the local and global position of the contact points and the contact normal.

    The joint info contains the following columns:

    0: connector in body 0 (global)

    1: connector in body 1 (global)

    2: contact normal in body 1 (global)

    3: contact tangent (global)

    0,4: 1.0 / normal^T * K * normal

    1,4: maximal impulse in tangent direction

    2,4: goal velocity in normal direction after collision

static bool velocitySolve_ParticleRigidBodyContactConstraint(const Real invMass0, const Vector3r &x0, const Vector3r &v0, const Real invMass1, const Vector3r &x1, const Vector3r &v1, const Matrix3r &inertiaInverseW1, const Vector3r &omega1, const Real stiffness, const Real frictionCoeff, Real &sum_impulses, Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> &constraintInfo, Vector3r &corr_v0, Vector3r &corr_v1, Vector3r &corr_omega1)

Perform a solver step for a contact constraint between a rigid body and a particle. A contact constraint handles collisions and resting contacts between the bodies. The contact info must be generated in each time step.

Parameters
  • invMass0 – inverse mass of rigid body

  • x0 – center of mass of first body

  • v0 – velocity of body 0

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • v1 – velocity of body 1

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • omega1 – angular velocity of second body

  • stiffness – stiffness parameter of penalty impulse

  • frictionCoeff – friction coefficient

  • sum_impulses – sum of all correction impulses in normal direction

  • constraintInfo – information which is required by the solver. This information must be generated in the beginning by calling init_RigidBodyContactConstraint().

  • corr_v0 – velocity correction of first body

  • corr_v1 – velocity correction of second body

  • corr_omega1 – angular velocity correction of second body

static bool init_DistanceJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &pos0, const Vector3r &pos1, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo)

Initialize distance joint and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointPosition – position of distance joint

  • jointInfo – Stores the local and global positions of the connector points. The first two columns store the local connectors in body 0 and 1, respectively, while the last two columns contain the global connector positions which have to be updated in each simulation step by calling update_DistanceJoint()

    .

    The joint info contains the following columns:

    0: connector in body 0 (local)

    1: connector in body 1 (local)

    2: connector in body 0 (global)

    3: connector in body 1 (global)

static bool update_DistanceJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo)

Update distance joint info which is required by the solver step. The distance joint info must be generated in the initialization process of the model by calling the function init_DistanceJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – joint information which should be updated

static bool solve_DistanceJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Real stiffness, const Real restLength, const Real dt, const Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &jointInfo, Real &lambda, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a distance joint which links two rigid bodies. A distance joint removes one translational degrees of freedom between the bodies. When setting a stiffness value which is not zero, we get an implicit spring. The distance joint info must be generated in the initialization process of the model by calling the function init_DistanceJoint() and updated each time the bodies change their state by update_DistanceJoint()

.

More information can be found in:

[7]

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • stiffness – Stiffness of the constraint. 0 means it is totally stiff and we get a distance joint otherwise we get an implicit spring.

  • restLength – Rest length of the joint.

  • dt – Time step size (required for XPBD when simulating a spring)

  • jointInfo – Joint information which is required by the solver. This information must be generated in the beginning by calling init_DistanceJoint() and updated each time the bodies change their state by update_DistanceJoint().

  • lambda – Lagrange multiplier (required for XPBD). Must be 0 in the first iteration.

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

static bool init_DamperJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, const Vector3r &direction, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Initialize a motor slider joint which is able to enforce a target position and return info which is required by the solver step.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • sliderJointPosition – position of slider joint

  • sliderJointAxis – axis of slider joint

  • jointInfo

    Stores the local and global positions of the connector points. The joint info contains the following columns:

    0: coordinate system in body 0, where the x-axis is the slider axis (local)

    1: coordinate system in body 0, where the x-axis is the slider axis (global)

    2: 3D vector d = R^T * (x0 - x1), where R is a rotation matrix with the slider axis as first column

    3-5: projection matrix Pr for the rotational part

    The info must be updated in each simulation step by calling

    update_TargetPositionMotorSliderJoint().

static bool update_DamperJoint(const Vector3r &x0, const Quaternionr &q0, const Vector3r &x1, const Quaternionr &q1, Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo)

Update motor slider joint info which is required by the solver step. The joint info must be generated in the initialization process of the model by calling the function init_TargetPositionMotorSliderJoint(). This method should be called once per simulation step before executing the solver.

Parameters
  • x0 – center of mass of first body

  • q0 – rotation of first body

  • x1 – center of mass of second body

  • q1 – rotation of second body

  • jointInfo – slider joint information which should be updated

static bool solve_DamperJoint(const Real invMass0, const Vector3r &x0, const Matrix3r &inertiaInverseW0, const Quaternionr &q0, const Real invMass1, const Vector3r &x1, const Matrix3r &inertiaInverseW1, const Quaternionr &q1, const Real stiffness, const Real dt, const Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> &jointInfo, Real &lambda, Vector3r &corr_x0, Quaternionr &corr_q0, Vector3r &corr_x1, Quaternionr &corr_q1)

Perform a solver step for a motor slider joint which links two rigid bodies. A motor slider joint removes two translational and three rotational degrees of freedom between the bodies. Moreover, a target position can be enforced on the remaining translation axis. The motor slider joint info must be generated in the initialization process of the model by calling the function init_TargetPositionMotorSliderJoint() and updated each time the bodies change their state by update_TargetPositionMotorSliderJoint()

.

More information can be found in:

[7]

doxyoutput/xml/motorsliderjoint.jpgdoxyoutput/xml/motorsliderjoint.jpg

Parameters
  • invMass0 – inverse mass of first body

  • x0 – center of mass of first body

  • inertiaInverseW0 – inverse inertia tensor in world coordinates of first body

  • q0 – rotation of first body

  • invMass1 – inverse mass of second body

  • x1 – center of mass of second body

  • inertiaInverseW1 – inverse inertia tensor in world coordinates of second body

  • q1 – rotation of second body

  • targetPosition – target position of the servo motor

  • jointInfo – Motor slider joint information which is required by the solver. This information must be generated in the beginning by calling init_TargetPositionMotorSliderJoint() and updated each time the bodies change their state by update_TargetPositionMotorSliderJoint().

  • corr_x0 – position correction of center of mass of first body

  • corr_q0 – rotation correction of first body

  • corr_x1 – position correction of center of mass of second body

  • corr_q1 – rotation correction of second body

Class RigidBody

Class Documentation
class RigidBody

This class encapsulates the state of a rigid body.

Public Functions

inline RigidBody(void)
inline ~RigidBody(void)
inline void initBody(const Real mass, const Vector3r &x, const Vector3r &inertiaTensor, const Quaternionr &rotation, const VertexData &vertices, const Utilities::IndexedFaceMesh &mesh, const Vector3r &scale = Vector3r(1.0, 1.0, 1.0))
inline void initBody(const Real density, const Vector3r &x, const Quaternionr &rotation, const VertexData &vertices, const Utilities::IndexedFaceMesh &mesh, const Vector3r &scale = Vector3r(1.0, 1.0, 1.0))
inline void reset()
inline void updateInverseTransformation()
inline void rotationUpdated()
inline void updateInertiaW()
inline void determineMassProperties(const Real density)

Determine mass and inertia tensor of the given geometry.

inline const Matrix3r &getTransformationR()
inline const Vector3r &getTransformationV1()
inline const Vector3r &getTransformationV2()
inline const Vector3r &getTransformationRXV1()
inline FORCE_INLINE Real & getMass ()
inline FORCE_INLINE const Real & getMass () const
inline FORCE_INLINE void setMass (const Real &value)
inline FORCE_INLINE const Real & getInvMass () const
inline FORCE_INLINE Vector3r & getPosition ()
inline FORCE_INLINE const Vector3r & getPosition () const
inline FORCE_INLINE void setPosition (const Vector3r &pos)
inline FORCE_INLINE Vector3r & getLastPosition ()
inline FORCE_INLINE const Vector3r & getLastPosition () const
inline FORCE_INLINE void setLastPosition (const Vector3r &pos)
inline FORCE_INLINE Vector3r & getOldPosition ()
inline FORCE_INLINE const Vector3r & getOldPosition () const
inline FORCE_INLINE void setOldPosition (const Vector3r &pos)
inline FORCE_INLINE Vector3r & getPosition0 ()
inline FORCE_INLINE const Vector3r & getPosition0 () const
inline FORCE_INLINE void setPosition0 (const Vector3r &pos)
inline FORCE_INLINE Vector3r & getPositionInitial_MAT ()
inline FORCE_INLINE const Vector3r & getPositionInitial_MAT () const
inline FORCE_INLINE void setPositionInitial_MAT (const Vector3r &pos)
inline FORCE_INLINE Vector3r & getVelocity ()
inline FORCE_INLINE const Vector3r & getVelocity () const
inline FORCE_INLINE void setVelocity (const Vector3r &value)
inline FORCE_INLINE Vector3r & getVelocity0 ()
inline FORCE_INLINE const Vector3r & getVelocity0 () const
inline FORCE_INLINE void setVelocity0 (const Vector3r &value)
inline FORCE_INLINE Vector3r & getAcceleration ()
inline FORCE_INLINE const Vector3r & getAcceleration () const
inline FORCE_INLINE void setAcceleration (const Vector3r &accel)
inline FORCE_INLINE const Vector3r & getInertiaTensor () const
inline FORCE_INLINE void setInertiaTensor (const Vector3r &value)
inline FORCE_INLINE Matrix3r & getInertiaTensorW ()
inline FORCE_INLINE const Matrix3r & getInertiaTensorW () const
inline FORCE_INLINE const Vector3r & getInertiaTensorInverse () const
inline FORCE_INLINE Matrix3r & getInertiaTensorInverseW ()
inline FORCE_INLINE const Matrix3r & getInertiaTensorInverseW () const
inline FORCE_INLINE void setInertiaTensorInverseW (const Matrix3r &value)
inline FORCE_INLINE Quaternionr & getRotation ()
inline FORCE_INLINE const Quaternionr & getRotation () const
inline FORCE_INLINE void setRotation (const Quaternionr &value)
inline FORCE_INLINE Quaternionr & getLastRotation ()
inline FORCE_INLINE const Quaternionr & getLastRotation () const
inline FORCE_INLINE void setLastRotation (const Quaternionr &value)
inline FORCE_INLINE Quaternionr & getOldRotation ()
inline FORCE_INLINE const Quaternionr & getOldRotation () const
inline FORCE_INLINE void setOldRotation (const Quaternionr &value)
inline FORCE_INLINE Quaternionr & getRotation0 ()
inline FORCE_INLINE const Quaternionr & getRotation0 () const
inline FORCE_INLINE void setRotation0 (const Quaternionr &value)
inline FORCE_INLINE Quaternionr & getRotationMAT ()
inline FORCE_INLINE const Quaternionr & getRotationMAT () const
inline FORCE_INLINE void setRotationMAT (const Quaternionr &value)
inline FORCE_INLINE Quaternionr & getRotationInitial ()
inline FORCE_INLINE const Quaternionr & getRotationInitial () const
inline FORCE_INLINE void setRotationInitial (const Quaternionr &value)
inline FORCE_INLINE Matrix3r & getRotationMatrix ()
inline FORCE_INLINE const Matrix3r & getRotationMatrix () const
inline FORCE_INLINE void setRotationMatrix (const Matrix3r &value)
inline FORCE_INLINE Vector3r & getAngularVelocity ()
inline FORCE_INLINE const Vector3r & getAngularVelocity () const
inline FORCE_INLINE void setAngularVelocity (const Vector3r &value)
inline FORCE_INLINE Vector3r & getAngularVelocity0 ()
inline FORCE_INLINE const Vector3r & getAngularVelocity0 () const
inline FORCE_INLINE void setAngularVelocity0 (const Vector3r &value)
inline FORCE_INLINE Vector3r & getTorque ()
inline FORCE_INLINE const Vector3r & getTorque () const
inline FORCE_INLINE void setTorque (const Vector3r &value)
inline FORCE_INLINE Real getRestitutionCoeff () const
inline FORCE_INLINE void setRestitutionCoeff (Real val)
inline FORCE_INLINE Real getFrictionCoeff () const
inline FORCE_INLINE void setFrictionCoeff (Real val)
inline RigidBodyGeometry &getGeometry()

Class RigidBodyContactConstraint

Class Documentation
class RigidBodyContactConstraint

Public Functions

inline RigidBodyContactConstraint()
inline ~RigidBodyContactConstraint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real stiffness, const Real frictionCoeff)
virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

std::array<unsigned int, 2> m_bodies

indices of the linked bodies

Real m_stiffness
Real m_frictionCoeff
Real m_sum_impulses
Eigen::Matrix<Real, 3, 5, Eigen::DontAlign> m_constraintInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class RigidBodyGeometry

Class Documentation
class RigidBodyGeometry

Public Types

typedef Utilities::IndexedFaceMesh Mesh

Public Functions

RigidBodyGeometry()
virtual ~RigidBodyGeometry()
Mesh &getMesh()
VertexData &getVertexData()
const VertexData &getVertexData() const
VertexData &getVertexDataLocal()
const VertexData &getVertexDataLocal() const
void initMesh(const unsigned int nVertices, const unsigned int nFaces, const Vector3r *vertices, const unsigned int *indices, const Mesh::UVIndices &uvIndices, const Mesh::UVs &uvs, const Vector3r &scale = Vector3r(1.0, 1.0, 1.0), const bool flatShading = false)
void updateMeshTransformation(const Vector3r &x, const Matrix3r &R)
void updateMeshNormals(const VertexData &vd)

Protected Attributes

Mesh m_mesh
VertexData m_vertexData_local
VertexData m_vertexData

Class RigidBodyParticleBallJoint

Inheritance Relationships
Base Type
Class Documentation
class RigidBodyParticleBallJoint : public PBD::Constraint

Public Functions

inline RigidBodyParticleBallJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex, const unsigned int particleIndex)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 2, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class RigidBodySpring

Inheritance Relationships
Base Type
Class Documentation
class RigidBodySpring : public PBD::Constraint

Public Functions

inline RigidBodySpring()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos1, const Vector3r &pos2, const Real stiffness)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> m_jointInfo
Real m_restLength
Real m_stiffness
Real m_lambda

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class RodConstraint

Class Documentation
class RodConstraint

Public Types

using Vector6r = Eigen::Matrix<Real, 6, 1, Eigen::DontAlign>

Public Functions

virtual unsigned int segmentIndex(unsigned int i) = 0
virtual Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> &getConstraintInfo() = 0
virtual Real getAverageSegmentLength() = 0
virtual Vector3r &getRestDarbouxVector() = 0
virtual Vector3r &getStiffnessCoefficientK() = 0
virtual Vector3r &getStretchCompliance() = 0
virtual Vector3r &getBendingAndTorsionCompliance() = 0

Class RodSegment

Class Documentation
class RodSegment

Public Functions

virtual bool isDynamic() = 0
virtual Real Mass() = 0
virtual const Vector3r &InertiaTensor() = 0
virtual const Vector3r &Position() = 0
virtual const Quaternionr &Rotation() = 0

Class ShapeMatchingConstraint

Inheritance Relationships
Base Type
Class Documentation
class ShapeMatchingConstraint : public PBD::Constraint

Public Functions

inline ShapeMatchingConstraint(const unsigned int numberOfParticles)
inline virtual ~ShapeMatchingConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particleIndices[], const unsigned int numClusters[], const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Vector3r m_restCm
Real *m_w
Vector3r *m_x0
Vector3r *m_x
Vector3r *m_corr
unsigned int *m_numClusters

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class Simulation

Inheritance Relationships
Base Type
  • public ParameterObject

Class Documentation
class Simulation : public ParameterObject

Class to manage the current simulation time and the time step size. This class is a singleton.

Public Functions

Simulation()
Simulation(const Simulation&) = delete
Simulation &operator=(const Simulation&) = delete
~Simulation()
void init()
void reset()
inline SimulationModel *getModel()
inline void setModel(SimulationModel *model)
inline TimeStep *getTimeStep()
inline void setTimeStep(TimeStep *ts)

Public Static Functions

static Simulation *getCurrent()
static void setCurrent(Simulation *tm)
static bool hasCurrent()

Public Static Attributes

static int GRAVITATION = -1

Protected Functions

virtual void initParameters()

Protected Attributes

SimulationModel *m_model
TimeStep *m_timeStep
Vector3r m_gravitation

Class SimulationModel

Inheritance Relationships
Base Type
  • public ParameterObject

Class Documentation
class SimulationModel : public ParameterObject

Public Types

typedef std::vector<Constraint*> ConstraintVector
typedef std::vector<RigidBodyContactConstraint> RigidBodyContactConstraintVector
typedef std::vector<ParticleRigidBodyContactConstraint> ParticleRigidBodyContactConstraintVector
typedef std::vector<ParticleTetContactConstraint> ParticleSolidContactConstraintVector
typedef std::vector<RigidBody*> RigidBodyVector
typedef std::vector<TriangleModel*> TriangleModelVector
typedef std::vector<TetModel*> TetModelVector
typedef std::vector<LineModel*> LineModelVector
typedef std::vector<unsigned int> ConstraintGroup
typedef std::vector<ConstraintGroup> ConstraintGroupVector

Public Functions

SimulationModel()
SimulationModel(const SimulationModel&) = delete
SimulationModel &operator=(const SimulationModel&) = delete
virtual ~SimulationModel()
void init()
virtual void initParameters()
virtual void reset()
virtual void cleanup()
RigidBodyVector &getRigidBodies()
ParticleData &getParticles()
OrientationData &getOrientations()
TriangleModelVector &getTriangleModels()
TetModelVector &getTetModels()
LineModelVector &getLineModels()
ConstraintVector &getConstraints()
RigidBodyContactConstraintVector &getRigidBodyContactConstraints()
ParticleRigidBodyContactConstraintVector &getParticleRigidBodyContactConstraints()
ParticleSolidContactConstraintVector &getParticleSolidContactConstraints()
ConstraintGroupVector &getConstraintGroups()
void resetContacts()
void addTriangleModel(const unsigned int nPoints, const unsigned int nFaces, Vector3r *points, unsigned int *indices, const TriangleModel::ParticleMesh::UVIndices &uvIndices, const TriangleModel::ParticleMesh::UVs &uvs)
void addRegularTriangleModel(const int width, const int height, const Vector3r &translation = Vector3r::Zero(), const Matrix3r &rotation = Matrix3r::Identity(), const Vector2r &scale = Vector2r::Ones())
void addTetModel(const unsigned int nPoints, const unsigned int nTets, Vector3r *points, unsigned int *indices)
void addRegularTetModel(const int width, const int height, const int depth, const Vector3r &translation = Vector3r::Zero(), const Matrix3r &rotation = Matrix3r::Identity(), const Vector3r &scale = Vector3r::Ones())
void addLineModel(const unsigned int nPoints, const unsigned int nQuaternions, Vector3r *points, Quaternionr *quaternions, unsigned int *indices, unsigned int *indicesQuaternions)
void updateConstraints()
void initConstraintGroups()
bool addBallJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos)
bool addBallOnLineJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &dir)
bool addHingeJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
bool addTargetAngleMotorHingeJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
bool addTargetVelocityMotorHingeJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
bool addUniversalJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis1, const Vector3r &axis2)
bool addSliderJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
bool addTargetPositionMotorSliderJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
bool addTargetVelocityMotorSliderJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
bool addRigidBodyParticleBallJoint(const unsigned int rbIndex, const unsigned int particleIndex)
bool addRigidBodySpring(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos1, const Vector3r &pos2, const Real stiffness)
bool addDistanceJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos1, const Vector3r &pos2)
bool addDamperJoint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis, const Real stiffness)
bool addRigidBodyContactConstraint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
bool addParticleRigidBodyContactConstraint(const unsigned int particleIndex, const unsigned int rbIndex, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
bool addParticleSolidContactConstraint(const unsigned int particleIndex, const unsigned int solidIndex, const unsigned int tetIndex, const Vector3r &bary, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff)
bool addDistanceConstraint(const unsigned int particle1, const unsigned int particle2, const Real stiffness)
bool addDistanceConstraint_XPBD(const unsigned int particle1, const unsigned int particle2, const Real stiffness)
bool addDihedralConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
bool addIsometricBendingConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
bool addIsometricBendingConstraint_XPBD(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
bool addFEMTriangleConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const Real xyPoissonRatio, const Real yxPoissonRatio)
bool addStrainTriangleConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const bool normalizeStretch, const bool normalizeShear)
bool addVolumeConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
bool addVolumeConstraint_XPBD(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
bool addFEMTetConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness, const Real poissonRatio)
bool addFEMTetConstraint_XPBD(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness, const Real poissonRatio)
bool addStrainTetConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stretchStiffness, const Real shearStiffness, const bool normalizeStretch, const bool normalizeShear)
bool addShapeMatchingConstraint(const unsigned int numberOfParticles, const unsigned int particleIndices[], const unsigned int numClusters[], const Real stiffness)
bool addStretchShearConstraint(const unsigned int particle1, const unsigned int particle2, const unsigned int quaternion1, const Real stretchingStiffness, const Real shearingStiffness1, const Real shearingStiffness2)
bool addBendTwistConstraint(const unsigned int quaternion1, const unsigned int quaternion2, const Real twistingStiffness, const Real bendingStiffness1, const Real bendingStiffness2)
bool addStretchBendingTwistingConstraint(const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Real averageRadius, const Real averageSegmentLength, const Real youngsModulus, const Real torsionModulus)
bool addDirectPositionBasedSolverForStiffRodsConstraint(const std::vector<std::pair<unsigned int, unsigned int>> &jointSegmentIndices, const std::vector<Vector3r> &jointPositions, const std::vector<Real> &averageRadii, const std::vector<Real> &averageSegmentLengths, const std::vector<Real> &youngsModuli, const std::vector<Real> &torsionModuli)
inline Real getContactStiffnessRigidBody() const
inline void setContactStiffnessRigidBody(Real val)
inline Real getContactStiffnessParticleRigidBody() const
inline void setContactStiffnessParticleRigidBody(Real val)
void addClothConstraints(const TriangleModel *tm, const unsigned int clothMethod, const Real distanceStiffness, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const Real xyPoissonRatio, const Real yxPoissonRatio, const bool normalizeStretch, const bool normalizeShear)
void addBendingConstraints(const TriangleModel *tm, const unsigned int bendingMethod, const Real stiffness)
void addSolidConstraints(const TetModel *tm, const unsigned int solidMethod, const Real stiffness, const Real poissonRatio, const Real volumeStiffness, const bool normalizeStretch, const bool normalizeShear)
template<typename ConstraintType, typename T, T ConstraintType::* MemPtr>
inline void setConstraintValue(const T v)
inline void setClothSimulationMethodChangedCallback(std::function<void()> const &callBackFct)
inline void setClothBendingMethodChangedCallback(std::function<void()> const &callBackFct)
inline void setSolidSimulationMethodChangedCallback(std::function<void()> const &callBackFct)
inline virtual int getClothSimulationMethod()
virtual void setClothSimulationMethod(const int val)
inline virtual int getClothBendingMethod()
virtual void setClothBendingMethod(const int val)
inline virtual Real getClothStiffness()
virtual void setClothStiffness(Real val)
inline virtual Real getClothStiffnessXX()
virtual void setClothStiffnessXX(Real val)
inline virtual Real getClothStiffnessYY()
virtual void setClothStiffnessYY(Real val)
inline virtual Real getClothStiffnessXY()
virtual void setClothStiffnessXY(Real val)
inline virtual Real getClothPoissonRatioXY()
virtual void setClothPoissonRatioXY(Real val)
inline virtual Real getClothPoissonRatioYX()
virtual void setClothPoissonRatioYX(Real val)
inline virtual Real getClothBendingStiffness()
virtual void setClothBendingStiffness(Real val)
inline virtual bool getClothNormalizeStretch()
virtual void setClothNormalizeStretch(bool val)
inline virtual bool getClothNormalizeShear()
virtual void setClothNormalizeShear(bool val)
inline virtual int getSolidSimulationMethod()
virtual void setSolidSimulationMethod(const int val)
inline virtual Real getSolidStiffness()
virtual void setSolidStiffness(Real val)
inline virtual Real getSolidPoissonRatio()
virtual void setSolidPoissonRatio(Real val)
inline virtual Real getSolidVolumeStiffness()
virtual void setSolidVolumeStiffness(Real val)
inline virtual bool getSolidNormalizeStretch()
virtual void setSolidNormalizeStretch(bool val)
inline virtual bool getSolidNormalizeShear()
virtual void setSolidNormalizeShear(bool val)
inline virtual Real getRodStretchingStiffness()
virtual void setRodStretchingStiffness(Real val)
inline virtual Real getRodShearingStiffnessX()
virtual void setRodShearingStiffnessX(Real val)
inline virtual Real getRodShearingStiffnessY()
virtual void setRodShearingStiffnessY(Real val)
inline virtual Real getRodBendingStiffnessX()
virtual void setRodBendingStiffnessX(Real val)
inline virtual Real getRodBendingStiffnessY()
virtual void setRodBendingStiffnessY(Real val)
inline virtual Real getRodTwistingStiffness()
virtual void setRodTwistingStiffness(Real val)

Public Members

bool m_groupsInitialized

Public Static Attributes

static int CLOTH_SIMULATION_METHOD = -1
static int ENUM_CLOTHSIM_NONE = -1
static int ENUM_CLOTHSIM_DISTANCE_CONSTRAINTS = -1
static int ENUM_CLOTHSIM_FEM_PBD = -1
static int ENUM_CLOTHSIM_SBD = -1
static int ENUM_CLOTHSIM_DISTANCE_CONSTRAINTS_XPBD = -1
static int CLOTH_STIFFNESS = -1
static int CLOTH_STIFFNESS_XX = -1
static int CLOTH_STIFFNESS_YY = -1
static int CLOTH_STIFFNESS_XY = -1
static int CLOTH_POISSON_RATIO_XY = -1
static int CLOTH_POISSON_RATIO_YX = -1
static int CLOTH_BENDING_METHOD = -1
static int ENUM_CLOTH_BENDING_NONE = -1
static int ENUM_CLOTH_BENDING_DIHEDRAL_ANGLE = -1
static int ENUM_CLOTH_BENDING_ISOMETRIC = -1
static int ENUM_CLOTH_BENDING_ISOMETRIX_XPBD = -1
static int CLOTH_BENDING_STIFFNESS = -1
static int CLOTH_NORMALIZE_STRETCH = -1
static int CLOTH_NORMALIZE_SHEAR = -1
static int SOLID_SIMULATION_METHOD = -1
static int ENUM_SOLIDSIM_NONE = -1
static int ENUM_SOLIDSIM_DISTANCE_CONSTRAINTS = -1
static int ENUM_SOLIDSIM_FEM_PBD = -1
static int ENUM_SOLIDSIM_FEM_XPBD = -1
static int ENUM_SOLIDSIM_SBD = -1
static int ENUM_SOLIDSIM_SHAPE_MATCHING = -1
static int ENUM_SOLIDSIM_DISTANCE_CONSTRAINTS_XPBD = -1
static int SOLID_STIFFNESS = -1
static int SOLID_POISSON_RATIO = -1
static int SOLID_VOLUME_STIFFNESS = -1
static int SOLID_NORMALIZE_STRETCH = -1
static int SOLID_NORMALIZE_SHEAR = -1
static int ROD_STRETCHING_STIFFNESS = -1
static int ROD_SHEARING_STIFFNESS_X = -1
static int ROD_SHEARING_STIFFNESS_Y = -1
static int ROD_BENDING_STIFFNESS_X = -1
static int ROD_BENDING_STIFFNESS_Y = -1
static int ROD_TWISTING_STIFFNESS = -1
static int CONTACT_STIFFNESS_RB = -1
static int CONTACT_STIFFNESS_PARTICLE_RB = -1

Protected Attributes

RigidBodyVector m_rigidBodies
TriangleModelVector m_triangleModels
TetModelVector m_tetModels
LineModelVector m_lineModels
ParticleData m_particles
OrientationData m_orientations
ConstraintVector m_constraints
RigidBodyContactConstraintVector m_rigidBodyContactConstraints
ParticleRigidBodyContactConstraintVector m_particleRigidBodyContactConstraints
ParticleSolidContactConstraintVector m_particleSolidContactConstraints
ConstraintGroupVector m_constraintGroups
int m_clothSimulationMethod
int m_clothBendingMethod
Real m_cloth_stiffness
Real m_cloth_bendingStiffness
Real m_cloth_xxStiffness
Real m_cloth_yyStiffness
Real m_cloth_xyStiffness
Real m_cloth_xyPoissonRatio
Real m_cloth_yxPoissonRatio
bool m_cloth_normalizeStretch
bool m_cloth_normalizeShear
int m_solidSimulationMethod
Real m_solid_stiffness
Real m_solid_poissonRatio
Real m_solid_volumeStiffness
bool m_solid_normalizeStretch
bool m_solid_normalizeShear
Real m_rod_stretchingStiffness
Real m_rod_shearingStiffnessX
Real m_rod_shearingStiffnessY
Real m_rod_bendingStiffnessX
Real m_rod_bendingStiffnessY
Real m_rod_twistingStiffness
Real m_contactStiffnessRigidBody
Real m_contactStiffnessParticleRigidBody
std::function<void()> m_clothSimMethodChanged
std::function<void()> m_clothBendingMethodChanged
std::function<void()> m_solidSimMethodChanged

Class SliderJoint

Inheritance Relationships
Base Type
Class Documentation
class SliderJoint : public PBD::Constraint

Public Functions

inline SliderJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class StrainTetConstraint

Inheritance Relationships
Base Type
Class Documentation
class StrainTetConstraint : public PBD::Constraint

Public Functions

inline StrainTetConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stretchStiffness, const Real shearStiffness, const bool normalizeStretch, const bool normalizeShear)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stretchStiffness
Real m_shearStiffness
Matrix3r m_invRestMat
bool m_normalizeStretch
bool m_normalizeShear

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class StrainTriangleConstraint

Inheritance Relationships
Base Type
Class Documentation
class StrainTriangleConstraint : public PBD::Constraint

Public Functions

inline StrainTriangleConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const Real xxStiffness, const Real yyStiffness, const Real xyStiffness, const bool normalizeStretch, const bool normalizeShear)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Matrix2r m_invRestMat
Real m_xxStiffness
Real m_xyStiffness
Real m_yyStiffness
bool m_normalizeStretch
bool m_normalizeShear

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class StretchBendingTwistingConstraint

Inheritance Relationships
Base Type
Class Documentation
class StretchBendingTwistingConstraint : public PBD::Constraint

Public Functions

inline StretchBendingTwistingConstraint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int segmentIndex1, const unsigned int segmentIndex2, const Vector3r &pos, const Real averageRadius, const Real averageSegmentLength, Real youngsModulus, Real torsionModulus)
virtual bool initConstraintBeforeProjection(SimulationModel &model)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 4, Eigen::DontAlign> m_constraintInfo
Real m_averageRadius
Real m_averageSegmentLength
Vector3r m_restDarbouxVector
Vector3r m_stiffnessCoefficientK
Vector3r m_stretchCompliance
Vector3r m_bendingAndTorsionCompliance
Vector6r m_lambdaSum

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class StretchShearConstraint

Inheritance Relationships
Base Type
Class Documentation
class StretchShearConstraint : public PBD::Constraint

Public Functions

inline StretchShearConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int quaternion1, const Real stretchingStiffness, const Real shearingStiffness1, const Real shearingStiffness2)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_restLength
Real m_shearingStiffness1
Real m_shearingStiffness2
Real m_stretchingStiffness

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class TargetAngleMotorHingeJoint

Inheritance Relationships
Base Type
Class Documentation
class TargetAngleMotorHingeJoint : public PBD::MotorJoint

Public Functions

inline TargetAngleMotorHingeJoint()
inline virtual int &getTypeId() const
inline virtual void setTarget(const Real val)
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class TargetPositionMotorSliderJoint

Inheritance Relationships
Base Type
Class Documentation
class TargetPositionMotorSliderJoint : public PBD::MotorJoint

Public Functions

inline TargetPositionMotorSliderJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class TargetVelocityMotorHingeJoint

Inheritance Relationships
Base Type
Class Documentation
class TargetVelocityMotorHingeJoint : public PBD::MotorJoint

Public Functions

inline TargetVelocityMotorHingeJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)
virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 8, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class TargetVelocityMotorSliderJoint

Inheritance Relationships
Base Type
Class Documentation
class TargetVelocityMotorSliderJoint : public PBD::MotorJoint

Public Functions

inline TargetVelocityMotorSliderJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &axis)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)
virtual bool solveVelocityConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 4, 6, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class TetMeshBSH

Inheritance Relationships
Base Type
Class Documentation
class TetMeshBSH : public PBD::KDTree<BoundingSphere>

Public Types

using super = KDTree<BoundingSphere>

Public Functions

TetMeshBSH()
void init(const Vector3r *vertices, const unsigned int numVertices, const unsigned int *indices, const unsigned int numTets, const Real tolerance)
virtual Vector3r const &entity_position(unsigned int i) const final
virtual void compute_hull(unsigned int b, unsigned int n, BoundingSphere &hull) const final
virtual void compute_hull_approx(unsigned int b, unsigned int n, BoundingSphere &hull) const final
void updateVertices(const Vector3r *vertices)

Class TetModel

Nested Relationships
Class Documentation
class TetModel

Public Types

typedef Utilities::IndexedFaceMesh SurfaceMesh
typedef Utilities::IndexedTetMesh ParticleMesh

Public Functions

TetModel()
virtual ~TetModel()
inline Vector3r &getInitialX()
inline void setInitialX(const Vector3r &val)
inline Matrix3r &getInitialR()
inline void setInitialR(const Matrix3r &val)
inline Vector3r &getInitialScale()
inline void setInitialScale(const Vector3r &val)
SurfaceMesh &getSurfaceMesh()
VertexData &getVisVertices()
SurfaceMesh &getVisMesh()
inline ParticleMesh &getParticleMesh()
inline const ParticleMesh &getParticleMesh() const
void cleanupModel()
unsigned int getIndexOffset() const
void initMesh(const unsigned int nPoints, const unsigned int nTets, const unsigned int indexOffset, unsigned int *indices)
void updateMeshNormals(const ParticleData &pd)
void attachVisMesh(const ParticleData &pd)

Attach a visualization mesh to the surface of the body. Important: The vertex normals have to be updated before calling this function by calling updateMeshNormals().

void updateVisMesh(const ParticleData &pd)

Update the visualization mesh of the body. Important: The vertex normals have to be updated before calling this function by calling updateMeshNormals().

inline FORCE_INLINE Real getRestitutionCoeff () const
inline FORCE_INLINE void setRestitutionCoeff (Real val)
inline FORCE_INLINE Real getFrictionCoeff () const
inline FORCE_INLINE void setFrictionCoeff (Real val)

Protected Functions

void createSurfaceMesh()
void solveQuadraticForZero(const Vector3r &F, const Vector3r &Fu, const Vector3r &Fv, const Vector3r &Fuu, const Vector3r &Fuv, const Vector3r &Fvv, Real &u, Real &v)
bool pointInTriangle(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Vector3r &p, Vector3r &inter, Vector3r &bary)

Protected Attributes

unsigned int m_indexOffset

offset which must be added to get the correct index in the particles array

ParticleMesh m_particleMesh

Tet mesh of particles which represents the simulation model

SurfaceMesh m_surfaceMesh
VertexData m_visVertices
SurfaceMesh m_visMesh
Real m_restitutionCoeff
Real m_frictionCoeff
std::vector<Attachment> m_attachments
Vector3r m_initialX
Matrix3r m_initialR
Vector3r m_initialScale
struct Attachment

Public Members

unsigned int m_index
unsigned int m_triIndex
Real m_bary[3]
Real m_dist
Real m_minError

Class TimeIntegration

Class Documentation
class TimeIntegration

Public Static Functions

static void semiImplicitEuler(const Real h, const Real mass, Vector3r &position, Vector3r &velocity, const Vector3r &acceleration)

Perform an integration step for a particle using the semi-implicit Euler (symplectic Euler) method:

\[\begin{split}\begin{align*} \mathbf{v}(t+h) &= \mathbf{v}(t) + \mathbf{a}(t) h\\ \mathbf{x}(t+h) &= \mathbf{x}(t) + \mathbf{v}(t+h) h \end{align*}\end{split}\]

Parameters
  • h – time step size

  • mass – mass of the particle

  • position – position of the particle

  • velocity – velocity of the particle

  • acceleration – acceleration of the particle

static void semiImplicitEulerRotation(const Real h, const Real mass, const Matrix3r &invertiaW, const Matrix3r &invInertiaW, Quaternionr &rotation, Vector3r &angularVelocity, const Vector3r &torque)
static void velocityUpdateFirstOrder(const Real h, const Real mass, const Vector3r &position, const Vector3r &oldPosition, Vector3r &velocity)

Perform a velocity update (first order) for the linear velocity:

\[\begin{equation*} \mathbf{v}(t+h) = \frac{1}{h} (\mathbf{p}(t+h) - \mathbf{p}(t) \end{equation*}\]

Parameters
  • h – time step size

  • mass – mass of the particle

  • position – new position \(\mathbf{p}(t+h)\) of the particle

  • oldPosition – position \(\mathbf{p}(t)\) of the particle before the time step

  • velocity – resulting velocity of the particle

static void angularVelocityUpdateFirstOrder(const Real h, const Real mass, const Quaternionr &rotation, const Quaternionr &oldRotation, Vector3r &angularVelocity)
static void velocityUpdateSecondOrder(const Real h, const Real mass, const Vector3r &position, const Vector3r &oldPosition, const Vector3r &positionOfLastStep, Vector3r &velocity)
static void angularVelocityUpdateSecondOrder(const Real h, const Real mass, const Quaternionr &rotation, const Quaternionr &oldRotation, const Quaternionr &rotationOfLastStep, Vector3r &angularVelocity)

Class TimeManager

Class Documentation
class TimeManager

Public Functions

TimeManager()
~TimeManager()
Real getTime()
void setTime(Real t)
Real getTimeStepSize()
void setTimeStepSize(Real tss)

Public Static Functions

static TimeManager *getCurrent()
static void setCurrent(TimeManager *tm)
static bool hasCurrent()

Class TimeStep

Inheritance Relationships
Base Type
  • public ParameterObject

Derived Type
Class Documentation
class TimeStep : public ParameterObject

Base class for the simulation methods.

Subclassed by PBD::TimeStepController

Public Functions

TimeStep()
virtual ~TimeStep(void)
virtual void step(SimulationModel &model) = 0
virtual void reset()
virtual void init()
void setCollisionDetection(SimulationModel &model, CollisionDetection *cd)
CollisionDetection *getCollisionDetection()

Protected Functions

void clearAccelerations(SimulationModel &model)

Clear accelerations and add gravitation.

virtual void initParameters()

Protected Attributes

CollisionDetection *m_collisionDetection

Protected Static Functions

static void contactCallbackFunction(const unsigned int contactType, const unsigned int bodyIndex1, const unsigned int bodyIndex2, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff, void *userData)
static void solidContactCallbackFunction(const unsigned int contactType, const unsigned int bodyIndex1, const unsigned int bodyIndex2, const unsigned int tetIndex, const Vector3r &bary, const Vector3r &cp1, const Vector3r &cp2, const Vector3r &normal, const Real dist, const Real restitutionCoeff, const Real frictionCoeff, void *userData)

Class TimeStepController

Inheritance Relationships
Base Type
Class Documentation
class TimeStepController : public PBD::TimeStep

Public Functions

TimeStepController()
virtual ~TimeStepController(void)
virtual void step(SimulationModel &model)
virtual void reset()

Public Static Attributes

static int NUM_SUB_STEPS = -1
static int MAX_ITERATIONS = -1
static int MAX_ITERATIONS_V = -1
static int VELOCITY_UPDATE_METHOD = -1
static int ENUM_VUPDATE_FIRST_ORDER = -1
static int ENUM_VUPDATE_SECOND_ORDER = -1

Protected Functions

virtual void initParameters()
void positionConstraintProjection(SimulationModel &model)
void velocityConstraintProjection(SimulationModel &model)

Protected Attributes

int m_velocityUpdateMethod
unsigned int m_iterations
unsigned int m_iterationsV
unsigned int m_subSteps
unsigned int m_maxIterations
unsigned int m_maxIterationsV

Class TriangleModel

Class Documentation
class TriangleModel

Public Types

typedef Utilities::IndexedFaceMesh ParticleMesh

Public Functions

TriangleModel()
virtual ~TriangleModel()
inline ParticleMesh &getParticleMesh()
inline const ParticleMesh &getParticleMesh() const
void cleanupModel()
unsigned int getIndexOffset() const
void initMesh(const unsigned int nPoints, const unsigned int nFaces, const unsigned int indexOffset, unsigned int *indices, const ParticleMesh::UVIndices &uvIndices, const ParticleMesh::UVs &uvs)
void updateMeshNormals(const ParticleData &pd)
inline FORCE_INLINE Real getRestitutionCoeff () const
inline FORCE_INLINE void setRestitutionCoeff (Real val)
inline FORCE_INLINE Real getFrictionCoeff () const
inline FORCE_INLINE void setFrictionCoeff (Real val)

Protected Attributes

unsigned int m_indexOffset

offset which must be added to get the correct index in the particles array

ParticleMesh m_particleMesh

Face mesh of particles which represents the simulation model

Real m_restitutionCoeff
Real m_frictionCoeff

Class UniversalJoint

Inheritance Relationships
Base Type
Class Documentation
class UniversalJoint : public PBD::Constraint

Public Functions

inline UniversalJoint()
inline virtual int &getTypeId() const
bool initConstraint(SimulationModel &model, const unsigned int rbIndex1, const unsigned int rbIndex2, const Vector3r &pos, const Vector3r &axis1, const Vector3r &axis2)
virtual bool updateConstraint(SimulationModel &model)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Eigen::Matrix<Real, 3, 8, Eigen::DontAlign> m_jointInfo

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class VertexData

Class Documentation
class VertexData

This class encapsulates the state of all vertices. All parameters are stored in individual arrays.

Public Functions

inline FORCE_INLINE VertexData(void)
inline FORCE_INLINE ~VertexData(void)
inline FORCE_INLINE void addVertex (const Vector3r &vertex)
inline FORCE_INLINE Vector3r & getPosition (const unsigned int i)
inline FORCE_INLINE const Vector3r & getPosition (const unsigned int i) const
inline FORCE_INLINE void setPosition (const unsigned int i, const Vector3r &pos)
inline FORCE_INLINE void resize (const unsigned int newSize)

Resize the array containing the particle data.

inline FORCE_INLINE void reserve (const unsigned int newSize)

Reserve the array containing the particle data.

inline FORCE_INLINE void release ()

Release the array containing the particle data.

inline FORCE_INLINE unsigned int size () const

Release the array containing the particle data.

inline FORCE_INLINE const std::vector< Vector3r > & getVertices () const

Class VolumeConstraint

Inheritance Relationships
Base Type
Class Documentation
class VolumeConstraint : public PBD::Constraint

Public Functions

inline VolumeConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Real m_restVolume

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class VolumeConstraint_XPBD

Inheritance Relationships
Base Type
Class Documentation
class VolumeConstraint_XPBD : public PBD::Constraint

Public Functions

inline VolumeConstraint_XPBD()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Real m_restVolume
Real m_lambda

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class XPBD

Class Documentation
class XPBD

Public Static Functions

static bool solve_DistanceConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Real restLength, const Real stiffness, const Real dt, Real &lambda, Vector3r &corr0, Vector3r &corr1)

Determine the position corrections for a distance constraint between two particles using XPBD:\(C(\mathbf{p}_0, \mathbf{p}_1) = \| \mathbf{p}_0 - \mathbf{p}_1\| - l_0 = 0\) More information can be found in the following papers: [12], [2], [5], [6], [10]

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • restLength – rest length of distance constraint

  • stiffness – stiffness coefficient

  • dt – Time step size

  • lambda – Lagrange multiplier (XPBD)

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

static bool solve_VolumeConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restVolume, const Real stiffness, const Real dt, Real &lambda, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for a constraint that conserves the volume of single tetrahedron. Such a constraint has the form

\[\begin{equation*} C(\mathbf{p}_1, \mathbf{p}_2, \mathbf{p}_3, \mathbf{p}_4) = \frac{1}{6} \left(\mathbf{p}_{2,1} \times \mathbf{p}_{3,1}\right) \cdot \mathbf{p}_{4,1} - V_0, \end{equation*}\]
where \(\mathbf{p}_1\), \(\mathbf{p}_2\), \(\mathbf{p}_3\) and \(\mathbf{p}_4\) are the four corners of the tetrahedron and \(V_0\)

is its rest volume.

More information can be found in the following papers:

[12], [2], [5], [6],

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • restVolume – rest angle \(V_0\)

  • stiffness – stiffness coefficient

  • dt – Time step size

  • lambda – Lagrange multiplier (XPBD)

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

static bool init_IsometricBendingConstraint(const Vector3r &p0, const Vector3r &p1, const Vector3r &p2, const Vector3r &p3, Matrix4r &Q)

Initialize the local stiffness matrix Q. The matrix is required by the solver step. It must only be recomputed if the rest shape changes.

Bending is simulated for the angle on (p2, p3) between the triangles (p0, p2, p3) and (p1, p3, p2).

Parameters
  • p0 – point 0 of stencil

  • p1 – point 1 of stencil

  • p2 – point 2 of stencil

  • p3 – point 3 of stencil

  • Q – returns the local stiffness matrix which is required by the solver

static bool solve_IsometricBendingConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Matrix4r &Q, const Real stiffness, const Real dt, Real &lambda, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

Determine the position corrections for the isometric bending constraint using XPBD

. This constraint can be used for almost inextensible surface models.

More information can be found in:

[6], [4]

Parameters
  • p0 – position of first particle

  • invMass0 – inverse mass of first particle

  • p1 – position of second particle

  • invMass1 – inverse mass of second particle

  • p2 – position of third particle

  • invMass2 – inverse mass of third particle

  • p3 – position of fourth particle

  • invMass3 – inverse mass of fourth particle

  • Q – local stiffness matrix which must be initialized by calling init_IsometricBendingConstraint()

  • stiffness – stiffness coefficient for bending

  • dt – Time step size

  • lambda – Lagrange multiplier (XPBD)

  • corr0 – position correction of first particle

  • corr1 – position correction of second particle

  • corr2 – position correction of third particle

  • corr3 – position correction of fourth particle

static bool solve_FEMTetraConstraint(const Vector3r &p0, Real invMass0, const Vector3r &p1, Real invMass1, const Vector3r &p2, Real invMass2, const Vector3r &p3, Real invMass3, const Real restVolume, const Matrix3r &invRestMat, const Real youngsModulus, const Real poissonRatio, const bool handleInversion, const Real dt, Real &lambda, Vector3r &corr0, Vector3r &corr1, Vector3r &corr2, Vector3r &corr3)

XPBD

implementation of the finite element method described in

Jan Bender, Dan Koschier, Patrick Charrier and Daniel Weber,

”Position-Based Simulation of Continuous Materials”,

Computers & Graphics 44, 2014

Solve the continuum mechanical constraint defined for a tetrahedron.

Class XPBD_FEMTetConstraint

Inheritance Relationships
Base Type
Class Documentation
class XPBD_FEMTetConstraint : public PBD::Constraint

Public Functions

inline XPBD_FEMTetConstraint()
inline virtual int &getTypeId() const
virtual bool initConstraint(SimulationModel &model, const unsigned int particle1, const unsigned int particle2, const unsigned int particle3, const unsigned int particle4, const Real stiffness, const Real poissonRatio)
virtual bool solvePositionConstraint(SimulationModel &model, const unsigned int iter)

Public Members

Real m_stiffness
Real m_poissonRatio
Real m_volume
Matrix3r m_invRestMat
Real m_lambda

Public Static Attributes

static int TYPE_ID = IDFactory::getId()

Class BufferSink

Inheritance Relationships
Base Type
Class Documentation
class BufferSink : public Utilities::LogSink

Public Functions

inline BufferSink(const LogLevel minLevel)
inline virtual void write(const Utilities::LogLevel level, const std::string &str)
inline std::vector<std::pair<Utilities::LogLevel, std::string>> &getBuffer()
inline void clearBuffer()

Protected Attributes

std::vector<std::pair<Utilities::LogLevel, std::string>> m_buffer

Class ConsoleSink

Inheritance Relationships
Base Type
Class Documentation
class ConsoleSink : public Utilities::LogSink

Public Functions

inline ConsoleSink(const LogLevel minLevel)
inline virtual void write(const LogLevel level, const std::string &str)

Class FileSink

Inheritance Relationships
Base Type
Class Documentation
class FileSink : public Utilities::LogSink

Public Functions

inline FileSink(const LogLevel minLevel, const std::string &fileName)
inline virtual ~FileSink()
inline virtual void write(const LogLevel level, const std::string &str)

Protected Attributes

std::ofstream m_file

Class FileSystem

Class Documentation
class FileSystem

This class implements different file system functions.

Public Static Functions

static inline std::string getFilePath(const std::string &path)
static inline std::string getFileName(const std::string &path)
static inline std::string getFileNameWithExt(const std::string &path)
static inline std::string getFileExt(const std::string &path)
static inline bool isRelativePath(const std::string &path)
static inline int makeDir(const std::string &path)
static inline int makeDirs(const std::string &path)

Make all subdirectories.

static inline std::string normalizePath(const std::string &path)
static inline bool fileExists(const std::string &fileName)
static inline std::string getProgramPath()
static inline bool copyFile(const std::string &source, const std::string &dest)
static inline bool isFile(const std::string &path)
static inline bool isDirectory(const std::string &path)
static inline bool getFilesInDirectory(const std::string &path, std::vector<std::string> &res)
static inline std::string getFileMD5(const std::string &filename)

Compute the MD5 hash of a file.

static inline bool writeMD5File(const std::string &fileName, const std::string &md5File)

Write the MD5 hash of a file to the md5File.

static inline bool checkMD5(const std::string &md5Hash, const std::string &md5File)

Compare an MD5 hash with the hash stored in an MD5 file.

Template Class Hashmap

Class Documentation
template<class KeyType, class ValueType>
class Hashmap

Public Types

typedef std::map<unsigned int, ValueType> KeyValueMap

Public Functions

inline FORCE_INLINE Hashmap(const unsigned int bucketCount)
inline ~Hashmap()
inline FORCE_INLINE void clear ()
inline FORCE_INLINE KeyValueMap * getKeyValueMap (const unsigned int index)
inline FORCE_INLINE void reset ()
inline FORCE_INLINE unsigned int bucket_count () const

Return the bucket count.

inline FORCE_INLINE ValueType * find (const KeyType &key)

Find element.

inline FORCE_INLINE void insert (const KeyType &key, const ValueType &value)

Insert element.

inline FORCE_INLINE void remove (const KeyType &key)

Remove the given element and return true, if the element was found.

inline FORCE_INLINE ValueType & operator[] (const KeyType &key)
inline FORCE_INLINE const ValueType & operator[] (const KeyType &key) const
inline FORCE_INLINE const ValueType * query (const KeyType &key) const
inline FORCE_INLINE ValueType * query (const KeyType &key)

Protected Functions

inline FORCE_INLINE void init ()
inline FORCE_INLINE void cleanup ()

Class IDFactory

Class Documentation
class IDFactory

Factory for unique ids.

Public Static Functions

static inline int getId()

Class IndexedFaceMesh

Nested Relationships
Class Documentation
class IndexedFaceMesh

Public Types

typedef std::vector<unsigned int> Faces
typedef std::vector<Vector3r> FaceNormals
typedef std::vector<Vector3r> VertexNormals
typedef std::vector<std::vector<unsigned int>> FacesEdges
typedef std::vector<Edge> Edges
typedef std::vector<std::vector<unsigned int>> VerticesEdges
typedef std::vector<std::vector<unsigned int>> VerticesFaces
typedef std::vector<unsigned int> UVIndices
typedef std::vector<Vector2r> UVs

Public Functions

IndexedFaceMesh()
IndexedFaceMesh(IndexedFaceMesh const &other)
IndexedFaceMesh &operator=(IndexedFaceMesh const &other)
~IndexedFaceMesh()
void release()
bool isClosed() const
inline bool getFlatShading() const
inline void setFlatShading(const bool v)
void initMesh(const unsigned int nPoints, const unsigned int nEdges, const unsigned int nFaces)
void addFace(const unsigned int *const indices)

Add a new face. Indices must be an array of size m_verticesPerFace.

void addFace(const int *const indices)

Add a new face. Indices must be an array of size m_verticesPerFace.

void addUV(const Real u, const Real v)
void addUVIndex(const unsigned int index)
inline const Faces &getFaces() const
inline Faces &getFaces()
inline const FaceNormals &getFaceNormals() const
inline FaceNormals &getFaceNormals()
inline const VertexNormals &getVertexNormals() const
inline VertexNormals &getVertexNormals()
inline Edges &getEdges()
inline const Edges &getEdges() const
inline const FacesEdges &getFacesEdges() const
inline const UVIndices &getUVIndices() const
inline const UVs &getUVs() const
inline const VerticesFaces &getVertexFaces() const
inline const VerticesEdges &getVertexEdges() const
inline unsigned int numVertices() const
inline unsigned int numFaces() const
inline unsigned int numEdges() const
inline unsigned int numUVs() const
void copyUVs(const UVIndices &uvIndices, const UVs &uvs)
void buildNeighbors()
template<class PositionData>
void updateNormals(const PositionData &pd, const unsigned int offset)
template<class PositionData>
void updateVertexNormals(const PositionData &pd)
unsigned int getVerticesPerFace() const

Protected Attributes

unsigned int m_numPoints
Faces m_indices
Edges m_edges
FacesEdges m_facesEdges
bool m_closed
UVIndices m_uvIndices
UVs m_uvs
VerticesFaces m_verticesFaces
VerticesEdges m_verticesEdges
const unsigned int m_verticesPerFace = 3u
FaceNormals m_normals
VertexNormals m_vertexNormals
bool m_flatShading
struct Edge

Public Members

std::array<unsigned int, 2> m_face
std::array<unsigned int, 2> m_vert

Class IndexedTetMesh

Class Documentation
class IndexedTetMesh

Public Types

typedef std::vector<unsigned int> Tets
typedef std::vector<unsigned int> Faces
typedef std::vector<Tet> TetData
typedef std::vector<Face> FaceData
typedef std::vector<Edge> Edges
typedef std::vector<std::vector<unsigned int>> VerticesTets
typedef std::vector<std::vector<unsigned int>> VerticesFaces
typedef std::vector<std::vector<unsigned int>> VerticesEdges

Public Functions

IndexedTetMesh()
~IndexedTetMesh()
void release()
void initMesh(const unsigned int nPoints, const unsigned int nEdges, const unsigned int nFaces, const unsigned int nTets)
void addTet(const unsigned int *const indices)

Add a new tet. Indices must be an array of size 4.

void addTet(const int *const indices)

Add a new tet. Indices must be an array of size 4.

inline const Faces &getFaces() const
inline Faces &getFaces()
inline const Tets &getTets() const
inline Tets &getTets()
inline Edges &getEdges()
inline const Edges &getEdges() const
inline const FaceData &getFaceData() const
inline const TetData &getTetData() const
inline const VerticesTets &getVertexTets() const
inline const VerticesFaces &getVertexFaces() const
inline const VerticesEdges &getVertexEdges() const
inline unsigned int numVertices() const
inline unsigned int numFaces() const
inline unsigned int numTets() const
inline unsigned int numEdges() const
void buildNeighbors()

Protected Attributes

unsigned int m_numPoints
Tets m_tetIndices
Faces m_faceIndices
Edges m_edges
FaceData m_faces
TetData m_tets
VerticesTets m_verticesTets
VerticesFaces m_verticesFaces
VerticesEdges m_verticesEdges
struct Edge

Public Members

std::array<unsigned int, 2> m_vert
struct Face

Public Members

std::array<unsigned int, 3> m_edges
std::array<unsigned int, 2> m_tets
struct Tet

Public Members

std::array<unsigned int, 6> m_edges
std::array<unsigned int, 4> m_faces

Class Logger

Class Documentation
class Logger

Public Functions

inline Logger()
inline ~Logger()
inline void addSink(std::shared_ptr<LogSink> sink)
inline void removeSink(std::shared_ptr<LogSink> sink)
inline std::vector<std::shared_ptr<LogSink>> &getSinks()
inline void write(const LogLevel level, const std::string &str)
inline void activate(const bool b)

Protected Attributes

std::vector<std::shared_ptr<LogSink>> m_sinks
bool m_active

Class LogSink

Inheritance Relationships
Derived Types
Class Documentation
class LogSink

Subclassed by Utilities::BufferSink, Utilities::ConsoleSink, Utilities::FileSink

Public Functions

inline LogSink(const LogLevel minLevel)
inline virtual ~LogSink()
virtual void write(const LogLevel level, const std::string &str) = 0
inline void setMinLevel(LogLevel level)

Protected Attributes

LogLevel m_minLevel

Class LogStream

Class Documentation
class LogStream

Public Functions

inline LogStream(Logger *logger, const LogLevel level)
template<typename T>
inline LogStream &operator<<(T const &value)
inline ~LogStream()

Protected Attributes

LogLevel m_level
Logger *m_logger
std::ostringstream m_buffer

Template Class ObjectArray

Class Documentation
template<class T, int growBy = 100, bool linearGrow = true>
class ObjectArray

Public Functions

inline FORCE_INLINE ObjectArray()
inline FORCE_INLINE ObjectArray(const ObjectArray &other)
inline ~ObjectArray()
inline FORCE_INLINE T * arrayPointer ()

Return the pointer of the data.

inline FORCE_INLINE const T * arrayPointer () const

Return the pointer of the data.

inline FORCE_INLINE void reset ()

Set size to zero but do not change capacity.

inline FORCE_INLINE void clear ()
inline FORCE_INLINE unsigned int size () const

Return the number of elements

inline FORCE_INLINE unsigned int capacity () const

Return the capacity

inline FORCE_INLINE T * getData ()
inline FORCE_INLINE const T * getData () const
inline T &create()
inline FORCE_INLINE void insert (const unsigned int index, const T &data)

Insert element at the given index.

inline FORCE_INLINE void removeAt (const unsigned int index)

Remove the element at the given index.

inline FORCE_INLINE bool remove (const T &element)

Remove the given element and return true, if the element was found.

inline FORCE_INLINE void pop_back ()
inline FORCE_INLINE void push_back (const T &data)
inline FORCE_INLINE void push_back (T &data)
inline FORCE_INLINE T & operator[] (const unsigned int i)
inline FORCE_INLINE const T & operator[] (const unsigned int i) const
inline FORCE_INLINE ObjectArray & operator= (const ObjectArray &val)
inline FORCE_INLINE void reserve (const unsigned int count)
inline FORCE_INLINE void resize (unsigned int count)

Protected Functions

inline FORCE_INLINE void init ()

Class OBJLoader

Class Documentation
class OBJLoader

Read for OBJ files.

Public Types

using Vec3f = std::array<float, 3>
using Vec2f = std::array<float, 2>

Public Static Functions

static inline void loadObj(const std::string &filename, std::vector<Vec3f> *x, std::vector<MeshFaceIndices> *faces, std::vector<Vec3f> *normals, std::vector<Vec2f> *texcoords, const Vec3f &scale)

This function loads an OBJ file. Only triangulated meshes are supported.

Class PLYLoader

Class Documentation
class PLYLoader

Read for PLY files.

Public Static Functions

static inline void loadPly(const std::string &filename, std::vector<std::array<float, 3>> &x, std::vector<std::array<int, 3>> &faces, const std::array<float, 3> &scale)

This function loads an PLY file. Only triangulated meshes are supported.

Class SceneLoader

Class Documentation
class SceneLoader

Public Types

enum CollisionObjectTypes

Values:

enumerator No_Collision_Object
enumerator Sphere
enumerator Box
enumerator Cylinder
enumerator Torus
enumerator SDF
enumerator HollowSphere
enumerator HollowBox

Public Functions

inline virtual ~SceneLoader()
void readScene(const std::string &fileName, SceneData &sceneData)
void readSimulation(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readRigidBodies(const nlohmann::json &child, const std::string &key, const std::string &basePath, SceneData &sceneData)
void readTriangleModels(const nlohmann::json &child, const std::string &key, const std::string &basePath, SceneData &sceneData)
void readTetModels(const nlohmann::json &child, const std::string &key, const std::string &basePath, SceneData &sceneData)
void readBallJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readBallOnLineJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readHingeJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readUniversalJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readSliderJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readRigidBodyParticleBallJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readTargetAngleMotorHingeJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readTargetVelocityMotorHingeJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readTargetPositionMotorSliderJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readTargetVelocityMotorSliderJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readRigidBodySprings(const nlohmann::json &j, const std::string &key, SceneData &sceneData)
void readDistanceJoints(const nlohmann::json &j, const std::string &key, SceneData &sceneData)
void readDamperJoints(const nlohmann::json &child, const std::string &key, SceneData &sceneData)
void readParameterObject(GenParam::ParameterObject *paramObj)
template<>
bool readValue(const nlohmann::json &j, const std::string &key, bool &v)
template<>
bool readValue(const nlohmann::json &j, const std::string &key, bool &v)

Public Static Functions

template<typename T>
static inline bool readValue(const nlohmann::json &j, const std::string &key, T &v)
template<typename T, int size>
static inline bool readVector(const nlohmann::json &j, const std::string &key, Eigen::Matrix<T, size, 1, Eigen::DontAlign> &vec)

Protected Attributes

nlohmann::json m_json
struct BallJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
struct BallOnLineJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
struct DamperJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_stiffness
struct DistanceJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position1
Vector3r m_position2
struct HingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
struct RigidBodyData

Public Members

unsigned int m_id
std::string m_modelFile
bool m_flatShading
bool m_isDynamic
Real m_density
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
Vector3r m_v
Vector3r m_omega
Real m_restitutionCoeff
Real m_frictionCoeff
int m_collisionObjectType
std::string m_collisionObjectFileName
bool m_testMesh
Vector3r m_collisionObjectScale
bool m_invertSDF
Real m_thicknessSDF
Eigen::Matrix<unsigned int, 3, 1, Eigen::DontAlign> m_resolutionSDF
nlohmann::json m_json
struct RigidBodyParticleBallJointData

Public Members

unsigned int m_bodyID[2]
struct RigidBodySpringData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position1
Vector3r m_position2
Real m_stiffness
struct SceneData

Public Members

std::string m_sceneName
Vector3r m_camPosition
Vector3r m_camLookat
Real m_timeStepSize
Vector3r m_gravity
std::vector<RigidBodyData> m_rigidBodyData
std::vector<TriangleModelData> m_triangleModelData
std::vector<TetModelData> m_tetModelData
std::vector<BallJointData> m_ballJointData
std::vector<BallOnLineJointData> m_ballOnLineJointData
std::vector<HingeJointData> m_hingeJointData
std::vector<UniversalJointData> m_universalJointData
std::vector<SliderJointData> m_sliderJointData
std::vector<RigidBodyParticleBallJointData> m_rigidBodyParticleBallJointData
std::vector<TargetAngleMotorHingeJointData> m_targetAngleMotorHingeJointData
std::vector<TargetVelocityMotorHingeJointData> m_targetVelocityMotorHingeJointData
std::vector<TargetPositionMotorSliderJointData> m_targetPositionMotorSliderJointData
std::vector<TargetVelocityMotorSliderJointData> m_targetVelocityMotorSliderJointData
std::vector<DamperJointData> m_damperJointData
std::vector<RigidBodySpringData> m_rigidBodySpringData
std::vector<DistanceJointData> m_distanceJointData
struct SliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
struct TargetAngleMotorHingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat
struct TargetPositionMotorSliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat
struct TargetVelocityMotorHingeJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat
struct TargetVelocityMotorSliderJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_axis
Real m_target
std::vector<Real> m_targetSequence
bool m_repeat
struct TetModelData

Public Members

unsigned int m_id
std::string m_modelFileTet
std::string m_modelFileNodes
std::string m_modelFileElements
std::string m_modelFileVis
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
std::vector<unsigned int> m_staticParticles
Real m_restitutionCoeff
Real m_frictionCoeff
int m_collisionObjectType
std::string m_collisionObjectFileName
bool m_testMesh
Vector3r m_collisionObjectScale
bool m_invertSDF
Real m_thicknessSDF
Eigen::Matrix<unsigned int, 3, 1, Eigen::DontAlign> m_resolutionSDF
nlohmann::json m_json
struct TriangleModelData

Public Members

unsigned int m_id
std::string m_modelFile
Vector3r m_x
Quaternionr m_q
Vector3r m_scale
std::vector<unsigned int> m_staticParticles
Real m_restitutionCoeff
Real m_frictionCoeff
nlohmann::json m_json
struct UniversalJointData

Public Members

unsigned int m_bodyID[2]
Vector3r m_position
Vector3r m_axis[2]

Class StringTools

Class Documentation
class StringTools

Tools to handle std::string objects.

Public Static Functions

static inline void tokenize(const std::string &str, std::vector<std::string> &tokens, const std::string &delimiters = " ")

Class SystemInfo

Class Documentation
class SystemInfo

Public Static Functions

static inline std::string getHostName()

Class TetGenLoader

Class Documentation
class TetGenLoader

Public Static Functions

static void loadTetFile(const std::string &filename, std::vector<Vector3r> &vertices, std::vector<unsigned int> &tets)
static void loadTetgenModel(const std::string &nodeFilename, const std::string &eleFilename, std::vector<Vector3r> &vertices, std::vector<unsigned int> &tets)
static void loadMSHModel(const std::string &mshFilename, std::vector<Vector3r> &vertices, std::vector<unsigned int> &tets)

Class Timing

Class Documentation
class Timing

Class for time measurements.

Public Static Functions

static inline void reset()
static inline FORCE_INLINE void startTiming (const std::string &name=std::string(""))
static inline FORCE_INLINE double stopTiming (bool print=true)
static inline FORCE_INLINE double stopTiming (bool print, int &id)
static inline FORCE_INLINE void printAverageTimes ()
static inline FORCE_INLINE void printTimeSums ()

Public Static Attributes

static bool m_dontPrintTimes
static unsigned int m_startCounter
static unsigned int m_stopCounter
static std::stack<TimingHelper> m_timingStack
static std::unordered_map<int, AverageTime> m_averageTimes

Class VolumeIntegration

Class Documentation
class VolumeIntegration

Public Functions

VolumeIntegration(const unsigned int nVertices, const unsigned int nFaces, Vector3r *const vertices, const unsigned int *indices)
void compute_inertia_tensor(Real density)

Compute inertia tensor for given geometry and given density.

inline Real getMass() const

Return mass of body.

inline Real getVolume() const

Return volume of body.

inline Matrix3r const &getInertia() const

Return inertia tensor of body.

inline Vector3r const &getCenterOfMass() const

Return center of mass.

Enums

Enum LogLevel

Enum Documentation
enum Utilities::LogLevel

Values:

enumerator DEBUG
enumerator INFO
enumerator WARN
enumerator ERR

Functions

Template Function Utilities::hashFunction

Function Documentation
template<class KeyType>
inline unsigned int Utilities::hashFunction(const KeyType &key)

Specialized Template Function Utilities::hashFunction< NeighborhoodSearchCellPos * >

Function Documentation
template<>
inline unsigned int Utilities::hashFunction<NeighborhoodSearchCellPos*>(NeighborhoodSearchCellPos *const &key)

Variables

Variable eps

Variable Documentation

Warning

doxygenvariable: Cannot find variable “eps” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Variable eps

Variable Documentation

Warning

doxygenvariable: Cannot find variable “eps” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Variable eps

Variable Documentation

Warning

doxygenvariable: Cannot find variable “eps” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Variable permutation

Variable Documentation

Warning

doxygenvariable: Cannot find variable “permutation” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Variable Utilities::logger

Variable Documentation
Utilities::Logger Utilities::logger

Defines

Define __BOUNDINGSPHERE_H__

Define Documentation
__BOUNDINGSPHERE_H__

Define _USE_MATH_DEFINES

Define Documentation
_USE_MATH_DEFINES

Define _USE_MATH_DEFINES

Define Documentation
_USE_MATH_DEFINES

Define _USE_MATH_DEFINES

Define Documentation
_USE_MATH_DEFINES

Define _USE_MATH_DEFINES

Define Documentation
_USE_MATH_DEFINES

Define CUBE

Define Documentation

Warning

doxygendefine: Cannot find define “CUBE” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Define INIT_LOGGING

Define Documentation
INIT_LOGGING

Define INIT_TIMING

Define Documentation
INIT_TIMING

Define LOG_DEBUG

Define Documentation
LOG_DEBUG

Define LOG_ERR

Define Documentation
LOG_ERR

Define LOG_INFO

Define Documentation
LOG_INFO

Define LOG_WARN

Define Documentation
LOG_WARN

Define NO_DISTANCE_TEST

Define Documentation
NO_DISTANCE_TEST

Define S_ISDIR

Define Documentation
S_ISDIR(mode)

Define S_ISREG

Define Documentation
S_ISREG(mode)

Define SQR

Define Documentation

Warning

doxygendefine: Cannot find define “SQR” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

Define START_TIMING

Define Documentation
START_TIMING(timerName)

Define STOP_TIMING

Define Documentation
STOP_TIMING

Define STOP_TIMING_AVG

Define Documentation
STOP_TIMING_AVG

Define STOP_TIMING_AVG_PRINT

Define Documentation
STOP_TIMING_AVG_PRINT

Define STOP_TIMING_PRINT

Define Documentation
STOP_TIMING_PRINT

Typedefs

Typedef NeighborhoodSearchCellPos

Typedef Documentation
typedef Eigen::Vector3i NeighborhoodSearchCellPos

Typedef PBD::Matrix6r

Typedef Documentation
using PBD::Matrix6r = Eigen::Matrix<Real, 6, 6, Eigen::DontAlign>

Typedef PBD::Vector6r

Typedef Documentation
typedef Eigen::Matrix<Real, 6, 1, Eigen::DontAlign> PBD::Vector6r

Typedef pool_set

Typedef Documentation

Warning

doxygentypedef: Cannot find typedef “pool_set” in doxygen xml output for project “PositionBasedDynamics” from directory: ./doxyoutput/xml

References

AIA+12

Nadir Akinci, Markus Ihmsen, Gizem Akinci, Barbara Solenthaler, and Matthias Teschner. Versatile rigid-fluid coupling for incompressible sph. ACM Trans. Graph., 31(4):62:1–62:8, July 2012. URL: http://doi.acm.org/10.1145/2185520.2185558, doi:10.1145/2185520.2185558.

BKCW14

Jan Bender, Dan Koschier, Patrick Charrier, and Daniel Weber. Position-based simulation of continuous materials. Computers & Graphics, 44(0):1 – 10, 2014. doi:http://dx.doi.org/10.1016/j.cag.2014.07.004.

BMM15

Jan Bender, Matthias Müller, and Miles Macklin. Position-based simulation methods in computer graphics. In EUROGRAPHICS 2015 Tutorials. Eurographics Association, 2015.

BMOT13

Jan Bender, Matthias Müller, Miguel A. Otaduy, and Matthias Teschner. Position-based methods for the simulation of solid objects in computer graphics. In EUROGRAPHICS 2013 State of the Art Reports. Eurographics Association, 2013.

BMO+14

Jan Bender, Matthias Müller, Miguel A. Otaduy, Matthias Teschner, and Miles Macklin. A survey on position-based simulation methods in computer graphics. Computer Graphics Forum, 33(6):228–251, 2014. URL: http://dx.doi.org/10.1111/cgf.12346, doi:10.1111/cgf.12346.

BWD13

Jan Bender, Daniel Weber, and Raphael Diziol. Fast and stable cloth simulation based on multi-resolution shape matching. Computers & Graphics, 37(8):945 – 954, 2013. URL: http://www.sciencedirect.com/science/article/pii/S0097849313001283, doi:http://dx.doi.org/10.1016/j.cag.2013.08.003.

DCB14

Crispin Deul, Patrick Charrier, and Jan Bender. Position-based rigid body dynamics. Computer Animation and Virtual Worlds, 2014. URL: http://dx.doi.org/10.1002/cav.1614, doi:10.1002/cav.1614.

DBB11

Raphael Diziol, Jan Bender, and Daniel Bayer. Robust real-time deformation of incompressible surface meshes. In Proceedings of ACM SIGGRAPH/Eurographics Symposium on Computer Animation, SCA ‘11. Eurographics Association, 2011.

MM13

Miles Macklin and Matthias Müller. Position based fluids. ACM Trans. Graph., 32(4):104:1–104:12, July 2013. URL: http://doi.acm.org/10.1145/2461912.2461984, doi:10.1145/2461912.2461984.

MMC16

Miles Macklin, Matthias Müller, and Nuttapong Chentanez. Xpbd: position-based simulation of compliant constrained dynamics. In ACM Motion in Games, MIG ‘16, 49–54. ACM, 2016. URL: http://doi.acm.org/10.1145/2994258.2994272, doi:10.1145/2994258.2994272.

MCKM14

Matthias Müller, Nuttapong Chentanez, Tae-Yong Kim, and Miles Macklin. Strain based dynamics. In Proceedings of ACM SIGGRAPH/Eurographics Symposium on Computer Animation. Eurographics Association, 2014.

MHHR07

Matthias Müller, Bruno Heidelberger, Marcus Hennix, and John Ratcliff. Position based dynamics. Journal of Visual Communication and Image Representation, 18(2):109–118, 2007. doi:http://dx.doi.org/10.1016/j.jvcir.2007.01.005.

MHTG05

Matthias Müller, Bruno Heidelberger, Matthias Teschner, and Markus Gross. Meshless deformations based on shape matching. ACM Trans. Graph., 24(3):471–478, 2005. doi:http://doi.acm.org/10.1145/1073204.1073216.

Indices and tables