Package org.apache.commons.math.geometry

Examples of org.apache.commons.math.geometry.Vector3D


  }

  public void testQuaternion() {

    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
    double n = 23.5;
    Rotation r2 = new Rotation(n * r1.getQ0(), n * r1.getQ1(),
                               n * r1.getQ2(), n * r1.getQ3(),
                               true);
    for (double x = -0.9; x < 0.9; x += 0.2) {
      for (double y = -0.9; y < 0.9; y += 0.2) {
        for (double z = -0.9; z < 0.9; z += 0.2) {
          Vector3D u = new Vector3D(x, y, z);
          checkVector(r2.applyTo(u), r1.applyTo(u));
        }
      }
    }

View Full Code Here


  }

  public void testCompose() {

    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3);
    Rotation r3 = r2.applyTo(r1);

    for (double x = -0.9; x < 0.9; x += 0.2) {
      for (double y = -0.9; y < 0.9; y += 0.2) {
        for (double z = -0.9; z < 0.9; z += 0.2) {
          Vector3D u = new Vector3D(x, y, z);
          checkVector(r2.applyTo(r1.applyTo(u)), r3.applyTo(u));
        }
      }
    }
View Full Code Here

  }

  public void testComposeInverse() {

    Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7);
    Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3);
    Rotation r3 = r2.applyInverseTo(r1);

    for (double x = -0.9; x < 0.9; x += 0.2) {
      for (double y = -0.9; y < 0.9; y += 0.2) {
        for (double z = -0.9; z < 0.9; z += 0.2) {
          Vector3D u = new Vector3D(x, y, z);
          checkVector(r2.applyInverseTo(r1.applyTo(u)), r3.applyTo(u));
        }
      }
    }
View Full Code Here

  }

  public void testApplyInverseTo() {

    Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7);
    for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
      for (double phi = -1.55; phi < 1.55; phi += 0.2) {
          Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
                                    Math.sin(lambda) * Math.cos(phi),
                                    Math.sin(phi));
          r.applyInverseTo(r.applyTo(u));
          checkVector(u, r.applyInverseTo(r.applyTo(u)));
          checkVector(u, r.applyTo(r.applyInverseTo(u)));
      }
    }

    r = Rotation.IDENTITY;
    for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
      for (double phi = -1.55; phi < 1.55; phi += 0.2) {
          Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
                                    Math.sin(lambda) * Math.cos(phi),
                                    Math.sin(phi));
          checkVector(u, r.applyInverseTo(r.applyTo(u)));
          checkVector(u, r.applyTo(r.applyInverseTo(u)));
      }
    }

    r = new Rotation(Vector3D.PLUS_K, Math.PI);
    for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
      for (double phi = -1.55; phi < 1.55; phi += 0.2) {
          Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
                                    Math.sin(lambda) * Math.cos(phi),
                                    Math.sin(phi));
          checkVector(u, r.applyInverseTo(r.applyTo(u)));
          checkVector(u, r.applyTo(r.applyInverseTo(u)));
      }
View Full Code Here

    super(name);
  }

  public void testConstructors() {
      double r = Math.sqrt(2) /2;
      checkVector(new Vector3D(2, new Vector3D(Math.PI / 3, -Math.PI / 4)),
                  r, r * Math.sqrt(3), -2 * r);
      checkVector(new Vector3D(2, Vector3D.PLUS_I,
                              -3, Vector3D.MINUS_K),
                  2, 0, 3);
      checkVector(new Vector3D(2, Vector3D.PLUS_I,
                               5, Vector3D.PLUS_J,
                              -3, Vector3D.MINUS_K),
                  2, 5, 3);
      checkVector(new Vector3D(2, Vector3D.PLUS_I,
                               5, Vector3D.PLUS_J,
                               5, Vector3D.MINUS_J,
                               -3, Vector3D.MINUS_K),
                  2, 0, 3);
  }
View Full Code Here

                               -3, Vector3D.MINUS_K),
                  2, 0, 3);
  }

  public void testCoordinates() {
    Vector3D v = new Vector3D(1, 2, 3);
    assertTrue(Math.abs(v.getX() - 1) < 1.0e-12);
    assertTrue(Math.abs(v.getY() - 2) < 1.0e-12);
    assertTrue(Math.abs(v.getZ() - 3) < 1.0e-12);
  }
View Full Code Here

    assertTrue(Math.abs(v.getZ() - 3) < 1.0e-12);
  }

  public void testNorm1() {
    assertEquals(0.0, Vector3D.ZERO.getNorm1());
    assertEquals(6.0, new Vector3D(1, -2, 3).getNorm1(), 0);
  }
View Full Code Here

    assertEquals(6.0, new Vector3D(1, -2, 3).getNorm1(), 0);
  }

  public void testNorm() {
      assertEquals(0.0, Vector3D.ZERO.getNorm());
      assertEquals(Math.sqrt(14), new Vector3D(1, 2, 3).getNorm(), 1.0e-12);
    }
View Full Code Here

      assertEquals(Math.sqrt(14), new Vector3D(1, 2, 3).getNorm(), 1.0e-12);
    }

  public void testNormInf() {
      assertEquals(0.0, Vector3D.ZERO.getNormInf());
      assertEquals(3.0, new Vector3D(1, -2, 3).getNormInf(), 0);
    }
View Full Code Here

      assertEquals(0.0, Vector3D.ZERO.getNormInf());
      assertEquals(3.0, new Vector3D(1, -2, 3).getNormInf(), 0);
    }

  public void testDistance1() {
      Vector3D v1 = new Vector3D(1, -2, 3);
      Vector3D v2 = new Vector3D(-4, 2, 0);
      assertEquals(0.0, Vector3D.distance1(Vector3D.MINUS_I, Vector3D.MINUS_I), 0);
      assertEquals(12.0, Vector3D.distance1(v1, v2), 1.0e-12);
      assertEquals(v1.subtract(v2).getNorm1(), Vector3D.distance1(v1, v2), 1.0e-12);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.geometry.Vector3D

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.