Improve tessellation algorithm
Added new mesh class Rewrite mesh algorithms to be less error prone Make code more concise Tried to add some documentation Added half edge set
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user