Package org.jbox2d.common

Examples of org.jbox2d.common.Mat22


        }
        pointCount = 0;
        localNormal = new Vec2();
        localPoint = new Vec2();
        normal = new Vec2();
        normalMass = new Mat22();
        K = new Mat22();

    }
View Full Code Here


    //      = [1/m1+1/m2     0    ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
    //        [    0     1/m1+1/m2]           [-r1.x*r1.y r1.x*r1.x]           [-r1.x*r1.y r1.x*r1.x]
    float invMass = b.m_invMass;
    float invI = b.m_invI;

    Mat22 K1 = pool.popMat22();
    K1.col1.x = invMass;  K1.col2.x = 0.0f;
    K1.col1.y = 0.0f;    K1.col2.y = invMass;

    Mat22 K2 = pool.popMat22();
    K2.col1.x =  invI * r.y * r.y;  K2.col2.x = -invI * r.x * r.y;
    K2.col1.y = -invI * r.x * r.y;  K2.col2.y =  invI * r.x * r.x;

    Mat22 K = pool.popMat22();
    K.set(K1).addLocal(K2);
    K.col1.x += m_gamma;
    K.col2.y += m_gamma;

    K.invertToOut(m_mass);

    m_C.set(b.m_sweep.c).addLocal(r).subLocal(m_target);

    // Cheat with some damping
    b.m_angularVelocity *= 0.98f;
View Full Code Here

    };
    vec3s = new OrderedStack<Vec3>(argSize, argContainerSize) {
      protected Vec3 newInstance() { return new Vec3(); }
    };
    mats = new OrderedStack<Mat22>(argSize, argContainerSize) {
      protected Mat22 newInstance() { return new Mat22(); }
    };
    aabbs = new OrderedStack<AABB>(argSize, argContainerSize) {
      protected AABB newInstance() { return new AABB(); }
    };
    rots = new OrderedStack<Rot>(argSize, argContainerSize) {
View Full Code Here

        b.x = vn1 - cp1.velocityBias;
        b.y = vn2 - cp2.velocityBias;
        // System.out.println("b is " + b.x + "," + b.y);

        // Compute b'
        Mat22 R = vc.K;
        b.x -= R.ex.x * a.x + R.ey.x * a.y;
        b.y -= R.ex.y * a.x + R.ey.y * a.y;
        // System.out.println("b' is " + b.x + "," + b.y);

        // final float k_errorTol = 1e-3f;
View Full Code Here

      positionError = C.length();

      float mA = m_invMassA, mB = m_invMassB;
      float iA = m_invIA, iB = m_invIB;

      final Mat22 K = pool.popMat22();
      K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;
      K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;
      K.ey.x = K.ex.y;
      K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;
      K.solveToOut(C, impulse);
      impulse.negateLocal();

      cA.x -= mA * impulse.x;
      cA.y -= mA * impulse.y;
      aA -= iA * Vec2.cross(rA, impulse);
View Full Code Here

      float k22 = iA + iB;
      if (k22 == 0.0f) {
        k22 = 1.0f;
      }

      final Mat22 K = pool.popMat22();
      K.ex.set(k11, k12);
      K.ey.set(k12, k22);

      // temp is impulse1
      K.solveToOut(C1.negateLocal(), temp);
      C1.negateLocal();

      impulse.x = temp.x;
      impulse.y = temp.y;
      impulse.z = 0.0f;
View Full Code Here

        float bx = vn1 - cp1.velocityBias;
        float by = vn2 - cp2.velocityBias;

        // Compute b'
        Mat22 R = vc.K;
        bx -= R.ex.x * ax + R.ey.x * ay;
        by -= R.ex.y * ax + R.ey.y * ay;

        // final float k_errorTol = 1e-3f;
        // B2_NOT_USED(k_errorTol);
        for (;;) {
          //
          // Case 1: vn = 0
          //
          // 0 = A * x' + b'
          //
          // Solve for x':
          //
          // x' = - inv(A) * b'
          //
          // Vec2 x = - Mul(c.normalMass, b);
          Mat22 R1 = vc.normalMass;
          float xx = R1.ex.x * bx + R1.ey.x * by;
          float xy = R1.ex.y * bx + R1.ey.y * by;
          xx *= -1;
          xy *= -1;

View Full Code Here

    };
    vec3s = new OrderedStack<Vec3>(argSize, argContainerSize) {
      protected Vec3 newInstance() { return new Vec3(); }
    };
    mats = new OrderedStack<Mat22>(argSize, argContainerSize) {
      protected Mat22 newInstance() { return new Mat22(); }
    };
    aabbs = new OrderedStack<AABB>(argSize, argContainerSize) {
      protected AABB newInstance() { return new AABB(); }
    };
    rots = new OrderedStack<Rot>(argSize, argContainerSize) {
View Full Code Here

    Rot.mulToOutUnsafe(qB, temp.set(m_localAnchorB).subLocal(m_localCenterB), m_rB);

    // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)]
    // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
    // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]
    final Mat22 K = pool.popMat22();
    K.ex.x = m_invMassB + m_invIB * m_rB.y * m_rB.y + m_gamma;
    K.ex.y = -m_invIB * m_rB.x * m_rB.y;
    K.ey.x = K.ex.y;
    K.ey.y = m_invMassB + m_invIB * m_rB.x * m_rB.x + m_gamma;

    K.invertToOut(m_mass);

    m_C.set(cB).addLocal(m_rB).subLocal(m_targetA);
    m_C.mulLocal(m_beta);

    // Cheat with some damping
View Full Code Here

    float wB = data.velocities[m_indexB].w;

    final Rot qA = pool.popRot();
    final Rot qB = pool.popRot();
    final Vec2 temp = pool.popVec2();
    Mat22 K = pool.popMat22();

    qA.set(aA);
    qB.set(aB);

    // Compute the effective mass matrix.
    // m_rA = b2Mul(qA, -m_localCenterA);
    // m_rB = b2Mul(qB, -m_localCenterB);
    m_rA.x = qA.c * -m_localCenterA.x - qA.s * -m_localCenterA.y;
    m_rA.y = qA.s * -m_localCenterA.x + qA.c * -m_localCenterA.y;
    m_rB.x = qB.c * -m_localCenterB.x - qB.s * -m_localCenterB.y;
    m_rB.y = qB.s * -m_localCenterB.x + qB.c * -m_localCenterB.y;

    // J = [-I -r1_skew I r2_skew]
    // [ 0 -1 0 1]
    // r_skew = [-ry; rx]

    // Matlab
    // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]
    // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]
    // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]
    float mA = m_invMassA, mB = m_invMassB;
    float iA = m_invIA, iB = m_invIB;

    K.ex.x = mA + mB + iA * m_rA.y * m_rA.y + iB * m_rB.y * m_rB.y;
    K.ex.y = -iA * m_rA.x * m_rA.y - iB * m_rB.x * m_rB.y;
    K.ey.x = K.ex.y;
    K.ey.y = mA + mB + iA * m_rA.x * m_rA.x + iB * m_rB.x * m_rB.x;

    K.invertToOut(m_linearMass);

    m_angularMass = iA + iB;
    if (m_angularMass > 0.0f) {
      m_angularMass = 1.0f / m_angularMass;
    }
View Full Code Here

TOP

Related Classes of org.jbox2d.common.Mat22

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.