Class UDim3

java.lang.Object
com.thecsdev.common.math.UDim3

public final class UDim3 extends Object
Represents a three-dimensional scalable value with independent scaling for each axis.

This structure extends UDim to three dimensions, allowing values to be defined using:

  • x - The horizontal component.
  • y - The vertical component.
  • z - The depth or forward component.
Each axis is defined using a UDim, meaning it consists of both a relative scale and an absolute offset. This is useful for 3D UI layouts, positioning, or procedural generation where values need to be both scalable and adjustable.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final UDim
    The horizontal component of the scalable value.
    final UDim
    The vertical component of the scalable value.
    final UDim
    The depth or forward component of the scalable value.
    static final UDim3
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    UDim3(double xScale, double xOffset, double yScale, double yOffset, double zScale, double zOffset)
     
    UDim3(UDim x, UDim y, UDim z)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final UDim3
     
    final double[]
    computeD(double referenceValueX, double referenceValueY, double referenceValueZ)
    Computes the final values for all three components using double reference values.
    final float[]
    computeF(float referenceValueX, float referenceValueY, float referenceValueZ)
    Computes the final values for all three components using floating-point reference values.
    final int[]
    computeI(int referenceValueX, int referenceValueY, int referenceValueZ)
    Computes the final values for all three components using integer reference values.
    final boolean
     
    static final UDim3
    fromOffset(double xOffset, double yOffset, double zOffset)
     
    static final UDim3
    fromScale(double xScale, double yScale, double zScale)
     
    final int
     
    final String
     

    Methods inherited from class Object

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

    • ZERO

      public static final UDim3 ZERO
    • x

      public final UDim x
      The horizontal component of the scalable value.

      Defines how the value changes relative to a reference width, combining a proportional scale and a fixed offset.

    • y

      public final UDim y
      The vertical component of the scalable value.

      Defines how the value changes relative to a reference height, combining a proportional scale and a fixed offset.

    • z

      public final UDim z
      The depth or forward component of the scalable value.

      Defines how the value changes relative to a reference depth, combining a proportional scale and a fixed offset.

  • Constructor Details

  • Method Details

    • fromScale

      public static final UDim3 fromScale(double xScale, double yScale, double zScale)
    • fromOffset

      public static final UDim3 fromOffset(double xOffset, double yOffset, double zOffset)
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • clone

      public final UDim3 clone()
      Overrides:
      clone in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • computeI

      public final int[] computeI(int referenceValueX, int referenceValueY, int referenceValueZ)
      Computes the final values for all three components using integer reference values.

      Each axis is calculated independently using the formula:

      finalValue = (referenceValue * scale) + offset;
      The results are rounded down to the nearest integers.
      Parameters:
      referenceValueX - The reference value for the horizontal component.
      referenceValueY - The reference value for the vertical component.
      referenceValueZ - The reference value for the depth component.
      Returns:
      An array containing the computed integer values for x, y, and z.
    • computeF

      public final float[] computeF(float referenceValueX, float referenceValueY, float referenceValueZ)
      Computes the final values for all three components using floating-point reference values.

      Each axis is calculated independently using the formula:

      finalValue = (referenceValue * scale) + offset;
      The results retain floating-point precision.
      Parameters:
      referenceValueX - The reference value for the horizontal component.
      referenceValueY - The reference value for the vertical component.
      referenceValueZ - The reference value for the depth component.
      Returns:
      An array containing the computed float values for x, y, and z.
    • computeD

      public final double[] computeD(double referenceValueX, double referenceValueY, double referenceValueZ)
      Computes the final values for all three components using double reference values.

      Each axis is calculated independently using the formula:

      finalValue = (referenceValue * scale) + offset;
      The results retain double precision.
      Parameters:
      referenceValueX - The reference value for the horizontal component.
      referenceValueY - The reference value for the vertical component.
      referenceValueZ - The reference value for the depth component.
      Returns:
      An array containing the computed double values for x, y, and z.