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 vector1 and vector2 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 vector1 and vector2.

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

the w component of the vector

final float

the x component of the vector

final float

the y component of the vector

final float

the z component of the vector

int
final @NonNull Vector4

Returns the component-wise multiplicative inverse of this vector.

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

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

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
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-alpha10
public Vector4(@NonNull Vector4 other)

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

Vector4

Added in 1.0.0-alpha10
public Vector4(float x, float y, float z, float w)

Public methods

abs

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

Returns the absolute values of each component of the vector.

Parameters
@NonNull Vector4 vector

the vector to get the absolute values of

angleBetween

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

Returns the angle between vector1 and vector2 in degrees. The result is never greater than 180 degrees.

Parameters
@NonNull Vector4 vector1

the first vector

@NonNull Vector4 vector2

the second vector

clamp

Added in 1.0.0-alpha10
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.

Parameters
@NonNull Vector4 min

the minimum clamp values

@NonNull Vector4 max

the maximum clamp values

copy

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

Returns a copy of the vector.

Parameters
float x

the new x value for the copied vector

float y

the new y value for the copied vector

float z

the new z value for the copied vector

float w

the new w value for the copied vector

distance

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

Returns the distance between vector1 and vector2.

Parameters
@NonNull Vector4 vector1

the first vector

@NonNull Vector4 vector2

the second vector

div

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

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

Parameters
float c

the scalar to divide by

dot

Added in 1.0.0-alpha10
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-alpha10
public static final @NonNull Vector4 fromValue(float value)

Creates a new vector with all components set to value.

getLength

Added in 1.0.0-alpha10
public final float getLength()

The length of the vector.

getLengthSquared

Added in 1.0.0-alpha10
public final float getLengthSquared()

The squared length of the vector.

getW

Added in 1.0.0-alpha10
public final float getW()

the w component of the vector

getX

Added in 1.0.0-alpha10
public final float getX()

the x component of the vector

getY

Added in 1.0.0-alpha10
public final float getY()

the y component of the vector

getZ

Added in 1.0.0-alpha10
public final float getZ()

the z component of the vector

hashCode

public int hashCode()

inverse

Added in 1.0.0-alpha10
public final @NonNull Vector4 inverse()

Returns the component-wise multiplicative inverse of this vector.

lerp

Added in 1.0.0-alpha10
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.

Parameters
@NonNull Vector4 start

the starting vector

@NonNull Vector4 end

the ending vector

float ratio

the interpolation ratio

max

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

Returns the maximum of each component of the two vectors.

Parameters
@NonNull Vector4 a

the first vector

@NonNull Vector4 b

the second vector

min

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

Returns the minimum of each component of the two vectors.

Parameters
@NonNull Vector4 a

the first vector

@NonNull Vector4 b

the second vector

minus

Added in 1.0.0-alpha10
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-alpha10
public final @NonNull Vector4 plus(@NonNull Vector4 other)

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

scale

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

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

Get a new vector multiplied by a scalar amount.

Parameters
float c

the scalar to multiply by

toNormalized

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

Returns the normalized version of this vector.

toString

public @NonNull String toString()

unaryMinus

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

Negates this vector.