Record Class QuadraticBezier

java.lang.Object
java.lang.Record
top.girlkisser.lazuli.api.mathematics.QuadraticBezier
Record Components:
start - The starting position.
control - The control point.
end - The ending position.

public record QuadraticBezier(org.joml.Vector2f start, org.joml.Vector2f control, org.joml.Vector2f end) extends Record
A quadratic Bézier curve implementation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<QuadraticBezier>
    A codec for a quadratic Bézier curve with the following format:
    { "start": { "x": 0.0, "y": 0.0 }, "control": { "x": 0.25, "y": 0.5 }, "end": { "x": 1.0, "y": 1.0 } }
    static final com.mojang.serialization.Codec<QuadraticBezier>
    A codec for a quadratic Bézier curve with the following format:
    [ { "x": 0.0, "y": 0.0 }, { "x": 0.5, "y": 0.5 }, { "x": 1.0, "y": 1.0 } ]
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,QuadraticBezier>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,QuadraticBezier>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    QuadraticBezier(float controlX, float controlY)
    Create a quadratic Bézier curve using the provided coordinates for the control point.
    QuadraticBezier(float startX, float startY, float controlX, float controlY, float endX, float endY)
    Create a quadratic Bézier curve using the provided coordinates for points.
    QuadraticBezier(org.joml.Vector2f control)
    Create a quadratic Bézier curve using the provided control point.
    QuadraticBezier(org.joml.Vector2f start, org.joml.Vector2f control, org.joml.Vector2f end)
    Creates an instance of a QuadraticBezier record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.joml.Vector2f
    Returns the value of the control record component.
    org.joml.Vector2f
    end()
    Returns the value of the end record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    List<org.joml.Vector2f>
    getPoints(float resolution)
    Get a list of points from 0 to 1 with `resolution` steps.
    final int
    Returns a hash code value for this object.
    org.joml.Vector2f
    sample(float t)
    Get the point for the given `t` value.
    org.joml.Vector2f
    Returns the value of the start record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<QuadraticBezier> CODEC
      A codec for a quadratic Bézier curve with the following format:
      { "start": { "x": 0.0, "y": 0.0 }, "control": { "x": 0.25, "y": 0.5 }, "end": { "x": 1.0, "y": 1.0 } }
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,QuadraticBezier> STREAM_CODEC
    • LIST_CODEC

      public static final com.mojang.serialization.Codec<QuadraticBezier> LIST_CODEC
      A codec for a quadratic Bézier curve with the following format:
      [ { "x": 0.0, "y": 0.0 }, { "x": 0.5, "y": 0.5 }, { "x": 1.0, "y": 1.0 } ]
    • LIST_STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,QuadraticBezier> LIST_STREAM_CODEC
  • Constructor Details

    • QuadraticBezier

      public QuadraticBezier(org.joml.Vector2f control)
      Create a quadratic Bézier curve using the provided control point. The start and end points are 0,0 and 1,1 respectively.
      Parameters:
      control - The control point.
    • QuadraticBezier

      public QuadraticBezier(float controlX, float controlY)
      Create a quadratic Bézier curve using the provided coordinates for the control point.
      Parameters:
      controlX - The control point's X coordinate.
      controlY - The control point's Y coordinate.
    • QuadraticBezier

      public QuadraticBezier(float startX, float startY, float controlX, float controlY, float endX, float endY)
      Create a quadratic Bézier curve using the provided coordinates for points.
      Parameters:
      startX - The start point's X coordinate.
      startY - The start point's Y coordinate.
      controlX - The control point's X coordinate.
      controlY - The control point's Y coordinate.
      endX - The end point's X coordinate.
      endY - The end point's Y coordinate.
    • QuadraticBezier

      public QuadraticBezier(org.joml.Vector2f start, org.joml.Vector2f control, org.joml.Vector2f end)
      Creates an instance of a QuadraticBezier record class.
      Parameters:
      start - the value for the start record component
      control - the value for the control record component
      end - the value for the end record component
  • Method Details

    • sample

      public org.joml.Vector2f sample(float t)
      Get the point for the given `t` value.
      Parameters:
      t - The "progress" of the curve, from 0 to 1.
      Returns:
      The point at the given `t` value.
    • getPoints

      public List<org.joml.Vector2f> getPoints(float resolution)
      Get a list of points from 0 to 1 with `resolution` steps.
      Parameters:
      resolution - The amount of steps, or "resolution" of the points.
      Returns:
      The list of points.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • start

      public org.joml.Vector2f start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • control

      public org.joml.Vector2f control()
      Returns the value of the control record component.
      Returns:
      the value of the control record component
    • end

      public org.joml.Vector2f end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component