Vector4
public final class Vector4
Represents a four-dimensional position in space.
Summary
Public fields |
|
|---|---|
static final @NonNull Vector4 |
Vector with all components set to one. |
static final @NonNull Vector4 |
Vector with all components set to zero. |
Public constructors |
|---|
|
Creates a new vector with the same values as the |
Vector4(float x, float y, float z, float w) |
Public methods |
|
|---|---|
static final @NonNull Vector4 |
Returns the absolute values of each component of the vector. |
static final float |
angleBetween(@NonNull Vector4 vector1, @NonNull Vector4 vector2)Returns the angle between this vector and other vector in degrees. |
final @NonNull Vector4 |
Returns a new vector with the each component of this vector clamped between corresponding components of |
final @NonNull Vector4 |
copy(float x, float y, float z, float w)Returns a copy of the vector. |
static final float |
Returns the distance between this vector and the other vector. |
final @NonNull Vector4 |
div(float c)Returns a new vector with this vector divided by a scalar amount. |
final float |
Returns the dot product of this vector and the |
boolean |
Returns true if this vector is equal to the |
static final @NonNull Vector4 |
fromValue(float value)Creates a new vector with all components set to |
final float |
The length of the vector. |
final float |
The squared length of the vector. |
final float |
getW()W component of the vector. |
final float |
getX()X component of the vector. |
final float |
getY()Y component of the vector. |
final float |
getZ()Z component of the vector. |
int |
hashCode() |
final @NonNull Vector4 |
inverse()Returns the component-wise multiplicative inverse of this vector. |
static final @NonNull Vector4 |
Returns a new vector that is linearly interpolated between |
static final @NonNull Vector4 |
Returns the maximum of each component of the two vectors. |
static final @NonNull Vector4 |
Returns the minimum of each component of the two vectors. |
final @NonNull Vector4 |
Returns a new vector with the difference of this vector and the |
final @NonNull Vector4 |
Returns a new vector with the sum of this vector and the |
final @NonNull Vector4 |
Returns a new vector with each component of this vector multiplied by each corresponding component of the |
final @NonNull Vector4 |
times(float c)Get a new vector multiplied by a scalar amount. |
final @NonNull Vector4 |
Returns the normalized version of this vector. |
@NonNull String |
toString() |
final @NonNull Vector4 |
Negates this vector. |
Public fields
Public constructors
Vector4
public Vector4(@NonNull Vector4 other)
Creates a new vector with the same values as the other vector.
Vector4
public Vector4(float x, float y, float z, float w)
| Parameters | |
|---|---|
float x |
X component of the vector. |
float y |
Y component of the vector. |
float z |
Z component of the vector. |
float w |
W component of the vector. |
Public methods
abs
public static final @NonNull Vector4 abs(@NonNull Vector4 vector)
Returns the absolute values of each component of the vector.
angleBetween
public static final float angleBetween(@NonNull Vector4 vector1, @NonNull Vector4 vector2)
Returns the angle between this vector and other vector in degrees. The result is never greater than 180 degrees.
clamp
public final @NonNull Vector4 clamp(@NonNull Vector4 min, @NonNull Vector4 max)
Returns a new vector with the each component of this vector clamped between corresponding components of min and max vectors.
copy
public final @NonNull Vector4 copy(float x, float y, float z, float w)
Returns a copy of the vector.
distance
public static final float distance(@NonNull Vector4 vector1, @NonNull Vector4 vector2)
Returns the distance between this vector and the other vector.
div
public final @NonNull Vector4 div(float c)
Returns a new vector with this vector divided by a scalar amount.
dot
public final float dot(@NonNull Vector4 other)
Returns the dot product of this vector and the other vector.
fromValue
public static final @NonNull Vector4 fromValue(float value)
Creates a new vector with all components set to value.
getLengthSquared
public final float getLengthSquared()
The squared length of the vector.
inverse
public final @NonNull Vector4 inverse()
Returns the component-wise multiplicative inverse of this vector.
lerp
public static final @NonNull Vector4 lerp(@NonNull Vector4 start, @NonNull Vector4 end, float ratio)
Returns a new vector that is linearly interpolated between start and end using the interpolation amount ratio.
If ratio is outside of the range [0, 1], the returned vector will be extrapolated.
max
public static final @NonNull Vector4 max(@NonNull Vector4 a, @NonNull Vector4 b)
Returns the maximum of each component of the two vectors.
min
public static final @NonNull Vector4 min(@NonNull Vector4 a, @NonNull Vector4 b)
Returns the minimum of each component of the two vectors.
minus
public final @NonNull Vector4 minus(@NonNull Vector4 other)
Returns a new vector with the difference of this vector and the other vector.
plus
public final @NonNull Vector4 plus(@NonNull Vector4 other)
Returns a new vector with the sum of this vector and the other vector.
scale
public final @NonNull Vector4 scale(@NonNull Vector4 other)
Returns a new vector with each component of this vector multiplied by each corresponding component of the other vector.
times
public final @NonNull Vector4 times(float c)
Get a new vector multiplied by a scalar amount.
toNormalized
public final @NonNull Vector4 toNormalized()
Returns the normalized version of this vector.