final PolygonCoordinate pc2, final PolygonCoordinate pc3,
final Texture texture) {
- this(pc1.space, pc2.space, pc3.space, pc1.texture, pc2.texture,
- pc3.texture, texture);
+ this(pc1.spaceCoordinate, pc2.spaceCoordinate, pc3.spaceCoordinate, pc1.textureCoordinate, pc2.textureCoordinate,
+ pc3.textureCoordinate, texture);
}
private void computeTotalTextureDistance() {
}
public double getLength() {
- return c1.space.getDistanceTo(c2.space);
+ return c1.spaceCoordinate.getDistanceTo(c2.spaceCoordinate);
}
public PolygonCoordinate getMiddlePoint() {
- return new PolygonCoordinate(new Point3D().computeMiddlePoint(c1.space,
- c2.space), new Point2D().setToMiddle(c1.texture,
- c2.texture));
+ return new PolygonCoordinate(new Point3D().computeMiddlePoint(c1.spaceCoordinate,
+ c2.spaceCoordinate), new Point2D().setToMiddle(c1.textureCoordinate,
+ c2.textureCoordinate));
}
}
import eu.svjatoslav.sixth.e3d.geometry.Point2D;
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+/**
+ * Polygon coordinate.
+ * This class is used to store coordinates of a point in 3D space and its
+ * texture coordinate.
+ */
public class PolygonCoordinate {
- public Point3D space;
- public Point2D texture;
+ /**
+ * Space coordinate of the point.
+ */
+ public Point3D spaceCoordinate;
+
+ /**
+ * Texture coordinate of the point.
+ */
+ public Point2D textureCoordinate;
- public PolygonCoordinate(final Point3D space, final Point2D texture) {
- this.space = space;
- this.texture = texture;
+ public PolygonCoordinate(final Point3D spaceCoordinate, final Point2D textureCoordinate) {
+ this.spaceCoordinate = spaceCoordinate;
+ this.textureCoordinate = textureCoordinate;
}
}
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon.TexturedPolygon;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+import static java.util.Arrays.sort;
+
public class Slicer {
+ /**
+ * Maximum distance between two points.
+ * If the distance is greater than this value, the polygon will be sliced.
+ * Otherwise, it will be added to the result.
+ */
private final double maxDistance;
+
+ /**
+ * Result of slicing.
+ */
private final List<TexturedPolygon> result = new ArrayList<>();
public Slicer(final double maxDistance) {
}
private void considerSlicing(final PolygonCoordinate c1,
- final PolygonCoordinate c2, final PolygonCoordinate c3,
+ final PolygonCoordinate c2,
+ final PolygonCoordinate c3,
final TexturedPolygon originalPolygon) {
final BorderLine[] lines = new BorderLine[]{
new BorderLine(c1, c2, 1), new BorderLine(c2, c3, 2),
new BorderLine(c3, c1, 3)};
- Arrays.sort(lines, lines[0]);
+ sort(lines, lines[0]);
final BorderLine longestLine = lines[2];