package com.aaaaahhhhhhh.bananapuncher714.mesh; import java.util.List; /** * A list of points denoting the shape of the polygon. May contain self intersections, * duplicate vertices, and overlapping edges. * * @author BananaPuncher714 */ public class Polygon { protected List< Point > points; public Polygon( List< Point > points ) { this.points = points; } public List< Point > getPoints() { return points; } public double area() { double area = 0; for ( int i = 0; i < points.size(); ++i ) { final Vector2d a = new Vector2d( points.get( i ) ); final Vector2d b = new Vector2d( points.get( ( i + 1 ) % points.size() ) ); area += a.cross( b ); } return Math.abs( area ) / 2.0; } }