Vector3
public final class Vector3
Represents a three-dimensional position in space.
The coordinate system is right-handed. The x-axis points to the right, the y-axis up and the z-axis back.
Summary
Public fields |
|
|---|---|
static final @NonNull Vector3 |
Vector with z set to one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with y set to negative one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with z set to negative one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with x set to negative one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with all components set to one. |
static final @NonNull Vector3 |
Vector with x set to one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with y set to one and all other components set to zero. |
static final @NonNull Vector3 |
Vector with all components set to zero. |
Public constructors |
|---|
|
Creates a new vector with the same values as the |
Vector3(float x, float y, float z) |
Public methods |
|
|---|---|
static final @NonNull Vector3 |
Returns the absolute values of each component of the vector. |
static final float |
angleBetween(@NonNull Vector3 vector1, @NonNull Vector3 vector2)Returns the angle between this vector and the other vector in degrees. |
final @NonNull Vector3 |
Returns a new vector with its values clamped between |
final @NonNull Vector3 |
copy(float x, float y, float z)Returns a copy of the vector. |
final @NonNull Vector3 |
Returns the cross product of this vector and the |
static final float |
Returns the distance between this vector and the other vector. |
final @NonNull Vector3 |
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 |
static final @NonNull Vector3 |
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 |
getX()the value of the horizontal component. |
final float |
getY()the value of the vertical component. |
final float |
getZ()the value of the forward component. |
int |
hashCode() |
final @NonNull Vector3 |
inverse()Returns the component-wise multiplicative inverse of this vector. |
static final @NonNull Vector3 |
Returns a new vector that is linearly interpolated between |
static final @NonNull Vector3 |
Returns the maximum of each component of the two vectors. |
static final @NonNull Vector3 |
Returns the minimum of each component of the two vectors. |
final @NonNull Vector3 |
Returns a new vector with the difference of this vector and the |
final @NonNull Vector3 |
Returns a new vector with the sum of this vector and the |
static final @NonNull Vector3 |
projectOnPlane(@NonNull Vector3 vector, @NonNull Vector3 planeNormal)Computes the vector projected from |
final @NonNull Vector3 |
Returns a new vector with each component of this vector multiplied by each corresponding component of the |
final @NonNull Vector3 |
times(float c)Get a new vector multiplied by a scalar amount. |
final @NonNull Vector3 |
Returns the normalized version of this vector. |
@NonNull String |
toString() |
final @NonNull Vector3 |
Negates this vector. |
Public fields
Backward
public static final @NonNull Vector3 Backward
Vector with z set to one and all other components set to zero.
Down
public static final @NonNull Vector3 Down
Vector with y set to negative one and all other components set to zero.
Forward
public static final @NonNull Vector3 Forward
Vector with z set to negative one and all other components set to zero.
Left
public static final @NonNull Vector3 Left
Vector with x set to negative one and all other components set to zero.
Right
public static final @NonNull Vector3 Right
Vector with x set to one and all other components set to zero.
Public constructors
Vector3
public Vector3(@NonNull Vector3 other)
Creates a new vector with the same values as the other vector.
Public methods
abs
public static final @NonNull Vector3 abs(@NonNull Vector3 vector)
Returns the absolute values of each component of the vector.
angleBetween
public static final float angleBetween(@NonNull Vector3 vector1, @NonNull Vector3 vector2)
Returns the angle between this vector and the other vector in degrees. The result is never greater than 180 degrees.
clamp
public final @NonNull Vector3 clamp(@NonNull Vector3 min, @NonNull Vector3 max)
Returns a new vector with its values clamped between min and max vectors.
copy
public final @NonNull Vector3 copy(float x, float y, float z)
Returns a copy of the vector.
cross
public final @NonNull Vector3 cross(@NonNull Vector3 other)
Returns the cross product of this vector and the other vector.
distance
public static final float distance(@NonNull Vector3 vector1, @NonNull Vector3 vector2)
Returns the distance between this vector and the other vector.
div
public final @NonNull Vector3 div(float c)
Returns a new vector with this vector divided by a scalar amount.
dot
public final float dot(@NonNull Vector3 other)
Returns the dot product of this vector and the other vector.
fromValue
public static final @NonNull Vector3 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 Vector3 inverse()
Returns the component-wise multiplicative inverse of this vector.
lerp
public static final @NonNull Vector3 lerp(@NonNull Vector3 start, @NonNull Vector3 end, float ratio)
Returns a new vector that is linearly interpolated between start and end using the interpolated amount ratio.
If ratio is outside of the range [0, 1], the returned vector will be extrapolated.
max
public static final @NonNull Vector3 max(@NonNull Vector3 a, @NonNull Vector3 b)
Returns the maximum of each component of the two vectors.
min
public static final @NonNull Vector3 min(@NonNull Vector3 a, @NonNull Vector3 b)
Returns the minimum of each component of the two vectors.
minus
public final @NonNull Vector3 minus(@NonNull Vector3 other)
Returns a new vector with the difference of this vector and the other vector.
plus
public final @NonNull Vector3 plus(@NonNull Vector3 other)
Returns a new vector with the sum of this vector and the other vector.
projectOnPlane
public static final @NonNull Vector3 projectOnPlane(@NonNull Vector3 vector, @NonNull Vector3 planeNormal)
Computes the vector projected from vector onto planeNormal.
scale
public final @NonNull Vector3 scale(@NonNull Vector3 other)
Returns a new vector with each component of this vector multiplied by each corresponding component of the other vector.
times
public final @NonNull Vector3 times(float c)
Get a new vector multiplied by a scalar amount.
toNormalized
public final @NonNull Vector3 toNormalized()
Returns the normalized version of this vector.