41 float frequencyHertz,
float dampingRatio,
47 if (massA > 0.0
f && massB > 0.0
f)
49 mass = massA * massB / (massA + massB);
51 else if (massA > 0.0
f)
60 float omega = 2.0f *
b2_pi * frequencyHertz;
61 stiffness = mass * omega * omega;
62 damping = 2.0f * mass * dampingRatio * omega;
66 float frequencyHertz,
float dampingRatio,
72 if (IA > 0.0
f && IB > 0.0
f)
74 I = IA * IB / (IA + IB);
85 float omega = 2.0f *
b2_pi * frequencyHertz;
86 stiffness = I * omega * omega;
87 damping = 2.0f * I * dampingRatio * omega;
99 joint =
new (mem)
b2DistanceJoint(static_cast<const b2DistanceJointDef*>(def));
106 joint =
new (mem)
b2MouseJoint(static_cast<const b2MouseJointDef*>(def));
113 joint =
new (mem)
b2PrismaticJoint(static_cast<const b2PrismaticJointDef*>(def));
120 joint =
new (mem)
b2RevoluteJoint(static_cast<const b2RevoluteJointDef*>(def));
127 joint =
new (mem)
b2PulleyJoint(static_cast<const b2PulleyJointDef*>(def));
134 joint =
new (mem)
b2GearJoint(static_cast<const b2GearJointDef*>(def));
141 joint =
new (mem)
b2WheelJoint(static_cast<const b2WheelJointDef*>(def));
148 joint =
new (mem)
b2WeldJoint(static_cast<const b2WeldJointDef*>(def));
155 joint =
new (mem)
b2FrictionJoint(static_cast<const b2FrictionJointDef*>(def));
162 joint =
new (mem)
b2MotorJoint(static_cast<const b2MotorJointDef*>(def));
const b2Transform & GetTransform() const
virtual void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)=0
Draw a line segment.
static void Destroy(b2Joint *joint, b2BlockAllocator *allocator)
b2Vec2 GetGroundAnchorA() const
Get the first ground anchor.
Joint definitions are used to construct joints.
b2JointEdge * prev
the previous joint edge in the body's joint list
virtual void DrawPoint(const b2Vec2 &p, float size, const b2Color &color)=0
Draw a point.
void Free(void *p, int32 size)
Free memory. This will use b2Free if the size is larger than b2_maxBlockSize.
b2Vec2 GetGroundAnchorB() const
Get the second ground anchor.
void b2AngularStiffness(float &stiffness, float &damping, float frequencyHertz, float dampingRatio, const b2Body *bodyA, const b2Body *bodyB)
Utility to compute rotational stiffness values frequency and damping ratio.
b2Body * other
provides quick access to the other body attached.
Color for debug drawing. Each value has the range [0,1].
A rigid body. These are created via b2World::CreateBody.
void * Allocate(int32 size)
Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
bool collideConnected
Set this flag to true if the attached bodies should collide.
b2JointUserData userData
Use this to attach application specific data to your joints.
void Set(float rIn, float gIn, float bIn, float aIn=1.0f)
bool IsEnabled() const
Short-cut function to determine if either body is enabled.
b2Joint(const b2JointDef *def)
void b2LinearStiffness(float &stiffness, float &damping, float frequencyHertz, float dampingRatio, const b2Body *bodyA, const b2Body *bodyB)
Utility to compute linear stiffness values from frequency and damping ratio.
b2JointType type
The joint type is set automatically for concrete joint types.
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
virtual void Draw(b2Draw *draw) const
Debug draw this joint.
b2JointUserData m_userData
bool IsEnabled() const
Get the active state of the body.
b2Body * bodyA
The first attached body.
static b2Joint * Create(const b2JointDef *def, b2BlockAllocator *allocator)
b2Body * bodyB
The second attached body.
b2JointEdge * next
the next joint edge in the body's joint list