File elasticJoint.h
-
class elasticJoint
Public Functions
Constructor for initializing an elastic joint.
- Parameters:
node – The node on the elastic rod that will be converted to a joint.
limb_idx – The limb id of the rod.
limbs – Container of limbs.
-
void addToJoint(int node_num, int limb_idx)
Adds a connection to the joint.
When we connect a node to a joint, that node is actually “replaced” with the joint node. Therefore, we assume that nodes that are connected to a joint have positional overlap.
- Parameters:
node_num – The id of the node that is being replaced by the joint node.
limb_idx – The limb id of the replaced node.
-
void updateJoint()
Updates the positions and velocities of the joint node.
All positions and velocities are computed within elasticRod. Therefore, before we compute anything within the elasticJoint class, we need to copy over the correct positions and velocities.
-
void updateRods()
Updates the positions of the “replaced” nodes in other limbs.
Recall that when attaching a rod to an existing joint, the overlapping node is “replaced” with the joint node. Behind the scenes, this node actually still coexists with the joint node. Therefore, for certain computations within elasticRod not to be incorrect, we need to update the position of the “replaced” node to match the joint node.
-
void updateConnectedNodes(int node_num, int limb_idx, bool remove_dof)
A helper function to store miscellaneous info when the joint is updated.
- Parameters:
node_num – The id of the node that is being replaced by the joint node.
limb_idx – The limb id of the replaced node.
remove_dof – Whether the node is being attached to a preexisting joint. For example, this value should only be False for the very first node being converted to a joint node at initialization.
-
void prepLimbs()
-
void prepareForIteration()
-
void setup()
Public Members
-
int joint_node
The node id of the joint.
-
int joint_limb
The limb id of the joint.
-
int ne
Total number of edges that connect to this joint.
-
vector<shared_ptr<elasticRod>> limbs
The stored limbs of the simulation.
-
Vector3d x0
The position of the joint node from the previous timestep.
-
Vector3d x
The position of the joint node during and after the current timestep.
-
Vector3d x_ls
Position vector used to save state during line search.
-
Vector3d u0
Velocity vector from the previous timestep.
-
Vector3d u
Velocity vector during and after the current timestep.
-
vector<pair<int, int>> connected_nodes
Container storing the ids of all nodes that have an edge connection to the joint node.
First value is the node id Second value is the limb id
-
vector<pair<int, int>> replaced_nodes
Container storing the ids of all the replaced nodes.
First value is the node id Second value is the limb id
-
vector<int> bending_twist_signs
The direction of the tangent of each edge connected to the joint node, used to compute bending and twisting force signs.
For each edge connected to the joint node, a value is stored to keep track whether the tangent of the node goes toward the joint node or out of the joint node. This direction of the tangent is determined when each rod is initialized. A value of 1: the tangent is going into the joint node. A value of -1: the tangent is going out from the joint node.
See also
Used in elasticBendingForce.cpp and elasticTwistingForce.cpp
-
int num_bending_combos
The number of possible non-repeating edge combinations connected to this joint.
-
vector<Vector2i> sgns
The sign of the bending and twisting forces.
Depending on the direction the edges are initialized, bending and twisting forces must sometimes be multiplied by -1. For elastic rods without joints, this is never an issue, but when two rods are connected in a way that the direction of the tangents go towards each-other rather than along the same direction, then at least one of the forces must be multiplied by -1. This vector holds a value of either 1 or -1.
See also
Computed using bending_twist_signs
See also
Used in elasticBendingForce.cpp and elasticTwistingForce.cpp
-
vector<Vector2i> theta_inds
Indices for the theta DOFs for each edge combination.
Vector is size num_bending_combos and contains the indices of first and second edge’s theta DOF, respectively.
-
VectorXd ref_len
Reference lengths of the discrete edges connected to the joint.
-
VectorXd voronoi_len
Voronoi lengths of the discrete edges connected to the joint.
-
double mass
The mass of the joint.
-
MatrixXd tangents
-
MatrixXd tangents_old
-
vector<Matrix<double, 2, 3>> d1
-
vector<Matrix<double, 2, 3>> d2
-
vector<Matrix<double, 2, 3>> d1_old
-
vector<Matrix<double, 2, 3>> d2_old
-
vector<Matrix<double, 2, 3>> m1
-
vector<Matrix<double, 2, 3>> m2
-
VectorXd ref_twist
-
MatrixXd kb
-
MatrixXd kappa
-
MatrixXd kappa_bar
-
VectorXd twist_bar
-
VectorXd ref_twist_old
-
VectorXd edge_len