java.lang.Object
io.github.shimeoki.jfx.rasterization.triangle.Barycentricser

public final class Barycentricser extends Object
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 Details

  • Method Details

    • barycentrics

      public Barycentrics 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

      public Triangle 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

      public void setTriangle(Triangle t)
      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 - if t is null
      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 coordinate
      y - second coordinate
      Since:
      2.0.0