physics
hinge_joint.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include "body.hpp"
8 
13 class HingeJoint {
14 public:
15  // position constraint state
16  vec3 bias = vec3(0,0,0);
17  mat3 effective_mass = mat3(0.0f);
18  vec3 P = vec3(0,0,0);
19 
20  // angle constraint state
21  vec2 bias2 = vec3(0,0,0);
22  mat2 effective_mass2 = mat2(0.0f);
23  vec2 P2 = vec2(0,0);
24 
27 
28  vec3 anchor_a;
29  vec3 anchor_b;
30 
33 
34  float dt = 0.02f;
35 
36  unsigned int body_a_index;
37  unsigned int body_b_index;
38 
39  unsigned int axisA;
40  unsigned int axisB;
41  unsigned int axisC;
42 
43  bool unset = true;
54  HingeJoint(unsigned int indexA, vec3 anchorA, unsigned int indexB, vec3 anchorB, unsigned int axisA, unsigned int axisB, unsigned int axisC);
55 
56  int applyImpulse();
57 
58  int preStep(float dt);
59 
60  static vector<HingeJoint*> allJoints;
61 };
mat2 effective_mass2
Definition: hinge_joint.hpp:22
RigidBody * body_a
Definition: hinge_joint.hpp:25
unsigned int axisA
Definition: hinge_joint.hpp:39
vec3 anchor_a_ws
Definition: hinge_joint.hpp:31
vec2 P2
Definition: hinge_joint.hpp:23
vec2 bias2
Definition: hinge_joint.hpp:21
unsigned int axisC
Definition: hinge_joint.hpp:41
int preStep(float dt)
Hinge Joint, a position constraint, and an orthogonality constraint.
Definition: hinge_joint.hpp:13
int applyImpulse()
mat3 effective_mass
Definition: hinge_joint.hpp:17
unsigned int body_a_index
Definition: hinge_joint.hpp:36
RigidBody structure for organising data to model physics simulations of convex hull collisions...
Definition: body.hpp:224
float dt
Definition: hinge_joint.hpp:34
unsigned int axisB
Definition: hinge_joint.hpp:40
static vector< HingeJoint * > allJoints
Definition: hinge_joint.hpp:60
vec3 anchor_b
Definition: hinge_joint.hpp:29
vec3 anchor_b_ws
Definition: hinge_joint.hpp:32
unsigned int body_b_index
Definition: hinge_joint.hpp:37
vec3 P
Definition: hinge_joint.hpp:18
HingeJoint(unsigned int indexA, vec3 anchorA, unsigned int indexB, vec3 anchorB, unsigned int axisA, unsigned int axisB, unsigned int axisC)
Hinge Joint, a position constraint, and an orthogonality constraint.
RigidBody * body_b
Definition: hinge_joint.hpp:26
vec3 bias
Definition: hinge_joint.hpp:16
bool unset
Definition: hinge_joint.hpp:43
vec3 anchor_a
Definition: hinge_joint.hpp:28