MCPcopy Create free account
hub / github.com/ByteArena/box2d / Initialize

Method Initialize

DynamicsB2JointDistance.go:130–137  ·  view source on GitHub ↗

1-D constrained system m (v2 - v1) = lambda v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass. x2 = x1 + h * v2 1-D mass-damper-spring system m (v2 - v1) + h * d * v2 + h * k * C = norm(p2 - p1) - L u = (p2 - p1) / norm(p2 - p1) Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1

(b1 *B2Body, b2 *B2Body, anchor1 B2Vec2, anchor2 B2Vec2)

Source from the content-addressed store, hash-verified

128// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
129
130func (joint *B2DistanceJointDef) Initialize(b1 *B2Body, b2 *B2Body, anchor1 B2Vec2, anchor2 B2Vec2) {
131 joint.BodyA = b1
132 joint.BodyB = b2
133 joint.LocalAnchorA = joint.BodyA.GetLocalPoint(anchor1)
134 joint.LocalAnchorB = joint.BodyB.GetLocalPoint(anchor2)
135 d := B2Vec2Sub(anchor2, anchor1)
136 joint.Length = d.Length()
137}
138
139func MakeB2DistanceJoint(def *B2DistanceJointDef) *B2DistanceJoint {
140 res := B2DistanceJoint{

Callers

nothing calls this directly

Calls 3

B2Vec2SubFunction · 0.85
GetLocalPointMethod · 0.80
LengthMethod · 0.80

Tested by

no test coverage detected