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

public final class Barycentrics extends Object
A class that represents barycentric coordinates using floats.

The main usage is to act as a data object for the Filler.

The coordinates are mutable for the usage of the same object instead of creating a new one everytime. It can be seen in Barycentricser.

It is recommended to keep the coordinates normalized (based on the theory). Documentation: Wikipedia.

Since:
2.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Barycentrics(float lambda1, float lambda2, float lambda3)
    Creates a new Barycentrics instance with initial values.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Gets the boolean value of the statement "are these barycentrics inside of a triangle?".
    float
    Gets the first barycentric coordinate.
    float
    Gets the second barycentric coordinate.
    float
    Gets the third barycentric coordinate.
    boolean
    Gets the boolean value of the statement "are these barycentrics normalized?".
    void
    setLambda1(float v)
    Sets the value of the first barycentric coordinate.
    void
    setLambda2(float v)
    Sets the value of the second barycentric coordinate.
    void
    setLambda3(float v)
    Sets the value of the third barycentric coordinate.

    Methods inherited from class java.lang.Object

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

    • Barycentrics

      public Barycentrics(float lambda1, float lambda2, float lambda3)
      Creates a new Barycentrics instance with initial values.
      Parameters:
      lambda1 - initial value of the first barycentric coordinate
      lambda2 - initial value of the second barycentric coordinate
      lambda3 - initial value of the third barycentric coordinate
      Since:
      2.0.0
  • Method Details

    • lambda1

      public float lambda1()
      Gets the first barycentric coordinate.
      Returns:
      the first barycentric coordinate.
      Since:
      2.0.0
    • setLambda1

      public void setLambda1(float v)
      Sets the value of the first barycentric coordinate.
      Parameters:
      v - new value of the first barycentric coordinate
      Since:
      2.0.0
    • lambda2

      public float lambda2()
      Gets the second barycentric coordinate.
      Returns:
      the second barycentric coordinate.
      Since:
      2.0.0
    • setLambda2

      public void setLambda2(float v)
      Sets the value of the second barycentric coordinate.
      Parameters:
      v - new value of the second barycentric coordinate
      Since:
      2.0.0
    • lambda3

      public float lambda3()
      Gets the third barycentric coordinate.
      Returns:
      the third barycentric coordinate.
      Since:
      2.0.0
    • setLambda3

      public void setLambda3(float v)
      Sets the value of the third barycentric coordinate.
      Parameters:
      v - new value of the third barycentric coordinate
      Since:
      2.0.0
    • inside

      public boolean inside()
      Gets the boolean value of the statement "are these barycentrics inside of a triangle?".

      Equals to the boolean value of the statement "are all the barycentric coordinates not negative?".

      Uses Floats.moreThan(float, float) internally.

      Returns:
      true if these barycentric coordinates are inside of the triangle; false otherwise
      Since:
      2.0.0
      See Also:
    • normalized

      public boolean normalized()
      Gets the boolean value of the statement "are these barycentrics normalized?".

      Equals to true is the sum of all coordinates is 1.

      Uses Floats.equals(float, float) internally.

      Returns:
      true if the sum of these barycentric coordinates is equal to 1; false otherwise
      Since:
      2.0.0
      See Also: