Ejemplo n.º 1
0
 /// Initialize the bodies, anchors, axis, and reference angle using the world
 /// anchor and world axis.
 public void Initialize(Body b1, Body b2, Vector2 anchor, Vector2 axis)
 {
     body1        = b1;
     body2        = b2;
     localAnchor1 = body1.GetLocalPoint(anchor);
     localAnchor2 = body2.GetLocalPoint(anchor);
     localAxis1   = body1.GetLocalVector(axis);
 }
Ejemplo n.º 2
0
 /// Initialize the bodies, anchors, and reference angle using the world
 /// anchor.
 public void Initialize(Body b1, Body b2, Vector2 anchor)
 {
     body1          = b1;
     body2          = b2;
     localAnchor1   = body1.GetLocalPoint(anchor);
     localAnchor2   = body2.GetLocalPoint(anchor);
     referenceAngle = body2.GetAngle() - body1.GetAngle();
 }
Ejemplo n.º 3
0
        /// Initialize the bodies, anchors, and length using the world
        /// anchors.
        // 1-D rained 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, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
        public void Initialize(Body b1, Body b2,
                               Vector2 anchor1, Vector2 anchor2)
        {
            body1        = b1;
            body2        = b2;
            localAnchor1 = body1.GetLocalPoint(anchor1);
            localAnchor2 = body2.GetLocalPoint(anchor2);
            Vector2 d = anchor2 - anchor1;

            length = d.Length();
        }
Ejemplo n.º 4
0
        /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
        public void Initialize(Body b1, Body b2,
                               Vector2 ga1, Vector2 ga2,
                               Vector2 anchor1, Vector2 anchor2,
                               float r)
        {
            body1         = b1;
            body2         = b2;
            groundAnchor1 = ga1;
            groundAnchor2 = ga2;
            localAnchor1  = body1.GetLocalPoint(anchor1);
            localAnchor2  = body2.GetLocalPoint(anchor2);
            Vector2 d1 = anchor1 - ga1;

            length1 = d1.Length();
            Vector2 d2 = anchor2 - ga2;

            length2 = d2.Length();
            ratio   = r;
            Debug.Assert(ratio > Settings.b2_FLT_EPSILON);
            float C = length1 + ratio * length2;

            maxLength1 = C - ratio * b2_minPulleyLength;
            maxLength2 = (C - b2_minPulleyLength) / ratio;
        }
Ejemplo n.º 5
0
 /// Initialize the bodies, anchors, axis, and reference angle using the world
 /// anchor and world axis.
 public void Initialize(Body b1, Body b2, Vector2 anchor, Vector2 axis)
 {
     body1 = b1;
     body2 = b2;
     localAnchor1 = body1.GetLocalPoint(anchor);
     localAnchor2 = body2.GetLocalPoint(anchor);
     localAxis1 = body1.GetLocalVector(axis);
 }
Ejemplo n.º 6
0
        /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
        public void Initialize(Body b1, Body b2,
                        Vector2 ga1, Vector2 ga2,
					    Vector2 anchor1, Vector2 anchor2,
					    float r)
        {
            body1 = b1;
            body2 = b2;
            groundAnchor1 = ga1;
            groundAnchor2 = ga2;
            localAnchor1 = body1.GetLocalPoint(anchor1);
            localAnchor2 = body2.GetLocalPoint(anchor2);
            Vector2 d1 = anchor1 - ga1;
            length1 = d1.Length();
            Vector2 d2 = anchor2 - ga2;
            length2 = d2.Length();
            ratio = r;
            Debug.Assert(ratio > Settings.b2_FLT_EPSILON);
            float C = length1 + ratio * length2;
            maxLength1 = C - ratio * b2_minPulleyLength;
            maxLength2 = (C - b2_minPulleyLength) / ratio;
        }
Ejemplo n.º 7
0
        /// Initialize the bodies, anchors, and length using the world
        /// anchors.
        // 1-D rained 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, r1))
        // J = [-u -cross(r1, u) u cross(r2, u)]
        // K = J * invM * JT
        //   = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
        public void Initialize(Body b1, Body b2,
					    Vector2 anchor1, Vector2 anchor2)
        {
            body1 = b1;
            body2 = b2;
            localAnchor1 = body1.GetLocalPoint(anchor1);
            localAnchor2 = body2.GetLocalPoint(anchor2);
            Vector2 d = anchor2 - anchor1;
            length = d.Length();
        }