Updated readability of the code.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / slicer / BorderLine.java
1 /*
2  * Sixth 3D engine. Author: Svjatoslav Agejenko. 
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5 package eu.svjatoslav.sixth.e3d.renderer.raster.slicer;
6
7 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
8 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
9
10 import java.util.Comparator;
11
12 public class BorderLine implements Comparator<BorderLine> {
13
14     public final int count;
15     final PolygonCoordinate c1;
16     final PolygonCoordinate c2;
17
18     public BorderLine(final PolygonCoordinate c1, final PolygonCoordinate c2,
19                       final int count) {
20         this.c1 = c1;
21         this.c2 = c2;
22         this.count = count;
23     }
24
25     @Override
26     public int compare(final BorderLine o1, final BorderLine o2) {
27         return Double.compare(o1.getLength(), o2.getLength());
28     }
29
30     public double getLength() {
31         return c1.space.getDistanceTo(c2.space);
32     }
33
34     public PolygonCoordinate getMiddlePoint() {
35         return new PolygonCoordinate(new Point3D().computeMiddlePoint(c1.space,
36                 c2.space), new Point2D().setToMiddle(c1.texture,
37                 c2.texture));
38     }
39 }