Package com.googlecode.jumpnevolve.math

Examples of com.googlecode.jumpnevolve.math.Vector


public class SpeedTest {

  @Test
  public void testSpeedNewRectCollisions() {
    NextShape rect = ShapeFactory.createRectangle(new Vector(10, 100), 20,
        20);
    // NextShape rect2 = ShapeFactory.createRectangle(new Vector(10, 90),
    // 20,20);
    NextShape rect2 = ShapeFactory.createCircle(new Vector(10, 90), 10);
    Date start = new Date();
    long startTime = start.getTime();
    for (int i = 0; i < 1000000; i++) {
      rect.getCollision(rect2, Vector.ZERO, true, true);
      rect = rect.moveCenter(new Vector(0, 0.000001f));
    }
    Date end = new Date();
    long endTime = end.getTime();
    System.out.println("Zeit neu benötigt: " + (endTime - startTime));
  }
View Full Code Here


    System.out.println("Zeit neu benötigt: " + (endTime - startTime));
  }

  @Test
  public void testSpeedOldRectCollisions() {
    Shape rect = new Rectangle(new Vector(10, 100), 20, 20);
    // Rectangle rect2 = new Rectangle(new Vector(10, 90), 20, 20);
    Shape rect2 = new Circle(new Vector(10, 90), 10);
    Date start = new Date();
    long startTime = start.getTime();
    for (int i = 0; i < 1000000; i++) {
      if (rect.doesCollide(rect2)) {
        rect.getCollision(rect2, false, true);
      }
      rect = rect.modifyCenter(rect.getCenter().add(
          new Vector(0, 0.000001f)));
    }
    Date end = new Date();
    long endTime = end.getTime();
    System.out.println("Zeit benötigt: " + (endTime - startTime));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Rectangle#Rectangle(com.googlecode.jumpnevolve.math.Vector, float, float)}
   * .
   */
  @Test
  public void testRectangleVectorFloatFloat() {
    assertThat(new Rectangle(new Vector(0.0f, 1.0f), 200.0f, 100.0f),
        is(new Rectangle(-100.0f, -49.0f, 200.0f, 100.0f)));
    try {
      new Rectangle(new Vector(-10.f, -33.0f), 17.0f, 0.0f);
      fail("Rectangles must have a width and height.");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Rectangle#Rectangle(com.googlecode.jumpnevolve.math.Vector, com.googlecode.jumpnevolve.math.Vector)}
   * .
   */
  @Test
  public void testRectangleVectorVector() {
    assertThat(new Rectangle(new Vector(0.0f, 0.0f), new Vector(10.0f,
        13.0f)),
        is(new Rectangle(new Vector(0.0f, 0.0f), 10.0f, 13.0f)));
    assertThat(new Rectangle(new Vector(10.0f, 10.0f), new Vector(-30.0f,
        -19.0f)), is(new Rectangle(new Vector(10.0f, 10.0f),
        new Vector(-30.0f, -19.0f))));
    try {
      new Rectangle(new Vector(-10.f, -33.0f), Vector.ZERO);
      fail("Rectangles must have a width and height.");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

   */
  @Test
  public void testGetCenter() {
    assertThat(new Rectangle(-10.0f, -20.0f, 20.0f, 40.0f).getCenter(),
        is(Vector.ZERO));
    assertThat(new Rectangle(new Vector(77.0f, 67.0f), 20.0f, -1.0f)
        .getCenter(), is(new Vector(77.0f, 67.0f)));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Rectangle#getLowerRightCorner()}.
   */
  @Test
  public void testGetLowerRightCorner() {
    assertThat(new Rectangle(30.0f, 20.0f, 40.0f, 23.0f)
        .getLowerRightCorner(), is(new Vector(70.0f, 43.0f)));
  }
View Full Code Here

   */
  @Test
  public void testGetCenter() {
    Circle circle = new Circle(10.0f, 4.0f, 1.0f);
    assertThat(circle.position, is(circle.getCenter()));
    assertThat(circle.getCenter(), is(new Vector(10.0f, 4.0f)));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Circle#Circle(float, float, float)}
   * .
   */
  @Test
  public void testCircleFloatFloatFloat() {
    assertThat(new Circle(80.0f, -26.0f, 30.0f).position, is(new Vector(
        80.0f, -26.0f)));
    assertThat(new Circle(0.0f, 1.0f, 99.0f).radius, is(99.0f));
    try {
      new Circle(20.0f, 31.0f, -70.1f);
      fail("A circle can't have a negative radius.");
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Circle#Circle(com.googlecode.jumpnevolve.math.Vector, float)}
   * .
   */
  @Test
  public void testCircleVectorFloat() {
    Circle circle = new Circle(new Vector(190.0f, 2034.0f), 20.0f);
    assertThat(circle.position, is(new Vector(190.0f, 2034.0f)));
    assertThat(circle.radius, is(20.0f));
    assertThat(circle, is(new Circle(190.0f, 2034.0f, 20.0f)));
    try {
      new Circle(new Vector(20.0f, 31.0f), -70.1f);
      fail("A circle can't have a negative radius.");
    } catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

    return this.status;
  }

  public LevelMarker getLevelInDirection(Vector direction) {
    float minAng = Float.POSITIVE_INFINITY;
    Vector cur = null;
    for (Vector vec : this.connections.keySet()) {
      float ang = vec.ang(direction);
      if (ang < minAng) {
        cur = vec;
        minAng = ang;
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.