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

Vector3(float x, float y, float z)

Public methods

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

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

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

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

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

Returns a new vector with this vector divided by 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 other.

static final @NonNull Vector3
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 value of the horizontal component.

final float

the value of the vertical component.

final float

the value of the forward component.

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

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

final @NonNull Vector3

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

static final @NonNull Vector3
projectOnPlane(@NonNull Vector3 vector, @NonNull Vector3 planeNormal)

Computes the vector projected from vector onto planeNormal.

final @NonNull Vector3
times(float c)

Get a new vector multiplied by a scalar amount.

final @NonNull Vector3

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

final @NonNull Vector3

Returns the normalized version of this vector.

@NonNull String
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.

One

public static final @NonNull Vector3 One

Vector with all components set to one.

Right

public static final @NonNull Vector3 Right

Vector with x set to one and all other components set to zero.

Up

public static final @NonNull Vector3 Up

Vector with y set to one and all other components set to zero.

Zero

public static final @NonNull Vector3 Zero

Vector with all components set to zero.

Public constructors

Vector3

Added in 1.0.0-alpha01
public Vector3(@NonNull Vector3 other)

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

Vector3

Added in 1.0.0-alpha01
public Vector3(float x, float y, float z)

Public methods

abs

Added in 1.0.0-alpha01
public static final @NonNull Vector3 abs(@NonNull Vector3 vector)

Returns the absolute values of each component of the vector.

angleBetween

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

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

Added in 1.0.0-alpha01
public final @NonNull Vector3 copy(float x, float y, float z)

Returns a copy of the vector.

cross

Added in 1.0.0-alpha01
public final @NonNull Vector3 cross(@NonNull Vector3 other)

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

distance

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

Returns the distance between this vector and the other vector.

div

Added in 1.0.0-alpha01
public final @NonNull Vector3 div(float c)

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

div

Added in 1.0.0-alpha01
public final @NonNull Vector3 div(@NonNull Vector3 other)

Returns a new vector with this vector divided by the other vector.

dot

Added in 1.0.0-alpha01
public final float dot(@NonNull Vector3 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 other.

fromValue

Added in 1.0.0-alpha01
public static final @NonNull Vector3 fromValue(float value)

Creates a new vector with all components set to value.

getLength

Added in 1.0.0-alpha01
public final float getLength()

The length of the vector.

getLengthSquared

Added in 1.0.0-alpha01
public final float getLengthSquared()

The squared length of the vector.

getX

Added in 1.0.0-alpha01
public final float getX()

the value of the horizontal component.

getY

Added in 1.0.0-alpha01
public final float getY()

the value of the vertical component.

getZ

Added in 1.0.0-alpha01
public final float getZ()

the value of the forward component.

hashCode

public int hashCode()

lerp

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

Added in 1.0.0-alpha01
public static final @NonNull Vector3 max(@NonNull Vector3 a, @NonNull Vector3 b)

Returns the maximum of each component of the two vectors.

min

Added in 1.0.0-alpha01
public static final @NonNull Vector3 min(@NonNull Vector3 a, @NonNull Vector3 b)

Returns the minimum of each component of the two vectors.

minus

Added in 1.0.0-alpha01
public final @NonNull Vector3 minus(@NonNull Vector3 other)

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

plus

Added in 1.0.0-alpha01
public final @NonNull Vector3 plus(@NonNull Vector3 other)

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

projectOnPlane

Added in 1.0.0-alpha01
public static final @NonNull Vector3 projectOnPlane(@NonNull Vector3 vector, @NonNull Vector3 planeNormal)

Computes the vector projected from vector onto planeNormal.

times

Added in 1.0.0-alpha01
public final @NonNull Vector3 times(float c)

Get a new vector multiplied by a scalar amount.

times

Added in 1.0.0-alpha01
public final @NonNull Vector3 times(@NonNull Vector3 other)

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

toNormalized

Added in 1.0.0-alpha01
public final @NonNull Vector3 toNormalized()

Returns the normalized version of this vector.

toString

public @NonNull String toString()

unaryMinus

Added in 1.0.0-alpha01
public final @NonNull Vector3 unaryMinus()

Negates this vector.