Files
mc-mesh/src/main/java/com/aaaaahhhhhhh/bananapuncher714/mesh/Polygon.java
BananaPuncher714 d16041f977 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
2025-05-04 00:04:22 -04:00

32 lines
847 B
Java

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;
}
}