Class UDim3
java.lang.Object
com.thecsdev.common.math.UDim3
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.
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal UDim3clone()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 booleanstatic final UDim3fromOffset(double xOffset, double yOffset, double zOffset) static final UDim3fromScale(double xScale, double yScale, double zScale) final inthashCode()final StringtoString()
-
Field Details
-
ZERO
-
x
The horizontal component of the scalable value.Defines how the value changes relative to a reference width, combining a proportional
scaleand a fixedoffset. -
y
The vertical component of the scalable value.Defines how the value changes relative to a reference height, combining a proportional
scaleand a fixedoffset. -
z
The depth or forward component of the scalable value.Defines how the value changes relative to a reference depth, combining a proportional
scaleand a fixedoffset.
-
-
Constructor Details
-
UDim3
public UDim3() -
UDim3
public UDim3(double xScale, double xOffset, double yScale, double yOffset, double zScale, double zOffset) -
UDim3
- Throws:
NullPointerException
-
-
Method Details
-
fromScale
-
fromOffset
-
hashCode
-
equals
-
clone
-
toString
-
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:
The results are rounded down to the nearest integers.finalValue = (referenceValue * scale) + offset;- 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, andz.
-
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:
The results retain floating-point precision.finalValue = (referenceValue * scale) + offset;- 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, andz.
-
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:
The results retain double precision.finalValue = (referenceValue * scale) + offset;- 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, andz.
-