GuidewireSimulation
GuidewireSim.SimulationLoop Class Reference
Inheritance diagram for GuidewireSim.SimulationLoop:

Public Member Functions

void PerformSimulationLoop ()
 

Public Attributes

Vector3[] spherePositions
 The position at the current frame of each sphere. More...
 
Vector3[] sphereVelocities
 The velocity of the current frame of each sphere. Initalized with zero entries. More...
 
float[] sphereInverseMasses
 
Vector3[] sphereExternalForces
 The sum of all current external forces that are applied per particle/ sphere. More...
 
Vector3[] cylinderPositions
 The center of mass of each cylinder. More...
 
float[] cylinderScalarWeights
 
Vector3[] cylinderExternalTorques
 The sum of all current external torques that are applied per orientation element/ cylinder. More...
 
Vector3[][] directors
 
bool solveStretchConstraints = true
 Whether or not to perform the constraint solving of the stretch constraint. More...
 
bool solveBendTwistConstraints = true
 Whether or not to perform the constraint solving of the bend twist constraint. More...
 

Properties

int ConstraintSolverSteps = 100 [get, set]
 
bool ExecuteSingleLoopTest = false [get, set]
 
int SpheresCount [get, private set]
 The count of all spheres of the guidewire. More...
 
int CylinderCount [get, private set]
 The count of all cylinders of the guidewire. More...
 

Private Member Functions

void Awake ()
 
void Start ()
 
void FixedUpdate ()
 
void PerformInitializationStep ()
 
void PerformPredictionStep ()
 
void PerformConstraintSolvingStep ()
 
void PerformUpdateStep ()
 
void AdoptCalculations ()
 

Private Attributes

InitializationStep initializationStep
 The component InitializationStep that is responsible for initializing the simulation. More...
 
PredictionStep predictionStep
 The component PredictionStep that is responsible for executing the Prediction Step of the algorithm. More...
 
ConstraintSolvingStep constraintSolvingStep
 
UpdateStep updateStep
 The component UpdateStep that is responsible for executing the Update Step of the algorithm. More...
 
ObjectSetter objectSetter
 The component ObjectSetter that is responsible for setting all positions and rotations the the GameObjects. More...
 
MathHelper mathHelper
 The component MathHelper that provides math related helper functions. More...
 
GameObject[] spheres
 
GameObject[] cylinders
 
Vector3[] spherePositionPredictions
 The prediction of the position at the current frame of each sphere. More...
 
BSM.Quaternion[] cylinderOrientations
 The orientation of each cylinder at its center of mass. More...
 
BSM.Quaternion[] cylinderOrientationPredictions
 The prediction of the orientation of each cylinder at its center of mass. More...
 
Vector3[] discreteRestDarbouxVectors
 
Vector3[] cylinderAngularVelocities
 
float[,] inertiaTensor
 The inertia tensor. Entries are approximates as in the CoRdE paper. More...
 
float[,] inverseInertiaTensor
 The inverse of inertiaTensor. More...
 
BSM.Quaternion[] worldSpaceBasis
 
float rodElementLength = 10f
 

Detailed Description

This class executes the outer simuluation loop of the algorithm and calls the implementations of each algorithm step and manages all coherent data.

Member Function Documentation

◆ AdoptCalculations()

void GuidewireSim.SimulationLoop.AdoptCalculations ( )
private

Adopts the data to the Unity GameObjects. For example, sets the positions of the GameObjects spheres to spherePositions.

Requirements:

Sets the positions of the GameObjects spheres to spherePositions.

Calculates cylinderPositions based on spherePositions.

Sets the positions of the GameObjects cylinders to cylinderPositions.

Sets the rotations of the GameObjects cylinders to cylinderOrientations.

◆ Awake()

void GuidewireSim.SimulationLoop.Awake ( )
private

◆ FixedUpdate()

void GuidewireSim.SimulationLoop.FixedUpdate ( )
private
Requirements:
Execute the simulation loop if and only if ExecuteSingleLoopTest is false.

◆ PerformConstraintSolvingStep()

void GuidewireSim.SimulationLoop.PerformConstraintSolvingStep ( )
private

Performs the constraint solving step of the algorithm.

Requirements:

Performs the constraint solving of every constraint #solverStep many times.

