Package classes

Examples of classes.PointR


    assertTrue(o.equals(o));
  }

  @Test
  public void testDistance() {
    PointR a = new PointR(1, 1, 0);
    PointR b = new PointR(4, 5, 0);
    assertTrue(((float) PointR.getDistance(a, b)) == 5.0f);
  }
View Full Code Here


    assertTrue(((float) PointR.getDistance(a, b)) == 5.0f);
  }

  @Test
  public void testInstanceDistance() {
    PointR a = new PointR(1, 1, 0);
    PointR b = new PointR(4, 5, 0);
    assertTrue(a.getDistance(b) == PointR.getDistance(a, b));
  }
View Full Code Here

  }

  @Test
  public void testCentroid() {
    List<PointR> a = new ArrayList<PointR>();
    a.add(new PointR(1, 1, 0));
    a.add(new PointR(2, 2, 0));
    a.add(new PointR(3, 9, 0));
    PointR centroid = PointR.getCentroid(a);
    assertTrue(centroid.equals(new PointR(2, 4)));
  }
View Full Code Here

  }

  @Test
  public void testPathLength() {
    List<PointR> a = new ArrayList<PointR>();
    a.add(new PointR(1, 1, 0));
    a.add(new PointR(4, 5, 0));
    a.add(new PointR(7, 9, 0));
    double length = PointR.getPathLength(a);
    assertTrue(length == 10.0);
  }
View Full Code Here

  }

  @Test
  public void testFindBox() {
    ArrayList<PointR> points = new ArrayList<PointR>();
    PointR p1 = new PointR(0, 0);
    PointR p2 = new PointR(4, 0);
    PointR p3 = new PointR(0, 2);
    PointR p4 = new PointR(4, 2);
    points.add(p1);
    points.add(p2);
    points.add(p3);
    points.add(p4);
    if (PointR.findBox(points).getMaxSide() != 4)
View Full Code Here

      fail("PointR.FindBox not working properly");
  }

  @Test
  public void testAngleinRadians() {
    PointR p1 = new PointR(0, 0);
    PointR p2 = new PointR(4, 2);
    if (PointR.getAngleInRadians(p1, p2, true) != Math.atan2(2, 4))
      fail("PointR pathlength calculation not working properly");
    if (PointR.getAngleInRadians(p1, p2, false) != Math.atan2(2, 4))
      fail("PointR pathlength calculation not working properly");
    PointR p3 = new PointR(4, 0);
    // -90 degrees is straight up
    assertEquals(-Math.PI / 2.0, PointR.getAngleInRadians(p2, p3, false),
        0.001);
    // With positiveOnly
    assertEquals((-Math.PI / 2.0) + (Math.PI * 2.0),
        PointR.getAngleInRadians(p2, p3, true), 0.001);
    PointR p4 = new PointR(4, 6);
    // 90 degrees is straight down
    assertEquals(Math.PI / 2.0, PointR.getAngleInRadians(p2, p4, true),
        0.001);
    PointR p5 = p4;
    // Identical points
    assertEquals(0.0, PointR.getAngleInRadians(p4, p5, true), 0.001);
  }
View Full Code Here

    // Size equals to 0
    List<PointR> points = new ArrayList<PointR>();
    List<PointR> result = PointR.rotateByRadians(points, 0);
    assertEquals(0, result.size());
   
    PointR p1a = new PointR(2, 2);
    PointR p2a = new PointR(4, 6);
    //c : 3, 4
    points.add(p1a);
    points.add(p2a);
    // 30 degrees
    double radians = Math.PI / 6;
    List<PointR> newPoints = PointR.rotateByRadians(points, radians);
    PointR p1b = new PointR(3.133974596216, 1.767949192431);
    PointR p2b = new PointR(2.866025403784, 6.232050807569);
    assertEquals(newPoints.get(0).getX(), p1b.getX(), 0.000001);
    assertEquals(newPoints.get(1).getX(), p2b.getX(), 0.0000001);
    assertEquals(newPoints.get(0).getY(), p1b.getY(), 0.0000001);
    assertEquals(newPoints.get(1).getY(), p2b.getY(), 0.0000001);
  }
View Full Code Here

        .getHeight() == 5));
  }
 
  @Test
  public void testTopLeft() {
    PointR tl = rr.getTopleft();
    assertTrue(tl.getX() == 2 && tl.getY() == 3);
  }
View Full Code Here

    assertTrue(tl.getX() == 2 && tl.getY() == 3);
  }
 
  @Test
  public void testBottomRight() {
    PointR tl = rr.getBottomRight();
    PointR tt = new PointR(6.0, 8.0);
    assertTrue(tt.equals(tl));
  }
View Full Code Here

    assertTrue(tt.equals(tl));
  }
 
  @Test
  public void testCenterPoint() {
    PointR tl = rr.getCenter();
    PointR cc = new PointR(4.0, 5.5);
    assertTrue(tl.equals(cc));
  }
View Full Code Here

TOP

Related Classes of classes.PointR

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.