Package chunmap.model.elem

Source Code of chunmap.model.elem.AngleTest

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.model.elem;

import static org.junit.Assert.*;

import org.junit.Test;

import chunmap.model.coord.CPoint;
import chunmap.model.coord.Coordinate2D;
import chunmap.util.math.MyDouble;

/**
* @author chunquedong
*
*/
public class AngleTest {

  /**
   * {@link chunmap.model.elem.Angle#computeAngle()} 的测试方法。
   */
  @Test
  public void testComputeAngle() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);

    Angle a = new Angle(p1, p2, p3);
    double d = a.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d), 45));

    Angle a2 = new Angle(p3, p2, p1);
    double d2 = a2.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d2), -45));
  }

  @Test
  public void testComputeAngle2() {
    CPoint p1 = new Coordinate2D(1, 0);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);

    Angle a = new Angle(p1, p2, p3);
    double d = a.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d), 0));

    Angle a2 = new Angle(p2, p1, p3);
    double d2 = a2.computeAngle();
    assertTrue(MyDouble.approximateEquals(Math.toDegrees(d2), 180));
  }

}
TOP

Related Classes of chunmap.model.elem.AngleTest

TOP
Copyright © 2018 www.massapi.com. 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.