Examples of Matrix3


Examples of jinngine.math.Matrix3

    final Vector3 direction = v.normalize();
//    final Vector3 midpoint = a.add(b).multiply(0.5);
    final Vector3 midpoint = a.add(b).add(v.multiply(spb-spa)).multiply(0.5); // account for sphere sweeping
   
    // contact space basis
    final Matrix3 M = GramSchmidt.run(direction);

    // make sure the normal direction is in the z-component
    final Matrix3 B = new Matrix3(M.column(1),M.column(2),M.column(0));

    // since B is orthogonal its inverse equals its transpose
    final Matrix3 Binv = B.transpose();
   
    // create a result handler for the intersection algorithm
    final ORourke.ResultHandler handler = new ORourke.ResultHandler() {
      public final void intersection(final Vector3 p, final Vector3 q) {       
        final ContactPoint cp = new ContactPoint();

        cp.b1 = ga.getBody();
        cp.b2 = gb.getBody();
       
        cp.normal.assign(direction);
        cp.point.assign( B.multiply(new Vector3(p.x,p.y,0)).add(midpoint) );
       
        // distance along the z axis in contact space
        cp.distance = (p.z-q.z)-spb-spa;  // take into account sphere sweeping

        // if contact is within the envelope size
        if (cp.distance < envelope ) {
          cp.depth = shell-cp.distance;
          cp.envelope = envelope;
          cp.restitution = restitution;
          cp.friction = friction;
          contacts.add(cp);
        }
      }
    };
   
   
    // apply transform to all points
    for (Vector3 p: faceA) {
      p.assign( Binv.multiply(p.sub(midpoint)));
    }
    for (Vector3 p: faceB) {
      p.assign( Binv.multiply(p.sub(midpoint)));
    }
   
    // run 2d intersection
    ORourke.run(faceA, faceB, handler);
   
View Full Code Here

Examples of jinngine.math.Matrix3

      ConvexHull hull = (ConvexHull)g;
      int n = hull.getNumberOfVertices();
      double points[] = new double[n*3];
      int i = 0; Iterator<Vector3> iter = hull.getVertices();

      Matrix3 T = new Matrix3();
      Vector3 t = new Vector3();
      g.getLocalTransform(T, t);
 
      while(iter.hasNext()){
        Vector3 v = new Vector3(iter.next());
View Full Code Here

Examples of jinngine.math.Matrix3

  /**
   * Get the calculated inertia tensor. This tensor will be scaled in the total mass of the object.
   * @return
   */
  public Matrix3 getInertiaMatrix() {
    return new Matrix3(inertia);
  }
View Full Code Here

Examples of jinngine.math.Matrix3

        assertMatrixEquals(ref, val, 0.);
    }

    @Test
    public void testCtorZero() {
        final Matrix3 m = new Matrix3();
        assertMatrixEquals(new double[]{
                    0., 0., 0.,
                    0., 0., 0.,
                    0., 0., 0.}, m);
    }
View Full Code Here

Examples of jinngine.math.Matrix3

                    0., 0., 0.}, m);
    }

    @Test
    public void testAssignZero() {
        final Matrix3 m = new Matrix3(
                1., 2., 3.,
                4., 5., 6.,
                7., 8., 9.);
        final Matrix3 r = m.assignZero();
        assertSame(r, m);//assert it return this
        //assert every value is 0.
        assertMatrixEquals(new double[]{
                    0., 0., 0.,
                    0., 0., 0.,
View Full Code Here

Examples of jinngine.math.Matrix3

                    0., 0., 0.}, m);
    }

    @Test
    public void testCtor() {
        final Matrix3 m = new Matrix3(1., 2., 3.,
                4., 5., 6.,
                7., 8., 9.);
        assertMatrixEquals(new double[]{
                    1., 2., 3.,
                    4., 5., 6.,
View Full Code Here

Examples of jinngine.math.Matrix3

                    7., 8., 9.}, m);
    }

    @Test
    public void testAssign() {
        final Matrix3 m = new Matrix3();
        final Matrix3 r = m.assign(
                1., 2., 3.,
                4., 5., 6.,
                7., 8., 9.);
        assertSame(r, m);//assert it return this
        //assert every value is 0.
View Full Code Here

Examples of jinngine.math.Matrix3

                    7., 8., 9.}, m);
    }

    @Test
    public void testCtor02() {
        final Matrix3 m = new Matrix3(
                new Vector3(1, 4, 7),
                new Vector3(2, 5, 8),
                new Vector3(3, 6, 9));

        assertMatrixEquals(new double[]{
View Full Code Here

Examples of jinngine.math.Matrix3

                    7., 8., 9.}, m);
    }

    @Test(expected = NullPointerException.class)
    public void testCtor03() {
        final Matrix3 m = new Matrix3(null,
                new Vector3(),
                new Vector3());
    }
View Full Code Here

Examples of jinngine.math.Matrix3

                new Vector3());
    }

    @Test(expected = NullPointerException.class)
    public void testCtor04() {
        final Matrix3 m = new Matrix3(
                new Vector3(),
                null,
                new Vector3());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.