java.lang.Object
com.github.stephengold.joltjni.Float3
A vector composed of 3 single-precision components, used as a storage class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloat
get
(int index) Return the specified component.void
put
(FloatBuffer storeBuffer) Write all 3 components to the specified buffer and advance the buffer's position by 3.void
set
(float[] array) Set all 3 components from the specified array.void
set
(float x, float y, float z) Set all 3 components to specified values.toString()
Return a string representation of the vector, which is unaffected.
-
Field Details
-
x
public float xthe first (X) component -
y
public float ythe 2nd (Y) component -
z
public float zthe 3rd (Z) component
-
-
Constructor Details
-
Float3
public Float3()Instantiate an all-zero vector (0,0,0). -
Float3
public Float3(float x, float y, float z) Instantiate a vector with specified components.- Parameters:
x
- the desired X componenty
- the desired Y componentz
- the desired Z component
-
Float3
Instantiate a copy of the specified vector.- Parameters:
rhs
- the vector to copy (not null, unaffected)
-
Float3
Instantiate from a buffer.- Parameters:
buffer
- the desired component values (not null, unaffected, capacity≥3)
-
-
Method Details
-
get
public float get(int index) Return the specified component. The vector is unaffected.- Parameters:
index
- 0, 1, or 2- Returns:
- the X component if index=0, the Y component if index=1, or the Z component if index=2
- Throws:
IllegalArgumentException
- if index is not 0, 1, or 2
-
put
Write all 3 components to the specified buffer and advance the buffer's position by 3. The vector is unaffected.- Parameters:
storeBuffer
- the destination buffer (not null)
-
set
public void set(float x, float y, float z) Set all 3 components to specified values.- Parameters:
x
- the desired X componenty
- the desired Y componentz
- the desired Z component
-
set
public void set(float[] array) Set all 3 components from the specified array.- Parameters:
array
- the desired component values (not null, length≥3, unaffected)
-
toString
Return a string representation of the vector, which is unaffected. For example, a zero vector is represented by:Float3(0.0 0.0 0.0)
-