Package com.googlecode.jumpnevolve.math

Examples of com.googlecode.jumpnevolve.math.Circle


  @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);
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

   * {@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

  public void testDoesCollide() {
    Rectangle rect = new Rectangle(55.0f, -20.0f, 356.0f, 23.0f);
    assertThat(rect.doesCollide(rect), is(true));
    assertThat(rect.doesCollide(rect.getBestCircle()), is(true));
    assertThat(rect.doesCollide(rect.getBoundingCircle()), is(true));
    assertThat(rect.doesCollide(new Circle(4000.0f, 4000.0f, 2.0f)),
        is(false));
    assertThat(rect.doesCollide(new Circle(0.0f, 0.0f, 60.0f)), is(true));
  }
View Full Code Here

   * {@link com.googlecode.jumpnevolve.math.Circle#doesCollide(com.googlecode.jumpnevolve.math.Shape)}
   * .
   */
  @Test
  public void testDoesCollide() {
    Circle circle = new Circle(0.4f, 0.99f, 29.0f);
    assertThat(circle.doesCollide(circle), is(true));
    assertThat(circle.doesCollide(circle.getBoundingRect()), is(true));
    assertThat(
        circle.doesCollide(new Rectangle(26.0f, 0.0f, 80.0f, 21.0f)),
        is(true));
    assertThat(circle.doesCollide(new Circle(30.0f, 30.0f, 0.1f)),
        is(false));
    assertThat(circle.doesCollide(new Rectangle(999.0f, 999.0f, 0.1f,
        1000.0f)), is(false));
  }
View Full Code Here

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Circle#getBestCircle()}.
   */
  @Test
  public void testGetBestCircle() {
    assertThat(new Circle(27.0f, 1.0f, 756.5f).getBestCircle(),
        is(new Circle(27.0f, 1.0f, 756.5f)));
  }
View Full Code Here

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

   * Test method for
   * {@link com.googlecode.jumpnevolve.math.Circle#getBoundingRect()}.
   */
  @Test
  public void testGetBoundingRectangle() {
    assertThat(new Circle(0.0f, 0.0f, 20.0f).getBoundingRect(),
        is(new Rectangle(-20.0f, -20.0f, 40.0f, 40.f)));
  }
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.");
    } catch (IllegalArgumentException e) {
    }
  }
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

TOP

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

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.