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.line;
7 public class LineInterpolator {
9 private double x1, y1, d1, x2, y2, d2;
16 public boolean containsY(final int y) {
27 public double getD() {
31 public int getX(final int y) {
33 return (int) (x2 + x1) / 2;
35 final int distanceFromY1 = y - (int) y1;
37 d = d1 + ((dinc * distanceFromY1) / height);
39 return (int) x1 + ((width * distanceFromY1) / height);
42 public void setPoints(final double x1, final double y1, final double d1,
43 final double x2, final double y2, final double d2) {
53 height = (int) y2 - (int) y1;
54 width = (int) x2 - (int) x1;