Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
47d1a7881This file is pinned to the selected release. Download the original to open it in your design tool.
package com.marginallyclever.makelangelo.turtle;
import org.jetbrains.annotations.Contract;
/**
* A {@link Line2d} is a series of connected 2D points with double precision.
*/
public class Line2d extends ConcreteListOfPoints {
@Contract(pure = true)
public boolean isClosed(double epsilon) {
var points = getAllPoints();
if(points.size()<2) return false;
var first = points.getFirst();
var last = points.getLast();
if(first == last) return true; // same instance, must match
return first.distanceSquared(last) < epsilon*epsilon;
}
@Contract(pure = true)
public boolean isClosed() {
return isClosed(1e-6);
}
}