Class Barycentricser
java.lang.Object
io.github.shimeoki.jfx.rasterization.triangle.Barycentricser
A class for memory and time efficient
Barycentrics
generation from a Triangle.
Exists for 3 reasons: to not allocate new barycentrics each time, to cache the calculations for a single triangle and to not enforce the implementation of this functionality on user.
- Since:
- 2.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a reference to the triangle barycentrics in this barycentricser object.voidcalculate(float x, float y) Calculates the barycentrics in this barycenctricser based on the current coordinates.voidSets the new triangle to calculate the barycentrics for.triangle()Returns a reference to the current used triangle in this barycentricser object.voidupdate()Updates cached points to the current state of the used triangle.
-
Constructor Details
-
Barycentricser
public Barycentricser()Creates a newBarycentricserinstance.Creates a new
Barycentricswith zeros as coordinates.- Since:
- 2.0.0
- See Also:
-
-
Method Details
-
barycentrics
Returns a reference to the triangle barycentrics in this barycentricser object.- Returns:
- reference to the barycentrics in this barycentricser
- Since:
- 2.0.0
- See Also:
-
triangle
Returns a reference to the current used triangle in this barycentricser object.- Returns:
- reference to the triangle in this barycentricser
- Since:
- 2.0.0
- See Also:
-
setTriangle
Sets the new triangle to calculate the barycentrics for.Updates the barycentrics in the object automatically on call.
- Parameters:
t- the triangle to use- Throws:
NullPointerException- iftisnull- Since:
- 2.0.0
- See Also:
-
update
public void update()Updates cached points to the current state of the used triangle.Because the triangle can be modified externally (and just a new one can be set), but the rasterization process considers only a single frame, the update is a separate method.
- Since:
- 2.0.0
-
calculate
public void calculate(float x, float y) Calculates the barycentrics in this barycenctricser based on the current coordinates.Updates the triangle barycentrics object accordingly on call.
- Parameters:
x- first coordinatey- second coordinate- Since:
- 2.0.0
-