2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
8 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon;
10 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
12 public class LineInterpolator implements Comparable<LineInterpolator> {
18 private int absoluteHeight;
21 public boolean equals(final Object o) {
22 if (o == null) return false;
24 return o instanceof LineInterpolator && compareTo((LineInterpolator) o) == 0;
28 public int compareTo(final LineInterpolator o) {
29 if (absoluteHeight < o.absoluteHeight)
31 if (absoluteHeight > o.absoluteHeight)
34 return Integer.compare(o.width, width);
39 public int hashCode() {
41 result = 31 * result + absoluteHeight;
45 public boolean containsY(final int y) {
58 public int getX(final int y) {
61 return (int) (p2.x + p1.x) / 2;
63 return (int) (p1.x + ((width * (y - p1.y)) / height));
66 public void setPoints(final Point2D p1, final Point2D p2) {
69 height = (int) (p2.y - p1.y);
70 width = (int) (p2.x - p1.x);
72 absoluteHeight = Math.abs(height);