コード例 #1
0
 @Test
 public void atanSafe() {
   assertEquals(Math.PI / 2.0, UtilAngle.atanSafe(0.0, 0.0), 1e-8);
   assertEquals(Math.PI / 2.0, UtilAngle.atanSafe(1.0, 0.0), 1e-8);
   assertEquals(-Math.PI / 2.0, UtilAngle.atanSafe(-1.0, 0.0), 1e-8);
   assertEquals(Math.atan(1), UtilAngle.atanSafe(1.0, 1.0), 1e-8);
 }
コード例 #2
0
 @Test
 public void isStandardDomain() {
   assertTrue(UtilAngle.isStandardDomain(0.1));
   assertTrue(UtilAngle.isStandardDomain(-0.1));
   assertFalse(UtilAngle.isStandardDomain(4));
   assertFalse(UtilAngle.isStandardDomain(-4));
 }
コード例 #3
0
  @Test
  public void domain2PI() {
    double angles[] = new double[] {-0.1, -Math.PI, -0.4, 0.1, 0.4, 2.5, Math.PI};

    for (double angle : angles) {
      assertEquals(Math.cos(angle), Math.cos(UtilAngle.domain2PI(angle)), 1e-8);
      assertEquals(Math.sin(angle), Math.sin(UtilAngle.domain2PI(angle)), 1e-8);
    }
  }
コード例 #4
0
  @Test
  public void distHalf_F64() {
    assertEquals(0, UtilAngle.distHalf(0, 0), 1e-8);
    assertEquals(0, UtilAngle.distHalf(Math.PI / 2, Math.PI / 2), 1e-8);
    assertEquals(0, UtilAngle.distHalf(-Math.PI / 2, -Math.PI / 2), 1e-8);
    assertEquals(0, UtilAngle.distHalf(Math.PI / 2, -Math.PI / 2), 1e-8);
    assertEquals(0, UtilAngle.distHalf(-Math.PI / 2, Math.PI / 2), 1e-8);

    assertEquals(0.2, UtilAngle.distHalf(0.1, -0.1), 1e-8);
    assertEquals(Math.PI / 2.0, UtilAngle.distHalf(0, Math.PI / 2.0), 1e-8);
    assertEquals(Math.PI / 2.0 - 0.1, UtilAngle.distHalf(-0.1, Math.PI / 2.0), 1e-8);
  }
コード例 #5
0
 @Test
 public void toHalfCircle() {
   assertEquals(0, UtilAngle.toHalfCircle(0), 1e-8);
   assertEquals(0.1, UtilAngle.toHalfCircle(0.1), 1e-8);
   assertEquals(1.9 - Math.PI, UtilAngle.toHalfCircle(1.9), 1e-8);
   assertEquals(0, UtilAngle.toHalfCircle(Math.PI), 1e-8);
   assertEquals(0.1, UtilAngle.toHalfCircle(0.1 - Math.PI), 1e-8);
   assertEquals(0.9, UtilAngle.toHalfCircle(0.9 - Math.PI), 1e-8);
 }
コード例 #6
0
 @Test
 public void reflectZeroToOne_F32() {
   assertEquals(0.00f, UtilAngle.reflectZeroToOne(2.0f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(1.00f, UtilAngle.reflectZeroToOne(1.0f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.00f, UtilAngle.reflectZeroToOne(0.0f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.50f, UtilAngle.reflectZeroToOne(1.5f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.25f, UtilAngle.reflectZeroToOne(1.75f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.25f, UtilAngle.reflectZeroToOne(-0.25f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.25f, UtilAngle.reflectZeroToOne(0.25f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.50f, UtilAngle.reflectZeroToOne(0.50f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.50f, UtilAngle.reflectZeroToOne(-0.50f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(1.00f, UtilAngle.reflectZeroToOne(-1.0f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.00f, UtilAngle.reflectZeroToOne(-6.0f), GrlConstants.FLOAT_TEST_TOL);
   assertEquals(0.75f, UtilAngle.reflectZeroToOne(-5.25f), GrlConstants.FLOAT_TEST_TOL);
 }
コード例 #7
0
 @Test
 public void reflectZeroToOne_F64() {
   assertEquals(0.00, UtilAngle.reflectZeroToOne(2.0), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(1.00, UtilAngle.reflectZeroToOne(1.0), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.00, UtilAngle.reflectZeroToOne(0.0), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.50, UtilAngle.reflectZeroToOne(1.5), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.25, UtilAngle.reflectZeroToOne(1.75), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.25, UtilAngle.reflectZeroToOne(-0.25), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.25, UtilAngle.reflectZeroToOne(0.25), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.50, UtilAngle.reflectZeroToOne(0.50), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.50, UtilAngle.reflectZeroToOne(-0.50), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(1.00, UtilAngle.reflectZeroToOne(-1.0), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.00, UtilAngle.reflectZeroToOne(-6.0), GrlConstants.DOUBLE_TEST_TOL);
   assertEquals(0.75, UtilAngle.reflectZeroToOne(-5.25), GrlConstants.DOUBLE_TEST_TOL);
 }