2 * Sixth 3D engine. Copyright ©2012-2020, 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)
36 return Integer.compare(o.width, width);
41 public int hashCode() {
43 result = 31 * result + absoluteHeight;
47 public boolean containsY(final int y) {
60 public int getX(final int y) {
63 return (int) (p2.x + p1.x) / 2;
65 return (int) (p1.x + ((width * (y - p1.y)) / height));
68 public void setPoints(final Point2D p1, final Point2D p2) {
71 height = (int) (p2.y - p1.y);
72 width = (int) (p2.x - p1.x);
74 absoluteHeight = Math.abs(height);