java.lang.Object
com.github.stephengold.joltjni.Float3
- All Implemented Interfaces:
ConstFloat3
A vector composed of 3 single-precision components, used as a storage class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFloat3()Instantiate an all-zero vector (0,0,0).Float3(float x, float y, float z) Instantiate a vector with specified components.Float3(ConstFloat3 rhs) Instantiate a copy of the specified vector.Float3(FloatBuffer buffer) Instantiate from the specified buffer.Float3(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 3 components to the specified buffer and advance the buffer's position by 3.voidset(float[] array) Set all 3 components from the specified array.voidset(float x, float y, float z) Set all 3 components to specified values.voidset(FloatBuffer buffer) Set all 3 components from the specified buffer.toString()Return a string representation of the vector, which is unaffected.floatx()Return the first (X) component.floaty()Return the 2nd (Y) component.floatz()Return the 3rd (Z) component.
-
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 (notnull, unaffected)
-
Float3
Instantiate from the specified buffer.- Parameters:
buffer- the desired component values (notnull, unaffected, capacity≥3)
-
Float3
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) 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 (notnull, length≥3, unaffected)
-
set
Set all 3 components from the specified buffer.- Parameters:
buffer- the desired component values (notnull, length≥3, unaffected)
-
get
public float get(int index) Return the specified component. The vector is unaffected.- Specified by:
getin interfaceConstFloat3- 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.- Specified by:
putin interfaceConstFloat3- Parameters:
storeBuffer- the destination buffer (notnull)
-
x
public float x()Return the first (X) component. The vector is unaffected.- Specified by:
xin interfaceConstFloat3- Returns:
- the component value
-
y
public float y()Return the 2nd (Y) component. The vector is unaffected.- Specified by:
yin interfaceConstFloat3- Returns:
- the component value
-
z
public float z()Return the 3rd (Z) component. The vector is unaffected.- Specified by:
zin interfaceConstFloat3- Returns:
- the component value
-
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)
-