Month: September 2013

Calculate centroid of 2D non crossing polygon

Calculate centroid of 2D non crossing polygon,To accommodate that points are correct using Gift wrapping algorithm(Finding Convex Hull) Test case import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.awt.Point; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.Test; public class MathUtilTest { @Test public void computeCentroidWithHull() { Point p1 = new Point(1, 1); Point p2 = new …

Calculate centroid of 2D non crossing polygon Read More »