Class LineInterpolator
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineInterpolator
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
ConstructorsConstructorDescriptionCreates a new line interpolator with uninitialized endpoints. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsY(int y) Checks if the given Y coordinate falls within the vertical span of this line.doublegetD()Returns the depth value (d) at the current Y position.intgetX(int y) Computes the X coordinate for the given Y position.voidsetPoints(double x1, double y1, double d1, double x2, double y2, double d2) Sets the endpoints and depth values for this line interpolator.
-
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:
trueif 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 pointy1- the Y coordinate of the first pointd1- the depth value at the first pointx2- the X coordinate of the second pointy2- the Y coordinate of the second pointd2- the depth value at the second point
-