Package chunmap.model.elem

Source Code of chunmap.model.elem.TriangleTest

/**
* 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 TriangleTest {

  /**
   * {@link chunmap.model.elem.Triangle#computeArea()} 的测试方法。
   */
  @Test
  public void testComputeArea2() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);
    Triangle tria = new Triangle(p1, p2, p3);
    double are = tria.computeArea();

    assertTrue(MyDouble.approximateEquals(are, 2.0));
  }

  /**
   * {@link chunmap.model.elem.Triangle#computeOuterCenter()} 的测试方法。
   */
  @Test
  public void testComputeOuterCenter() {
    CPoint p1 = new Coordinate2D(2, 2);
    CPoint p2 = new Coordinate2D(0, 0);
    CPoint p3 = new Coordinate2D(2, 0);
    Triangle tria = new Triangle(p1, p2, p3);
    CPoint p = tria.computeOuterCenter();
    CPoint ep = new Coordinate2D(1, 1);
    assertTrue(p.equals(ep));
  }

  @Test
  public void testComputeCenter() {
    CPoint p1 = new Coordinate2D(-1, 0);
    CPoint p2 = new Coordinate2D(1, 0);
    CPoint p3 = new Coordinate2D(0, 2);
    Triangle tria = new Triangle(p1, p2, p3);
    CPoint p = tria.computeCenter();
    CPoint ep = new Coordinate2D(0, 2d / 3d);
    assertTrue(p.equals(ep));
  }

}
TOP

Related Classes of chunmap.model.elem.TriangleTest

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.