java.lang.Object
com.github.stephengold.joltjni.Float2
A vector composed of 2 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 both components to the specified buffer and advance the buffer's position by 2.void
set
(float[] array) Set both components from the specified array.void
set
(float x, float y) Set both 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
-
-
Constructor Details
-
Float2
public Float2()Instantiate an all-zero vector (0,0,0). -
Float2
public Float2(float x, float y) Instantiate a vector with specified components.- Parameters:
x
- the desired X componenty
- the desired Y component
-
Float2
Instantiate a copy of the specified vector.- Parameters:
rhs
- the vector to copy (not null, unaffected)
-
-
Method Details
-
get
public float get(int index) Return the specified component. The vector is unaffected.- Parameters:
index
- 0 or 1- Returns:
- the X component if index=0 or the Y component if index=1
- Throws:
IllegalArgumentException
- if index is not 0 or 1
-
put
Write both components to the specified buffer and advance the buffer's position by 2. The vector is unaffected.- Parameters:
storeBuffer
- the destination buffer (not null)
-
set
public void set(float x, float y) Set both components to specified values.- Parameters:
x
- the desired X componenty
- the desired Y component
-
set
public void set(float[] array) Set both components from the specified array.- Parameters:
array
- the desired component values (not null, length≥2, unaffected)
-
toString
Return a string representation of the vector, which is unaffected. For example, a zero vector is represented by:Float2(0.0 0.0)
-