Package org.jbox2d.common

Examples of org.jbox2d.common.Vec2


      float iA = vc.invIA;
      float mB = vc.invMassB;
      float iB = vc.invIB;
      int pointCount = vc.pointCount;

      Vec2 vA = m_velocities[indexA].v;
      float wA = m_velocities[indexA].w;
      Vec2 vB = m_velocities[indexB].v;
      float wB = m_velocities[indexB].w;

      Vec2 normal = vc.normal;
      float tangentx = 1.0f * normal.y;
      float tangenty = -1.0f * normal.x;

      for (int j = 0; j < pointCount; ++j) {
        VelocityConstraintPoint vcp = vc.points[j];
View Full Code Here


      float mA = vc.invMassA;
      float mB = vc.invMassB;
      float iA = vc.invIA;
      float iB = vc.invIB;
      Vec2 localCenterA = pc.localCenterA;
      Vec2 localCenterB = pc.localCenterB;

      Vec2 cA = m_positions[indexA].c;
      float aA = m_positions[indexA].a;
      Vec2 vA = m_velocities[indexA].v;
      float wA = m_velocities[indexA].w;

      Vec2 cB = m_positions[indexB].c;
      float aB = m_positions[indexB].a;
      Vec2 vB = m_velocities[indexB].v;
      float wB = m_velocities[indexB].w;

      assert (manifold.pointCount > 0);

      xfA.q.set(aA);
View Full Code Here

      float mB = vc.invMassB;
      float iA = vc.invIA;
      float iB = vc.invIB;
      int pointCount = vc.pointCount;

      Vec2 vA = m_velocities[indexA].v;
      float wA = m_velocities[indexA].w;
      Vec2 vB = m_velocities[indexB].v;
      float wB = m_velocities[indexB].w;

      Vec2 normal = vc.normal;
      tangent.x = 1.0f * vc.normal.y;
      tangent.y = -1.0f * vc.normal.x;
      final float friction = vc.friction;

      assert (pointCount == 1 || pointCount == 2);

      // Solve tangent constraints
      for (int j = 0; j < pointCount; ++j) {
        final VelocityConstraintPoint vcp = vc.points[j];
        final Vec2 a = vcp.rA;
        float dvx = -wB * vcp.rB.y + vB.x - vA.x + wA * a.y;
        float dvy = wB * vcp.rB.x + vB.y - vA.y - wA * a.x;

        // Compute tangent force
        final float vt = dvx * tangent.x + dvy * tangent.y - vc.tangentSpeed;
        float lambda = vcp.tangentMass * (-vt);

        // Clamp the accumulated force
        final float maxFriction = friction * vcp.normalImpulse;
        final float newImpulse =
            MathUtils.clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);
        lambda = newImpulse - vcp.tangentImpulse;
        vcp.tangentImpulse = newImpulse;

        // Apply contact impulse
        // Vec2 P = lambda * tangent;

        final float Px = tangent.x * lambda;
        final float Py = tangent.y * lambda;

        // vA -= invMassA * P;
        vA.x -= Px * mA;
        vA.y -= Py * mA;
        wA -= iA * (vcp.rA.x * Py - vcp.rA.y * Px);

        // vB += invMassB * P;
        vB.x += Px * mB;
        vB.y += Py * mB;
        wB += iB * (vcp.rB.x * Py - vcp.rB.y * Px);
      }

      // Solve normal constraints
      if (vc.pointCount == 1) {
        final VelocityConstraintPoint vcp = vc.points[0];

        // Relative velocity at contact
        // Vec2 dv = vB + Cross(wB, vcp.rB) - vA - Cross(wA, vcp.rA);

        float dvx = -wB * vcp.rB.y + vB.x - vA.x + wA * vcp.rA.y;
        float dvy = wB * vcp.rB.x + vB.y - vA.y - wA * vcp.rA.x;

        // Compute normal impulse
        final float vn = dvx * normal.x + dvy * normal.y;
        float lambda = -vcp.normalMass * (vn - vcp.velocityBias);

        // Clamp the accumulated impulse
        float a = vcp.normalImpulse + lambda;
        final float newImpulse = (a > 0.0f ? a : 0.0f);
        lambda = newImpulse - vcp.normalImpulse;
        vcp.normalImpulse = newImpulse;

        // Apply contact impulse
        float Px = normal.x * lambda;
        float Py = normal.y * lambda;

        // vA -= invMassA * P;
        vA.x -= Px * mA;
        vA.y -= Py * mA;
        wA -= iA * (vcp.rA.x * Py - vcp.rA.y * Px);

        // vB += invMassB * P;
        vB.x += Px * mB;
        vB.y += Py * mB;
        wB += iB * (vcp.rB.x * Py - vcp.rB.y * Px);
      } else {
        // Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on
        // Box2D_Lite).
        // Build the mini LCP for this contact patch
        //
        // vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
        //
        // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
        // b = vn_0 - velocityBias
        //
        // The system is solved using the "Total enumeration method" (s. Murty). The complementary
        // constraint vn_i * x_i
        // implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D
        // contact problem the cases
        // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be
        // tested. The first valid
        // solution that satisfies the problem is chosen.
        //
        // In order to account of the accumulated impulse 'a' (because of the iterative nature of
        // the solver which only requires
        // that the accumulated impulse is clamped and not the incremental impulse) we change the
        // impulse variable (x_i).
        //
        // Substitute:
        //
        // x = a + d
        //
        // a := old total impulse
        // x := new total impulse
        // d := incremental impulse
        //
        // For the current iteration we extend the formula for the incremental impulse
        // to compute the new total impulse:
        //
        // vn = A * d + b
        // = A * (x - a) + b
        // = A * x + b - A * a
        // = A * x + b'
        // b' = b - A * a;

        final VelocityConstraintPoint cp1 = vc.points[0];
        final VelocityConstraintPoint cp2 = vc.points[1];
        a.x = cp1.normalImpulse;
        a.y = cp2.normalImpulse;

        assert (a.x >= 0.0f && a.y >= 0.0f);
        // Relative velocity at contact
        // Vec2 dv1 = vB + Cross(wB, cp1.rB) - vA - Cross(wA, cp1.rA);
        dv1.x = -wB * cp1.rB.y + vB.x - vA.x + wA * cp1.rA.y;
        dv1.y = wB * cp1.rB.x + vB.y - vA.y - wA * cp1.rA.x;

        // Vec2 dv2 = vB + Cross(wB, cp2.rB) - vA - Cross(wA, cp2.rA);
        dv2.x = -wB * cp2.rB.y + vB.x - vA.x + wA * cp2.rA.y;
        dv2.y = wB * cp2.rB.x + vB.y - vA.y - wA * cp2.rA.x;

        // Compute normal velocity
        float vn1 = dv1.x * normal.x + dv1.y * normal.y;
        float vn2 = dv2.x * normal.x + dv2.y * normal.y;

        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;
        // 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.mulToOutUnsafe(vc.normalMass, b, x);
          x.x *= -1;
          x.y *= -1;

          if (x.x >= 0.0f && x.y >= 0.0f) {
            // System.out.println("case 1");
            // Get the incremental impulse
            // Vec2 d = x - a;
            d.set(x).subLocal(a);

            // Apply incremental impulse
            // Vec2 P1 = d.x * normal;
            // Vec2 P2 = d.y * normal;
            P1.set(normal).mulLocal(d.x);
            P2.set(normal).mulLocal(d.y);

            /*
             * vA -= invMassA * (P1 + P2); wA -= invIA * (Cross(cp1.rA, P1) + Cross(cp2.rA, P2));
             *
             * vB += invMassB * (P1 + P2); wB += invIB * (Cross(cp1.rB, P1) + Cross(cp2.rB, P2));
             */

            temp1.set(P1).addLocal(P2);
            temp2.set(temp1).mulLocal(mA);
            vA.subLocal(temp2);
            temp2.set(temp1).mulLocal(mB);
            vB.addLocal(temp2);

            wA -= iA * (Vec2.cross(cp1.rA, P1) + Vec2.cross(cp2.rA, P2));
            wB += iB * (Vec2.cross(cp1.rB, P1) + Vec2.cross(cp2.rB, P2));

            // Accumulate
            cp1.normalImpulse = x.x;
            cp2.normalImpulse = x.y;

            /*
             * #if B2_DEBUG_SOLVER == 1 // Postconditions dv1 = vB + Cross(wB, cp1.rB) - vA -
             * Cross(wA, cp1.rA); dv2 = vB + Cross(wB, cp2.rB) - vA - Cross(wA, cp2.rA);
             *
             * // Compute normal velocity vn1 = Dot(dv1, normal); vn2 = Dot(dv2, normal);
             *
             * assert(Abs(vn1 - cp1.velocityBias) < k_errorTol); assert(Abs(vn2 - cp2.velocityBias)
             * < k_errorTol); #endif
             */
            if (DEBUG_SOLVER) {
              // Postconditions
              Vec2 dv1 =
                  vB.add(Vec2.cross(wB, cp1.rB).subLocal(vA).subLocal(Vec2.cross(wA, cp1.rA)));
              Vec2 dv2 =
                  vB.add(Vec2.cross(wB, cp2.rB).subLocal(vA).subLocal(Vec2.cross(wA, cp2.rA)));
              // Compute normal velocity
              vn1 = Vec2.dot(dv1, normal);
              vn2 = Vec2.dot(dv2, normal);

              assert (MathUtils.abs(vn1 - cp1.velocityBias) < k_errorTol);
              assert (MathUtils.abs(vn2 - cp2.velocityBias) < k_errorTol);
            }
            break;
          }

          //
          // Case 2: vn1 = 0 and x2 = 0
          //
          // 0 = a11 * x1' + a12 * 0 + b1'
          // vn2 = a21 * x1' + a22 * 0 + '
          //
          x.x = -cp1.normalMass * b.x;
          x.y = 0.0f;
          vn1 = 0.0f;
          vn2 = vc.K.ex.y * x.x + b.y;

          if (x.x >= 0.0f && vn2 >= 0.0f) {
            // System.out.println("case 2");
            // Get the incremental impulse
            d.set(x).subLocal(a);

            // Apply incremental impulse
            // Vec2 P1 = d.x * normal;
            // Vec2 P2 = d.y * normal;
            P1.set(normal).mulLocal(d.x);
            P2.set(normal).mulLocal(d.y);

            /*
             * Vec2 P1 = d.x * normal; Vec2 P2 = d.y * normal; vA -= invMassA * (P1 + P2); wA -=
             * invIA * (Cross(cp1.rA, P1) + Cross(cp2.rA, P2));
             *
             * vB += invMassB * (P1 + P2); wB += invIB * (Cross(cp1.rB, P1) + Cross(cp2.rB, P2));
             */

            temp1.set(P1).addLocal(P2);
            temp2.set(temp1).mulLocal(mA);
            vA.subLocal(temp2);
            temp2.set(temp1).mulLocal(mB);
            vB.addLocal(temp2);

            wA -= iA * (Vec2.cross(cp1.rA, P1) + Vec2.cross(cp2.rA, P2));
            wB += iB * (Vec2.cross(cp1.rB, P1) + Vec2.cross(cp2.rB, P2));

            // Accumulate
            cp1.normalImpulse = x.x;
            cp2.normalImpulse = x.y;

            /*
             * #if B2_DEBUG_SOLVER == 1 // Postconditions dv1 = vB + Cross(wB, cp1.rB) - vA -
             * Cross(wA, cp1.rA);
             *
             * // Compute normal velocity vn1 = Dot(dv1, normal);
             *
             * assert(Abs(vn1 - cp1.velocityBias) < k_errorTol); #endif
             */
            if (DEBUG_SOLVER) {
              // Postconditions
              Vec2 dv1 =
                  vB.add(Vec2.cross(wB, cp1.rB).subLocal(vA).subLocal(Vec2.cross(wA, cp1.rA)));
              // Compute normal velocity
              vn1 = Vec2.dot(dv1, normal);

              assert (MathUtils.abs(vn1 - cp1.velocityBias) < k_errorTol);
            }
            break;
          }

          //
          // Case 3: wB = 0 and x1 = 0
          //
          // vn1 = a11 * 0 + a12 * x2' + b1'
          // 0 = a21 * 0 + a22 * x2' + '
          //
          x.x = 0.0f;
          x.y = -cp2.normalMass * b.y;
          vn1 = vc.K.ey.x * x.y + b.x;
          vn2 = 0.0f;

          if (x.y >= 0.0f && vn1 >= 0.0f) {
            // System.out.println("case 3");
            // Resubstitute for the incremental impulse
            d.set(x).subLocal(a);

            // Apply incremental impulse
            /*
             * Vec2 P1 = d.x * normal; Vec2 P2 = d.y * normal; vA -= invMassA * (P1 + P2); wA -=
             * invIA * (Cross(cp1.rA, P1) + Cross(cp2.rA, P2));
             *
             * vB += invMassB * (P1 + P2); wB += invIB * (Cross(cp1.rB, P1) + Cross(cp2.rB, P2));
             */

            P1.set(normal).mulLocal(d.x);
            P2.set(normal).mulLocal(d.y);

            temp1.set(P1).addLocal(P2);
            temp2.set(temp1).mulLocal(mA);
            vA.subLocal(temp2);
            temp2.set(temp1).mulLocal(mB);
            vB.addLocal(temp2);

            wA -= iA * (Vec2.cross(cp1.rA, P1) + Vec2.cross(cp2.rA, P2));
            wB += iB * (Vec2.cross(cp1.rB, P1) + Vec2.cross(cp2.rB, P2));

            // Accumulate
            cp1.normalImpulse = x.x;
            cp2.normalImpulse = x.y;

            /*
             * #if B2_DEBUG_SOLVER == 1 // Postconditions dv2 = vB + Cross(wB, cp2.rB) - vA -
             * Cross(wA, cp2.rA);
             *
             * // Compute normal velocity vn2 = Dot(dv2, normal);
             *
             * assert(Abs(vn2 - cp2.velocityBias) < k_errorTol); #endif
             */
            if (DEBUG_SOLVER) {
              // Postconditions
              Vec2 dv2 =
                  vB.add(Vec2.cross(wB, cp2.rB).subLocal(vA).subLocal(Vec2.cross(wA, cp2.rA)));
              // Compute normal velocity
              vn2 = Vec2.dot(dv2, normal);

              assert (MathUtils.abs(vn2 - cp2.velocityBias) < k_errorTol);
View Full Code Here

      int indexA = pc.indexA;
      int indexB = pc.indexB;

      float mA = pc.invMassA;
      float iA = pc.invIA;
      Vec2 localCenterA = pc.localCenterA;
      float mB = pc.invMassB;
      float iB = pc.invIB;
      Vec2 localCenterB = pc.localCenterB;
      int pointCount = pc.pointCount;

      Vec2 cA = m_positions[indexA].c;
      float aA = m_positions[indexA].a;
      Vec2 cB = m_positions[indexB].c;
      float aB = m_positions[indexB].a;

      // Solve normal constraints
      for (int j = 0; j < pointCount; ++j) {
        xfA.q.set(aA);
        xfB.q.set(aB);
        Rot.mulToOutUnsafe(xfA.q, localCenterA, xfA.p);
        xfA.p.negateLocal().addLocal(cA);
        Rot.mulToOutUnsafe(xfB.q, localCenterB, xfB.p);
        xfB.p.negateLocal().addLocal(cB);

        final PositionSolverManifold psm = psolver;
        psm.initialize(pc, xfA, xfB, j);
        final Vec2 normal = psm.normal;

        final Vec2 point = psm.point;
        final float separation = psm.separation;

        rA.set(point).subLocal(cA);
        rB.set(point).subLocal(cB);
View Full Code Here

    for (int i = 0; i < m_count; ++i) {
      ContactPositionConstraint pc = m_positionConstraints[i];

      int indexA = pc.indexA;
      int indexB = pc.indexB;
      Vec2 localCenterA = pc.localCenterA;
      Vec2 localCenterB = pc.localCenterB;
      int pointCount = pc.pointCount;

      float mA = 0.0f;
      float iA = 0.0f;
      if (indexA == toiIndexA || indexA == toiIndexB) {
        mA = pc.invMassA;
        iA = pc.invIA;
      }

      float mB = 0f;
      float iB = 0f;
      if (indexB == toiIndexA || indexB == toiIndexB) {
        mB = pc.invMassB;
        iB = pc.invIB;
      }

      Vec2 cA = m_positions[indexA].c;
      float aA = m_positions[indexA].a;

      Vec2 cB = m_positions[indexB].c;
      float aB = m_positions[indexB].a;

      // Solve normal constraints
      for (int j = 0; j < pointCount; ++j) {
        xfA.q.set(aA);
        xfB.q.set(aB);
        Rot.mulToOutUnsafe(xfA.q, localCenterA, xfA.p);
        xfA.p.negateLocal().addLocal(cA);
        Rot.mulToOutUnsafe(xfB.q, localCenterB, xfB.p);
        xfB.p.negateLocal().addLocal(cB);

        final PositionSolverManifold psm = psolver;
        psm.initialize(pc, xfA, xfB, j);
        Vec2 normal = psm.normal;

        Vec2 point = psm.point;
        float separation = psm.separation;

        rA.set(point).subLocal(cA);
        rB.set(point).subLocal(cB);
View Full Code Here

  public void initialize(ContactPositionConstraint pc, Transform xfA, Transform xfB, int index) {
    assert (pc.pointCount > 0);

    final Rot xfAq = xfA.q;
    final Rot xfBq = xfB.q;
    final Vec2 pcLocalPointsI = pc.localPoints[index];
    switch (pc.type) {
      case CIRCLES: {
        // Transform.mulToOutUnsafe(xfA, pc.localPoint, pointA);
        // Transform.mulToOutUnsafe(xfB, pc.localPoints[0], pointB);
        // normal.set(pointB).subLocal(pointA);
        // normal.normalize();
        //
        // point.set(pointA).addLocal(pointB).mulLocal(.5f);
        // temp.set(pointB).subLocal(pointA);
        // separation = Vec2.dot(temp, normal) - pc.radiusA - pc.radiusB;
        final Vec2 plocalPoint = pc.localPoint;
        final Vec2 pLocalPoints0 = pc.localPoints[0];
        final float pointAx = (xfAq.c * plocalPoint.x - xfAq.s * plocalPoint.y) + xfA.p.x;
        final float pointAy = (xfAq.s * plocalPoint.x + xfAq.c * plocalPoint.y) + xfA.p.y;
        final float pointBx = (xfBq.c * pLocalPoints0.x - xfBq.s * pLocalPoints0.y) + xfB.p.x;
        final float pointBy = (xfBq.s * pLocalPoints0.x + xfBq.c * pLocalPoints0.y) + xfB.p.y;
        normal.x = pointBx - pointAx;
        normal.y = pointBy - pointAy;
        normal.normalize();

        point.x = (pointAx + pointBx) * .5f;
        point.y = (pointAy + pointBy) * .5f;
        final float tempx = pointBx - pointAx;
        final float tempy = pointBy - pointAy;
        separation = tempx * normal.x + tempy * normal.y - pc.radiusA - pc.radiusB;
        break;
      }

      case FACE_A: {
        // Rot.mulToOutUnsafe(xfAq, pc.localNormal, normal);
        // Transform.mulToOutUnsafe(xfA, pc.localPoint, planePoint);
        //
        // Transform.mulToOutUnsafe(xfB, pc.localPoints[index], clipPoint);
        // temp.set(clipPoint).subLocal(planePoint);
        // separation = Vec2.dot(temp, normal) - pc.radiusA - pc.radiusB;
        // point.set(clipPoint);
        final Vec2 pcLocalNormal = pc.localNormal;
        final Vec2 pcLocalPoint = pc.localPoint;
        normal.x = xfAq.c * pcLocalNormal.x - xfAq.s * pcLocalNormal.y;
        normal.y = xfAq.s * pcLocalNormal.x + xfAq.c * pcLocalNormal.y;
        final float planePointx = (xfAq.c * pcLocalPoint.x - xfAq.s * pcLocalPoint.y) + xfA.p.x;
        final float planePointy = (xfAq.s * pcLocalPoint.x + xfAq.c * pcLocalPoint.y) + xfA.p.y;

        final float clipPointx = (xfBq.c * pcLocalPointsI.x - xfBq.s * pcLocalPointsI.y) + xfB.p.x;
        final float clipPointy = (xfBq.s * pcLocalPointsI.x + xfBq.c * pcLocalPointsI.y) + xfB.p.y;
        final float tempx = clipPointx - planePointx;
        final float tempy = clipPointy - planePointy;
        separation = tempx * normal.x + tempy * normal.y - pc.radiusA - pc.radiusB;
        point.x = clipPointx;
        point.y = clipPointy;
        break;
      }

      case FACE_B: {
        // Rot.mulToOutUnsafe(xfBq, pc.localNormal, normal);
        // Transform.mulToOutUnsafe(xfB, pc.localPoint, planePoint);
        //
        // Transform.mulToOutUnsafe(xfA, pcLocalPointsI, clipPoint);
        // temp.set(clipPoint).subLocal(planePoint);
        // separation = Vec2.dot(temp, normal) - pc.radiusA - pc.radiusB;
        // point.set(clipPoint);
        //
        // // Ensure normal points from A to B
        // normal.negateLocal();
        final Vec2 pcLocalNormal = pc.localNormal;
        final Vec2 pcLocalPoint = pc.localPoint;
        normal.x = xfBq.c * pcLocalNormal.x - xfBq.s * pcLocalNormal.y;
        normal.y = xfBq.s * pcLocalNormal.x + xfBq.c * pcLocalNormal.y;
        final float planePointx = (xfBq.c * pcLocalPoint.x - xfBq.s * pcLocalPoint.y) + xfB.p.x;
        final float planePointy = (xfBq.s * pcLocalPoint.x + xfBq.c * pcLocalPoint.y) + xfB.p.y;

View Full Code Here

        break;
    }
  }
 
  public void runCreationTest(){
    Vec2 v;
    float a = 0;
    for(int i=0; i<INNER_ITERS; i++){
      v = new Vec2();
      a += op(v);
    }
    aStore += a;
  }
View Full Code Here

    }
    aStore += a;
  }

  public void runWorldPoolTest(){
    Vec2 v;
    float a = 0;
    for(int i=0; i<INNER_ITERS; i++){
      v = wp.popVec2();
      a += op(v);
      wp.pushVec2(1);
View Full Code Here

    }
    aStore += a;
  }
 
  public void runCirclePoolTest(){
    Vec2 v;
    float a = 0;
    for(int i=0; i<INNER_ITERS; i++){
      v = cp.get();
      a += op(v);
    }
View Full Code Here

    {
      BodyDef bd = new BodyDef();
      Body ground = getWorld().createBody(bd);

      EdgeShape shape = new EdgeShape();
      shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
      ground.createFixture(shape, 0.0f);
    }

    {
      Vec2 vertices[] = new Vec2[3];
      vertices[0] = new Vec2(-0.5f, 0.0f);
      vertices[1] = new Vec2(0.5f, 0.0f);
      vertices[2] = new Vec2(0.0f, 1.5f);
      m_polygons[0] = new PolygonShape();
      m_polygons[0].set(vertices, 3);
    }

    {
      Vec2 vertices[] = new Vec2[3];
      vertices[0] = new Vec2(-0.1f, 0.0f);
      vertices[1] = new Vec2(0.1f, 0.0f);
      vertices[2] = new Vec2(0.0f, 1.5f);
      m_polygons[1] = new PolygonShape();
      m_polygons[1].set(vertices, 3);
    }

    {
      float w = 1.0f;
      float b = w / (2.0f + MathUtils.sqrt(2.0f));
      float s = MathUtils.sqrt(2.0f) * b;

      Vec2 vertices[] = new Vec2[8];
      vertices[0] = new Vec2(0.5f * s, 0.0f);
      vertices[1] = new Vec2(0.5f * w, b);
      vertices[2] = new Vec2(0.5f * w, b + s);
      vertices[3] = new Vec2(0.5f * s, w);
      vertices[4] = new Vec2(-0.5f * s, w);
      vertices[5] = new Vec2(-0.5f * w, b + s);
      vertices[6] = new Vec2(-0.5f * w, b);
      vertices[7] = new Vec2(-0.5f * s, 0.0f);

      m_polygons[2] = new PolygonShape();
      m_polygons[2].set(vertices, 8);
    }

View Full Code Here

TOP

Related Classes of org.jbox2d.common.Vec2

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.