Solve stretch constraints, if and only if solveStretchConstraints is true.

Solve bend twist constraints, if and only if solveBendTwistConstraints is true.

If solveStretchConstraints, then SpheresCount is at least two.

If solveStretchConstraints, then CylinderCount is at least one.

If solveBendTwistConstraints, then SpheresCount is at least three.

If solveBendTwistConstraints, then CylinderCount is at least two.

If solveStretchConstraints, after the step is complete the deviation between the actual rod element length and the default (rest state) rodElementLength should be close to zero.

If solveStretchConstraints, after the step is complete the deviation of the stretch constraint to zero should be close to zero.

◆ PerformInitializationStep()

void GuidewireSim.SimulationLoop.PerformInitializationStep ( )
private

Calls every step that is mandatory to declare and initialize all data.

Requirements:

Set SpheresCount to the length of spheres.

Set CylinderCount to the length of cylinders.

Call every init method of initializationStep.

◆ PerformPredictionStep()

void GuidewireSim.SimulationLoop.PerformPredictionStep ( )
private

Performs the prediction step of the algorithm.

Requirements:

Predict the sphereVelocities.

Predict the spherePositionPredictions.

Predict the cylinderAngularVelocities.

Predict the cylinderOrientationPredictions.

◆ PerformSimulationLoop()

void GuidewireSim.SimulationLoop.PerformSimulationLoop ( )

Performs the outer simulation loop of the algorithm.

Note
In a late version, CollisionDetection and GenerateCollisionConstraints will be added to the algorithm.

◆ PerformUpdateStep()

void GuidewireSim.SimulationLoop.PerformUpdateStep ( )
private

Performs the update step of the algorithm.

Requirements:

Upate sphereVelocities.

Upate spherePositions.

Upate cylinderAngularVelocities.

Upate cylinderOrientations.

Upate directors.

◆ Start()

void GuidewireSim.SimulationLoop.Start ( )
private

Member Data Documentation

◆ constraintSolvingStep

ConstraintSolvingStep GuidewireSim.SimulationLoop.constraintSolvingStep
private

The component ConstraintSolvingStep that is responsible for correcting the predictions with the collision and model constraints.

◆ cylinderAngularVelocities

Vector3 [] GuidewireSim.SimulationLoop.cylinderAngularVelocities
private

The angular velocity of the current frame of each orientation element/ cylinder. Initalized with zero entries.

◆ cylinderExternalTorques

Vector3 [] GuidewireSim.SimulationLoop.cylinderExternalTorques

The sum of all current external torques that are applied per orientation element/ cylinder.

◆ cylinderOrientationPredictions

BSM.Quaternion [] GuidewireSim.SimulationLoop.cylinderOrientationPredictions
private

The prediction of the orientation of each cylinder at its center of mass.

◆ cylinderOrientations

BSM.Quaternion [] GuidewireSim.SimulationLoop.cylinderOrientations
private

The orientation of each cylinder at its center of mass.

◆ cylinderPositions

Vector3 [] GuidewireSim.SimulationLoop.cylinderPositions

The center of mass of each cylinder.

◆ cylinders

GameObject [] GuidewireSim.SimulationLoop.cylinders
private

All cylinders that are part of the guidewire.

Attention
The order in which the cylinders are assigned matters. Assign them such that two adjacent cylinders are adjacent in the array as well.

◆ cylinderScalarWeights

float [] GuidewireSim.SimulationLoop.cylinderScalarWeights

The constant scalar weights of each orientation/ quaternion similar to sphereInverseMasses.

Note
Set to 1 for moving orientations (so that angular motion can be applied) and to 0 for fixed orientations.

◆ directors

Vector3 [][] GuidewireSim.SimulationLoop.directors

The orthonormal basis of each orientation element / cylinder, also called directors.

Note
In the 0th row are the first directors of each orientation element, not in the 1th row. Example: The (i, j)th element holds the (i-1)th director of orientation element j.

◆ discreteRestDarbouxVectors

Vector3 [] GuidewireSim.SimulationLoop.discreteRestDarbouxVectors
private

The discrete Darboux Vector at the rest configuration, i.e. at frame 0.

