Package com.googlecode.jumpnevolve.math

Examples of com.googlecode.jumpnevolve.math.Vector


   * .
   */
  @Test
  public void testGetDistance() {
    assertThat(Vector.ZERO.getDistance(Vector.ZERO), is(0.0f));
    assertThat(Vector.ZERO.getDistance(new Vector(44, 20)), is(new Vector(
        44, 20).abs()));
    assertThat(new Vector(-27, 29).getDistance(new Vector(200, 107)),
        is(new Vector(-27, 29).sub(new Vector(200, 107)).abs()));
  }
View Full Code Here


  public void testGetNormal() {
    assertThat(Vector.DOWN.getNormal(), either(is(Vector.LEFT)).or(
        is(Vector.RIGHT)));
    assertThat(Vector.LEFT.getNormal(), either(is(Vector.UP)).or(
        is(Vector.DOWN)));
    assertThat(new Vector(7, 5).getNormal(), either(is(new Vector(-5, 7)))
        .or(is(new Vector(5, -7))));
  }
View Full Code Here

   */
  @Test
  public void testIsZero() {
    assertThat(Vector.ZERO.isZero(), is(true));
    assertThat(Vector.RIGHT.isZero(), is(false));
    assertThat(new Vector(0, 0).isZero(), is(true));
    assertThat(new Vector(0, 16).isZero(), is(false));
    assertThat(new Vector(-2, 2).isZero(), is(false));
  }
View Full Code Here

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Vector#mulAsLists(Vector)}
   */
  @Test
  public void testMulAsLists() {
    assertThat(Vector.ZERO.mulAsLists(new Vector(939.0f, -193.0f)),
        is(Vector.ZERO));
    assertThat(Vector.LEFT.mulAsLists(Vector.UP), is(Vector.ZERO));
    assertThat(new Vector(3, 5).mulAsLists(new Vector(-2, 4)),
        is(new Vector(-6, 20)));
  }
View Full Code Here

   */
  @Test
  public void testMulFloat() {
    assertThat(Vector.ZERO.mul(18), is(Vector.ZERO));
    assertThat(Vector.RIGHT.mul(0), is(Vector.ZERO));
    assertThat(new Vector(14, 18).mul(1), is(new Vector(14, 18)));
    assertThat(new Vector(-3, 4).mul(2), is(new Vector(-6, 8)));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Vector#mul(com.googlecode.jumpnevolve.math.Vector)}
   * .
   */
  @Test
  public void testMulVector() {
    assertThat(new Vector(9, 1).mul(Vector.ZERO), is(0.0f));
    assertThat(new Vector(9, 1).mul(Vector.RIGHT), is(9.0f));
    assertThat(new Vector(2, 4).mul(new Vector(50, 12)),
        is(2.0f * 50.0f + 4.0f * 12.0f));
    assertThat(new Vector(17, 18).mul(new Vector(17, 18)), is(new Vector(
        17, 18).squareAbs()));
  }
View Full Code Here

   */
  @Test
  public void testSquareAbs() {
    assertThat(Vector.ZERO.squareAbs(), is(0.0f));
    assertThat(Vector.RIGHT.squareAbs(), is(1.0f));
    assertThat(new Vector(4, 3).squareAbs(), is(25.0f));
    assertThat(new Vector(29, 21).squareAbs(), is(new Vector(21, 29).abs()
        * new Vector(29, 21).abs()));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Vector#sub(com.googlecode.jumpnevolve.math.Vector)}
   * .
   */
  @Test
  public void testSub() {
    assertThat(new Vector(18, 19).sub(Vector.ZERO), is(new Vector(18, 19)));
    assertThat(new Vector(77, -11).sub(new Vector(1, 2)), is(new Vector(76,
        -13)));
  }
View Full Code Here

  public void testAng() {
    assertThat(Vector.DOWN.ang(Vector.LEFT), is((float) Math.PI / 2.0f));
    assertThat(Vector.DOWN.mul(72.1f).ang(Vector.RIGHT.mul(0.2f)),
        is((float) Math.PI / 2.0f));
    assertThat(Vector.LEFT.ang(Vector.RIGHT), is((float) Math.PI));
    assertThat(new Vector(8, 2).getNormal().ang(new Vector(8, 2)),
        is((float) Math.PI / 2.0f));
    assertThat(new Vector(735.0f, 24.0f).ang(new Vector(1.1f, 34.0f)),
        is(new Vector(1.1f, 34.0f).ang(new Vector(735.0f, 24.0f))));
    assertThat(Vector.UP.ang(new Vector(1.0f, -1.0f)),
        is((float) Math.PI / 4.0f));
    assertThat(new Vector(635.0f, 2.0f).ang(), is(greaterThan(new Vector(
        -1.0f, -1.0f).ang())));
  }
View Full Code Here

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Vector#parseVector(String)}.
   */
  @Test
  public void testParseVector() {
    assertThat(Vector.parseVector("17|18"), is(new Vector(17, 18)));
    assertThat(Vector.parseVector("  (9, 1e-5   "),
        is(new Vector(9, 1e-5f)));
    assertThat(Vector.parseVector(Vector.UP.toString()), is(Vector.UP));
    assertThat(Vector.parseVector("   ( 1.000 , 2.123  \t  )"),
        is(new Vector(1.0f, 2.123f)));

    try {
      Vector.parseVector("(ABC,eee");
      throw new AssertionError("NumberFormatException expeted.");
    } catch (NumberFormatException expected) {
View Full Code Here

TOP

Related Classes of com.googlecode.jumpnevolve.math.Vector

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.