java.lang.Object
com.github.stephengold.joltjni.Float4
- All Implemented Interfaces:
ConstFloat4
A vector composed of 4 single-precision components, used as a storage class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFloat4()Instantiate an all-zero vector (0,0,0,0).Float4(float x, float y, float z, float w) Instantiate a vector with specified components.Float4(ConstFloat4 rhs) Instantiate a copy of the specified vector.Float4(FloatBuffer buffer) Instantiate from the specified buffer.Float4(FloatBuffer buffer, int startPos) Instantiate from the specified position in the specified buffer. -
Method Summary
Modifier and TypeMethodDescriptionfloatget(int index) Return the specified component.voidput(FloatBuffer storeBuffer) Write all 4 components to the specified buffer and advance the buffer's position by 4.voidset(float[] array) Set all 4 components from the specified array.voidset(float x, float y, float z, float w) Set all 4 components to specified values.voidset(FloatBuffer buffer) Set all 4 components from the specified buffer.toString()Return a string representation of the vector, which is unaffected.floatw()Return the 4th (W) component.floatx()Return the first (X) component.floaty()Return the 2nd (Y) component.floatz()Return the 3rd (Z) component.
-
Field Details
-
w
public float wthe 4th (W) component -
x
public float xthe first (X) component -
y
public float ythe 2nd (Y) component -
z
public float zthe 3rd (Z) component
-
-
Constructor Details
-
Float4
public Float4()Instantiate an all-zero vector (0,0,0,0). -
Float4
public Float4(float x, float y, float z, float w) Instantiate a vector with specified components.- Parameters:
x- the desired X componenty- the desired Y componentz- the desired Z componentw- the desired W component
-
Float4
Instantiate a copy of the specified vector.- Parameters:
rhs- the vector to copy (notnull, unaffected)
-
Float4
Instantiate from the specified buffer.- Parameters:
buffer- the desired component values (notnull, unaffected, capacity≥4)
-
Float4
Instantiate from the specified position in the specified buffer.- Parameters:
buffer- the desired component values (notnull, unaffected)startPos- the starting position in the buffer (≥0)
-
-
Method Details
-
set
public void set(float x, float y, float z, float w) Set all 4 components to specified values.- Parameters:
x- the desired X componenty- the desired Y componentz- the desired Z componentw- the desired W component
-
set
public void set(float[] array) Set all 4 components from the specified array.- Parameters:
array- the desired component values (notnull, length≥4, unaffected)
-
set
Set all 4 components from the specified buffer.- Parameters:
buffer- the desired component values (notnull, length≥4, unaffected)
-
get
public float get(int index) Return the specified component. The vector is unaffected.- Specified by:
getin interfaceConstFloat4- Parameters:
index- 0, 1, 2, or 3- Returns:
- the X component if index=0, the Y component if index=1, the Z component if index=2, or the W component if index=3
- Throws:
IllegalArgumentException- if index is not 0, 1, 2, or 3
-
put
Write all 4 components to the specified buffer and advance the buffer's position by 4. The vector is unaffected.- Specified by:
putin interfaceConstFloat4- Parameters:
storeBuffer- the destination buffer (notnull)
-
w
public float w()Return the 4th (W) component. The vector is unaffected.- Specified by:
win interfaceConstFloat4- Returns:
- the component value
-
x
public float x()Return the first (X) component. The vector is unaffected.- Specified by:
xin interfaceConstFloat4- Returns:
- the component value
-
y
public float y()Return the 2nd (Y) component. The vector is unaffected.- Specified by:
yin interfaceConstFloat4- Returns:
- the component value
-
z
public float z()Return the 3rd (Z) component. The vector is unaffected.- Specified by:
zin interfaceConstFloat4- Returns:
- the component value
-
toString
Return a string representation of the vector, which is unaffected. For example, a zero vector is represented by:Float4(0.0 0.0 0.0 0.0)
-