2 * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon;
12 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
14 public class LineInterpolator implements Comparable<LineInterpolator> {
20 private int absoluteHeight;
23 public boolean equals(final Object o) {
24 if (o == null) return false;
26 return o instanceof LineInterpolator && compareTo((LineInterpolator) o) == 0;
30 public int compareTo(final LineInterpolator o) {
31 if (absoluteHeight < o.absoluteHeight)
33 if (absoluteHeight > o.absoluteHeight)
45 public int hashCode() {
47 result = 31 * result + absoluteHeight;
51 public boolean containsY(final int y) {
64 public int getX(final int y) {
67 return (int) (p2.x + p1.x) / 2;
69 return (int) (p1.x + ((width * (y - p1.y)) / height));
72 public void setPoints(final Point2D p1, final Point2D p2) {
75 height = (int) (p2.y - p1.y);
76 width = (int) (p2.x - p1.x);
78 absoluteHeight = Math.abs(height);