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 other vector.

Vector4(float x, float y, float z, float w)

Public methods

static final @NonNull Vector4
abs(@NonNull Vector4 vector)

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 min and max vectors.

final @NonNull Vector4
copy(float x, float y, float z, float w)

Returns a copy of the vector.

static final float
distance(@NonNull Vector4 vector1, @NonNull Vector4 vector2)

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 @NonNull Vector4

Returns a new vector with each component of this vector divided by each corresponding component of the other vector.

final float

Returns the dot product of this vector and the other vector.

boolean
equals(Object other)

Returns true if this vector is equal to the other.

static final @NonNull Vector4
fromValue(float value)

Creates a new vector with all components set to value.

final float

The length of the vector.

final float

The squared length of the vector.

final float

W component of the vector.

final float

X component of the vector.

final float

Y component of the vector.

final float

Z component of the vector.

int
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.

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 other vector.

final @NonNull Vector4

Returns a new vector with the sum of this vector and the other vector.

final @NonNull Vector4
times(float c)

Get a new vector multiplied by a scalar amount.

final @NonNull Vector4

Returns a new vector with the product of this vector and the other vector.

final @NonNull Vector4

Returns the normalized version of this vector.

@NonNull String
final @NonNull Vector4

Negates this vector.

Public fields

One

public static final @NonNull Vector4 One

Vector with all components set to one.

Zero

public static final @NonNull Vector4 Zero

Vector with all components set to zero.

Public constructors

Vector4

Added in 1.0.0-alpha04
public Vector4(@NonNull Vector4 other)

Creates a new vector with the same values as the other vector.

Vector4

Added in 1.0.0-alpha04
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

Added in 1.0.0-alpha04
public static final @NonNull Vector4 abs(@NonNull Vector4 vector)

Returns the absolute values of each component of the vector.

angleBetween

Added in 1.0.0-alpha04
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

Added in 1.0.0-alpha04
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

Added in 1.0.0-alpha04
public final @NonNull Vector4 copy(float x, float y, float z, float w)

Returns a copy of the vector.

distance

Added in 1.0.0-alpha04
public static final float distance(@NonNull Vector4 vector1, @NonNull Vector4 vector2)

Returns the distance between this vector and the other vector.

div

Added in 1.0.0-alpha04
public final @NonNull Vector4 div(float c)

Returns a new vector with this vector divided by a scalar amount.

div

Added in 1.0.0-alpha04
public final @NonNull Vector4 div(@NonNull Vector4 other)

Returns a new vector with each component of this vector divided by each corresponding component of the other vector.

dot

Added in 1.0.0-alpha04
public final float dot(@NonNull Vector4 other)

Returns the dot product of this vector and the other vector.

equals

public boolean equals(Object other)

Returns true if this vector is equal to the other.

fromValue

Added in 1.0.0-alpha04
public static final @NonNull Vector4 fromValue(float value)

Creates a new vector with all components set to value.

getLength

Added in 1.0.0-alpha04
public final float getLength()

The length of the vector.

getLengthSquared

Added in 1.0.0-alpha04
public final float getLengthSquared()

The squared length of the vector.

getW

Added in 1.0.0-alpha04
public final float getW()

W component of the vector.

getX

Added in 1.0.0-alpha04
public final float getX()

X component of the vector.

getY

Added in 1.0.0-alpha04
public final float getY()

Y component of the vector.

getZ

Added in 1.0.0-alpha04
public final float getZ()

Z component of the vector.

hashCode

public int hashCode()

lerp

Added in 1.0.0-alpha04
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

Added in 1.0.0-alpha04
public static final @NonNull Vector4 max(@NonNull Vector4 a, @NonNull Vector4 b)

Returns the maximum of each component of the two vectors.

min

Added in 1.0.0-alpha04
public static final @NonNull Vector4 min(@NonNull Vector4 a, @NonNull Vector4 b)

Returns the minimum of each component of the two vectors.

minus

Added in 1.0.0-alpha04
public final @NonNull Vector4 minus(@NonNull Vector4 other)

Returns a new vector with the difference of this vector and the other vector.

plus

Added in 1.0.0-alpha04
public final @NonNull Vector4 plus(@NonNull Vector4 other)

Returns a new vector with the sum of this vector and the other vector.

times

Added in 1.0.0-alpha04
public final @NonNull Vector4 times(float c)

Get a new vector multiplied by a scalar amount.

times

Added in 1.0.0-alpha04
public final @NonNull Vector4 times(@NonNull Vector4 other)

Returns a new vector with the product of this vector and the other vector.

toNormalized

Added in 1.0.0-alpha04
public final @NonNull Vector4 toNormalized()

Returns the normalized version of this vector.

toString

public @NonNull String toString()

unaryMinus

Added in 1.0.0-alpha04
public final @NonNull Vector4 unaryMinus()

Negates this vector.