Package org.apache.commons.math.geometry

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


      assertEquals(12.0, Vector3D.distance1(v1, v2), 1.0e-12);
      assertEquals(v1.subtract(v2).getNorm1(), Vector3D.distance1(v1, v2), 1.0e-12);
  }

  public void testDistance() {
      Vector3D v1 = new Vector3D(1, -2, 3);
      Vector3D v2 = new Vector3D(-4, 2, 0);
      assertEquals(0.0, Vector3D.distance(Vector3D.MINUS_I, Vector3D.MINUS_I), 0);
      assertEquals(Math.sqrt(50), Vector3D.distance(v1, v2), 1.0e-12);
      assertEquals(v1.subtract(v2).getNorm(), Vector3D.distance(v1, v2), 1.0e-12);
  }
View Full Code Here


      assertEquals(Math.sqrt(50), Vector3D.distance(v1, v2), 1.0e-12);
      assertEquals(v1.subtract(v2).getNorm(), Vector3D.distance(v1, v2), 1.0e-12);
  }

  public void testDistanceSq() {
      Vector3D v1 = new Vector3D(1, -2, 3);
      Vector3D v2 = new Vector3D(-4, 2, 0);
      assertEquals(0.0, Vector3D.distanceSq(Vector3D.MINUS_I, Vector3D.MINUS_I), 0);
      assertEquals(50.0, Vector3D.distanceSq(v1, v2), 1.0e-12);
      assertEquals(Vector3D.distance(v1, v2) * Vector3D.distance(v1, v2),
                   Vector3D.distanceSq(v1, v2), 1.0e-12);
  }
View Full Code Here

      assertEquals(Vector3D.distance(v1, v2) * Vector3D.distance(v1, v2),
                   Vector3D.distanceSq(v1, v2), 1.0e-12);
  }

  public void testDistanceInf() {
      Vector3D v1 = new Vector3D(1, -2, 3);
      Vector3D v2 = new Vector3D(-4, 2, 0);
      assertEquals(0.0, Vector3D.distanceInf(Vector3D.MINUS_I, Vector3D.MINUS_I), 0);
      assertEquals(5.0, Vector3D.distanceInf(v1, v2), 1.0e-12);
      assertEquals(v1.subtract(v2).getNormInf(), Vector3D.distanceInf(v1, v2), 1.0e-12);
  }
View Full Code Here

      assertEquals(v1.subtract(v2).getNormInf(), Vector3D.distanceInf(v1, v2), 1.0e-12);
  }

  public void testSubtract() {

    Vector3D v1 = new Vector3D(1, 2, 3);
    Vector3D v2 = new Vector3D(-3, -2, -1);
    v1 = v1.subtract(v2);
    checkVector(v1, 4, 4, 4);

    checkVector(v2.subtract(v1), -7, -6, -5);
    checkVector(v2.subtract(3, v1), -15, -14, -13);

  }
View Full Code Here

    checkVector(v2.subtract(3, v1), -15, -14, -13);

  }

  public void testAdd() {
    Vector3D v1 = new Vector3D(1, 2, 3);
    Vector3D v2 = new Vector3D(-3, -2, -1);
    v1 = v1.add(v2);
    checkVector(v1, -2, 0, 2);

    checkVector(v2.add(v1), -5, -2, 1);
    checkVector(v2.add(3, v1), -9, -2, 5);

  }
View Full Code Here

    checkVector(v2.add(3, v1), -9, -2, 5);

  }

  public void testScalarProduct() {
    Vector3D v = new Vector3D(1, 2, 3);
    v = v.scalarMultiply(3);
    checkVector(v, 3, 6, 9);

    checkVector(v.scalarMultiply(0.5), 1.5, 3, 4.5);

  }
View Full Code Here

    super(name);
  }

  public void testConstructors() {
      double r = FastMath.sqrt(2) /2;
      checkVector(new Vector3D(2, new Vector3D(FastMath.PI / 3, -FastMath.PI / 4)),
                  r, r * FastMath.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(FastMath.abs(v.getX() - 1) < 1.0e-12);
    assertTrue(FastMath.abs(v.getY() - 2) < 1.0e-12);
    assertTrue(FastMath.abs(v.getZ() - 3) < 1.0e-12);
  }
View Full Code Here

    assertTrue(FastMath.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(FastMath.sqrt(14), new Vector3D(1, 2, 3).getNorm(), 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.