/sigmah/src/test/java/org/sigmah/server/report/generator/map/CircleMathTest.java

http://sigma-h.googlecode.com/ · Java · 43 lines · 25 code · 14 blank · 4 comment · 0 complexity · 6acc930665c29f740fd60467ae020907 MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.server.report.generator.map;
  6. import org.junit.Assert;
  7. import org.junit.Test;
  8. import org.sigmah.shared.report.content.Point;
  9. public class CircleMathTest {
  10. private static final double DELTA = 0.001;
  11. @Test
  12. public void testNoIntersection() {
  13. Point a = new Point(0, 0);
  14. Point b = new Point(5, 0);
  15. Assert.assertEquals(0.0, CircleMath.intersectionArea(a, b, 1, 2), DELTA);
  16. }
  17. @Test
  18. public void testTangentIntersection() {
  19. Point a = new Point(0, 0);
  20. Point b = new Point(2, 0);
  21. Assert.assertEquals(0.0, CircleMath.intersectionArea(a, b, 1, 1), DELTA);
  22. }
  23. @Test
  24. public void testCompletelyContained() {
  25. Point a = new Point(297, 212);
  26. Point b = new Point(295, 213);
  27. Assert.assertEquals(CircleMath.area(5), CircleMath.intersectionArea(a, b, 8, 5), DELTA);
  28. }
  29. }