Note
It is important to only take the imaginary part in the calculation for the discrete Darboux Vector, thus we only save it as a Vector3. To use it in a quaternion setting, embedd the Vector3 with scalar part 0, i.e. with EmbeddedVector().
Attention
There is only CylinderCount - 1 many darboux vectors. The i-th Darboux Vector is between orientation i and orientation i+1.

◆ inertiaTensor

float [,] GuidewireSim.SimulationLoop.inertiaTensor
private

The inertia tensor. Entries are approximates as in the CoRdE paper.

◆ initializationStep

InitializationStep GuidewireSim.SimulationLoop.initializationStep
private

The component InitializationStep that is responsible for initializing the simulation.

◆ inverseInertiaTensor

float [,] GuidewireSim.SimulationLoop.inverseInertiaTensor
private

The inverse of inertiaTensor.

◆ mathHelper

MathHelper GuidewireSim.SimulationLoop.mathHelper
private

The component MathHelper that provides math related helper functions.

◆ objectSetter

ObjectSetter GuidewireSim.SimulationLoop.objectSetter
private

The component ObjectSetter that is responsible for setting all positions and rotations the the GameObjects.

◆ predictionStep

PredictionStep GuidewireSim.SimulationLoop.predictionStep
private

The component PredictionStep that is responsible for executing the Prediction Step of the algorithm.

◆ rodElementLength

float GuidewireSim.SimulationLoop.rodElementLength = 10f
private

The distance between two spheres, also the distance between two orientations. Also the length of one cylinder.

Note
This should be two times the radius of a sphere.
Attention
Make sure that the guidewire setup fulfilles that the distance between two adjacent spheres is rodElementLength.

◆ solveBendTwistConstraints

bool GuidewireSim.SimulationLoop.solveBendTwistConstraints = true

Whether or not to perform the constraint solving of the bend twist constraint.

◆ solveStretchConstraints

bool GuidewireSim.SimulationLoop.solveStretchConstraints = true

Whether or not to perform the constraint solving of the stretch constraint.

◆ sphereExternalForces

Vector3 [] GuidewireSim.SimulationLoop.sphereExternalForces

The sum of all current external forces that are applied per particle/ sphere.

◆ sphereInverseMasses

float [] GuidewireSim.SimulationLoop.sphereInverseMasses

The constant inverse masses of each sphere.

Note
Set to 1 for moving spheres and to 0 for fixed spheres.

◆ spherePositionPredictions

Vector3 [] GuidewireSim.SimulationLoop.spherePositionPredictions
private

The prediction of the position at the current frame of each sphere.

◆ spherePositions

Vector3 [] GuidewireSim.SimulationLoop.spherePositions

The position at the current frame of each sphere.

◆ spheres

GameObject [] GuidewireSim.SimulationLoop.spheres
private

All spheres that are part of the guidewire.

Attention
The order in which the spheres are assigned matters. Assign them such that two adjacent spheres are adjacent in the array as well.

◆ sphereVelocities

Vector3 [] GuidewireSim.SimulationLoop.sphereVelocities

The velocity of the current frame of each sphere. Initalized with zero entries.

◆ updateStep

UpdateStep GuidewireSim.SimulationLoop.updateStep
private

The component UpdateStep that is responsible for executing the Update Step of the algorithm.

◆ worldSpaceBasis

BSM.Quaternion [] GuidewireSim.SimulationLoop.worldSpaceBasis
private

The three basis vectors of the world coordinate system as embedded quaternions with scalar part 0. E.g. the first basis vector is (1, 0, 0), the second (0, 1, 0) and the third (0, 0, 1).

Property Documentation

◆ ConstraintSolverSteps

int GuidewireSim.SimulationLoop.ConstraintSolverSteps = 100
getset

How often the constraint solver iterates over each constraint during the Constraint Solving Step.

Attention
This value must be positive.

◆ CylinderCount

int GuidewireSim.SimulationLoop.CylinderCount
getprivate set

The count of all cylinders of the guidewire.

◆ ExecuteSingleLoopTest

bool GuidewireSim.SimulationLoop.ExecuteSingleLoopTest = false
getset

Whether or not to execute the Single Loop Test, in which the outer simulation loop is exactly executed once.

◆ SpheresCount

int GuidewireSim.SimulationLoop.SpheresCount
getprivate set

The count of all spheres of the guidewire.


The documentation for this class was generated from the following file: