2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon;
7 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
9 public class LineInterpolator implements Comparable<LineInterpolator> {
15 private int absoluteHeight;
18 public boolean equals(final Object o) {
19 if (o == null) return false;
21 return o instanceof LineInterpolator && compareTo((LineInterpolator) o) == 0;
25 public int compareTo(final LineInterpolator o) {
26 if (absoluteHeight < o.absoluteHeight)
28 if (absoluteHeight > o.absoluteHeight)
31 return Integer.compare(o.width, width);
36 public int hashCode() {
38 result = 31 * result + absoluteHeight;
42 public boolean containsY(final int y) {
55 public int getX(final int y) {
58 return (int) (p2.x + p1.x) / 2;
60 return (int) (p1.x + ((width * (y - p1.y)) / height));
63 public void setPoints(final Point2D p1, final Point2D p2) {
66 height = (int) (p2.y - p1.y);
67 width = (int) (p2.x - p1.x);
69 absoluteHeight = Math.abs(height);