java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineInterpolator

public class LineInterpolator extends Object
Interpolates between two points along a line for scanline rendering.

This class calculates screen coordinates and depth values (d) for a given Y position. It supports perspective-correct interpolation by tracking the distance between points and using it to compute step increments.

The comparison logic prioritizes interpolators with greater vertical coverage to optimize scanline ordering.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new line interpolator with uninitialized endpoints.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsY(int y)
    Checks if the given Y coordinate falls within the vertical span of this line.
    double
    Returns the depth value (d) at the current Y position.
    int
    getX(int y)
    Computes the X coordinate for the given Y position.
    void
    setPoints(double x1, double y1, double d1, double x2, double y2, double d2)
    Sets the endpoints and depth values for this line interpolator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LineInterpolator

      public LineInterpolator()
      Creates a new line interpolator with uninitialized endpoints.
  • Method Details

    • containsY

      public boolean containsY(int y)
      Checks if the given Y coordinate falls within the vertical span of this line.
      Parameters:
      y - the Y coordinate to test
      Returns:
      true if y is between y1 and y2 (inclusive)
    • getD

      public double getD()
      Returns the depth value (d) at the current Y position.
      Returns:
      the interpolated depth value
    • getX

      public int getX(int y)
      Computes the X coordinate for the given Y position.
      Parameters:
      y - the Y coordinate
      Returns:
      the interpolated X coordinate
    • setPoints

      public void setPoints(double x1, double y1, double d1, double x2, double y2, double d2)
      Sets the endpoints and depth values for this line interpolator.
      Parameters:
      x1 - the X coordinate of the first point
      y1 - the Y coordinate of the first point
      d1 - the depth value at the first point
      x2 - the X coordinate of the second point
      y2 - the Y coordinate of the second point
      d2 - the depth value at the second point