Package com.googlecode.jumpnevolve.math

Examples of com.googlecode.jumpnevolve.math.Rectangle


    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(float, float, float, float)}
   * .
   */
  @Test
  public void testRectangleFloatFloatFloatFloat() {
    Rectangle rect = new Rectangle(20.0f, 45.0f, 800.0f, 300.0f);
    assertThat(rect.x, is(20.0f));
    assertThat(rect.y, is(45.0f));
    assertThat(rect.width, is(800.0f));
    assertThat(rect.height, is(300.0f));
    rect = new Rectangle(0.0f, 0.0f, -200.0f, 100.0f);
    assertThat(rect.x, is(-200.f));
    assertThat(rect.y, is(0.0f));
    assertThat(rect.width, is(200.0f));
    assertThat(rect.height, is(100.0f));
    try {
      new Rectangle(-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, 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 method for
   * {@link com.googlecode.jumpnevolve.math.Rectangle#getArea()}.
   */
  @Test
  public void testGetArea() {
    assertThat(new Rectangle(70.0f, -27.0f, 99.0f, -20.0f).getArea(),
        is(99.0f * 20.0f));
  }
 
View Full Code Here

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Rectangle#getCenter()}.
   */
  @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

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Rectangle#getBestCircle()}.
   */
  @Test
  public void testGetBestCircle() {
    Circle bestCircle = new Rectangle(35.0f, -500.0f, 30.0f, 500.0f)
        .getBestCircle();
    assertThat(bestCircle.radius, is(lessThan(new Rectangle(35.0f, -500.0f,
        30.0f, 500.0f).getBoundingCircle().radius)));
  }
View Full Code Here

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Rectangle#getBoundingCircle()}.
   */
  @Test
  public void testGetBoundingCircle() {
    Rectangle rect = new Rectangle(0.0f, 0.0f, 12.0f, 25.0f);
    Circle boundingCircle = rect.getBoundingCircle();
    assertThat(boundingCircle.getCenter(), is(rect.getCenter()));
    assertThat(boundingCircle.radius, is((float) Math.sqrt(12.0f * 12.0f
        / 4.0f + 25.0f * 25.0f / 4.0f)));
  }
View Full Code Here

   * Test method for
   * {@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

   * {@link com.googlecode.jumpnevolve.math.Rectangle#getBoundingRectangle(com.googlecode.jumpnevolve.math.Rectangle)}
   * .
   */
  @Test
  public void testGetBoundingRectangle() {
    Rectangle rect = new Rectangle(55.0f, -20.0f, 356.0f, 23.0f);
    assertThat(rect.getBoundingRectangle(rect), is(rect));
    assertThat(rect.getBoundingRectangle(new Rectangle(0.0f, 0.0f, 20.0f,
        1.0f)), is(new Rectangle(0.0f, -20.0f, 55.0f + 356.0f, 23.0f)));
  }
View Full Code Here

TOP

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

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.