APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.math

public Class Vector3

extends Object
implements Serializable, Vector<Vector3>
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.math.Vector, java.io.Serializable
Imports
java.io.Serializable, com.badlogic.gdx.utils.GdxRuntimeException, .NumberUtils

Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods.
Author
[email protected]

Field Summary

Modifier and TypeField and Description
public static final Vector3
private static final long
private static final Matrix4
public float
x

the x-component of this vector

public static final Vector3
X

public float
y

the y-component of this vector

public static final Vector3
Y

public float
z

the z-component of this vector

public static final Vector3
Z

public static final Vector3

Constructor Summary

AccessConstructor and Description
public
Vector3()

Constructs a vector at (0,0,0)

public
Vector3(float
The x-component
x
,
float
The y-component
y
,
float
The z-component
z
)

Creates a vector with the given components

public
Vector3(final Vector3
The vector
vector
)

Creates a vector from the given vector

public
Vector3(final float[]
The array
values
)

Creates a vector from the given array.

public
Vector3(final Vector2
The vector
vector
,
float
The z-component
z
)

Creates a vector from the given vector and z-component

Method Summary

Modifier and TypeMethod and Description
public Vector3
add(final Vector3 vector)

Implements com.badlogic.gdx.math.Vector.add.

Adds the given vector to this vector

public Vector3

Returns:

This vector for chaining.
add
(float
The x-component of the other vector
x
,
float
The y-component of the other vector
y
,
float
The z-component of the other vector
z
)

Adds the given vector to this component

public Vector3

Returns:

This vector for chaining
add
(float
The value
values
)

Implements com.badlogic.gdx.math.Vector.add.

Adds the given value to all three components of the vector.

public Vector3
clamp(float min, float max)

Implements com.badlogic.gdx.math.Vector.clamp.

Clamps this vector's length to given min and max values

public Vector3
public Vector3

Returns:

This vector for chaining
crs
(final Vector3
The other vector
vector
)

Sets this vector to the cross product between it and the other vector.

public Vector3

Returns:

This vector for chaining
crs
(float
The x-component of the other vector
x
,
float
The y-component of the other vector
y
,
float
The z-component of the other vector
z
)

Sets this vector to the cross product between it and the other vector.

public static float
dot(float x1, float y1, float z1, float x2, float y2, float z2)

Returns: The dot product between the two vectors

public float
dot(final Vector3 vector)

Implements com.badlogic.gdx.math.Vector.dot.

public float

Returns:

The dot product
dot
(float
The x-component of the other vector
x
,
float
The y-component of the other vector
y
,
float
The z-component of the other vector
z
)

Returns the dot product between this and the given vector.

public static float
dst(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2)

Returns: The Euclidean distance between the two specified vectors

public float
dst(final Vector3 vector)

Implements com.badlogic.gdx.math.Vector.dst.

public float
dst(float x, float y, float z)

Returns: the distance between this point and the given point

public static float
dst2(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2)

Returns: the squared distance between the given points

public float
dst2(Vector3 point)

Implements com.badlogic.gdx.math.Vector.dst2.

This method is faster than Vector#dst(Vector) because it avoids calculating a square root.

public float

Returns:

The squared distance
dst2
(float
The x-component of the other point
x
,
float
The y-component of the other point
y
,
float
The z-component of the other point
z
)

Returns the squared distance between this point and the given point

public boolean
epsilonEquals(final Vector3 other, float epsilon)

Implements com.badlogic.gdx.math.Vector.epsilonEquals.

Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.

public boolean

Returns:

whether the vectors are the same.
epsilonEquals
(float x, float y, float z, float epsilon)

Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.

public boolean

Returns:

true if vector are equal, otherwise false
epsilonEquals
(final Vector3
other vector to compare
other
)

Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing

public boolean

Returns:

true if vector are equal, otherwise false
epsilonEquals
(float
x component of the other vector to compare
x
,
float
y component of the other vector to compare
y
,
float
z component of the other vector to compare
z
)

Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Vector3

Returns:

this vector for chaining
fromString
(String
the string.
v
)

Sets this Vector3 to the value represented by the specified string according to the format of toString().

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
public boolean

Returns:

Whether this and the other vector are equal with exact precision
idt
(final Vector3
The other vector
vector
)

Returns true if this vector and the vector parameter have identical components.

public Vector3
interpolate(Vector3 target, float alpha, Interpolation interpolator)

Implements com.badlogic.gdx.math.Vector.interpolate.

Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method.

public boolean
public boolean
public boolean
public boolean
public boolean
isOnLine(Vector3 other, float epsilon)

Implements com.badlogic.gdx.math.Vector.isOnLine.

public boolean
public boolean
public boolean
public boolean
public boolean
isUnit(final float margin)

Implements com.badlogic.gdx.math.Vector.isUnit.

public boolean
public boolean
isZero(final float margin)

Implements com.badlogic.gdx.math.Vector.isZero.

public static float
len(final float x, final float y, final float z)

Returns: The Euclidean length

public float
public static float
len2(final float x, final float y, final float z)

Returns: The squared Euclidean length

public float
len2()

Implements com.badlogic.gdx.math.Vector.len2.

This method is faster than Vector#len() because it avoids calculating a square root.

public Vector3
lerp(final Vector3 target, float alpha)

Implements com.badlogic.gdx.math.Vector.lerp.

Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1].

public Vector3
limit(float limit)

Implements com.badlogic.gdx.math.Vector.limit.

Limits the length of this vector, based on the desired maximum length.

public Vector3
limit2(float limit2)

Implements com.badlogic.gdx.math.Vector.limit2.

Limits the length of this vector, based on the desired maximum length squared.

public Vector3

Returns:

This vector for chaining
mul
(final Matrix4
The matrix
matrix
)

Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.

public Vector3

Returns:

This vector for chaining
mul
(Matrix3
The matrix
matrix
)

Left-multiplies the vector by the given matrix.

public Vector3

Returns:

This vector for chaining
mul
(final Quaternion quat)

Multiplies the vector by the given Quaternion.

public Vector3

Returns:

This vector for chaining
mul4x3
(float[]
The matrix
matrix
)

Left-multiplies the vector by the given 4x3 column major matrix.

public Vector3
mulAdd(Vector3 vec, float scalar)

Implements com.badlogic.gdx.math.Vector.mulAdd, com.badlogic.gdx.math.Vector.mulAdd.

First scale a supplied vector, then add it to this vector.

public Vector3
mulAdd(Vector3 vec, Vector3 mulVec)

Implements com.badlogic.gdx.math.Vector.mulAdd.

First scale a supplied vector, then add it to this vector.

public Vector3
nor()

Implements com.badlogic.gdx.math.Vector.nor.

Normalizes this vector.

public Vector3

Returns:

This vector for chaining
prj
(final Matrix4
The matrix.
matrix
)

Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1.

public Vector3

Returns:

This vector for chaining
rot
(final Matrix4
The matrix
matrix
)

Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.

public Vector3

Returns:

This vector for chaining
rotate
(float
the angle in degrees
degrees
,
float
the x-component of the axis
axisX
,
float
the y-component of the axis
axisY
,
float
the z-component of the axis
axisZ
)

Rotates this vector by the given angle in degrees around the given axis.

public Vector3

Returns:

This vector for chaining
rotate
(final Vector3
the axis
axis
,
float
the angle in degrees
degrees
)

Rotates this vector by the given angle in degrees around the given axis.

public Vector3

Returns:

This vector for chaining
rotateRad
(float
the angle in radians
radians
,
float
the x-component of the axis
axisX
,
float
the y-component of the axis
axisY
,
float
the z-component of the axis
axisZ
)

Rotates this vector by the given angle in radians around the given axis.

public Vector3

Returns:

This vector for chaining
rotateRad
(final Vector3
the axis
axis
,
float
the angle in radians
radians
)

Rotates this vector by the given angle in radians around the given axis.

public Vector3
scl(float scalar)

Implements com.badlogic.gdx.math.Vector.scl, com.badlogic.gdx.math.Vector.scl.

Scales this vector by a scalar

public Vector3
scl(final Vector3 other)

Implements com.badlogic.gdx.math.Vector.scl.

Scales this vector by another vector

public Vector3

Returns:

This vector for chaining
scl
(float
X value
vx
,
float
Y value
vy
,
float
Z value
vz
)

Scales this vector by the given values

public Vector3

Returns:

this vector for chaining
set
(float
The x-component
x
,
float
The y-component
y
,
float
The z-component
z
)

Sets the vector to the given components

public Vector3
set(final Vector3 vector)

Implements com.badlogic.gdx.math.Vector.set.

Sets this vector from the given vector

public Vector3

Returns:

this vector for chaining
set
(final float[]
The array
values
)

Implements com.badlogic.gdx.math.Vector.set.

Sets the components from the array.

public Vector3

Returns:

This vector for chaining
set
(final Vector2
The vector
vector
,
float
The z-component
z
)

Sets the components of the given vector and z-component

public Vector3

Returns:

This vector for chaining
setFromSpherical
(float
The angle between x-axis in radians [0, 2pi]
azimuthalAngle
,
float
The angle between z-axis in radians [0, pi]
polarAngle
)

Sets the components from the given spherical coordinate

public Vector3
setLength(float len)

Implements com.badlogic.gdx.math.Vector.setLength.

Sets the length of this vector.

public Vector3
setLength2(float len2)

Implements com.badlogic.gdx.math.Vector.setLength2.

Sets the length of this vector, based on the square of the desired length.

public Vector3
setToRandomDirection()

Implements com.badlogic.gdx.math.Vector.setToRandomDirection.

Sets this vector to the unit vector with a random direction

public Vector3
setZero()

Implements com.badlogic.gdx.math.Vector.setZero.

Sets the components of this vector to 0

public Vector3

Returns:

This vector for chaining.
slerp
(final Vector3
The target vector
target
,
float
The interpolation coefficient
alpha
)

Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1].

public Vector3
sub(final Vector3 a_vec)

Implements com.badlogic.gdx.math.Vector.sub.

Subtracts the given vector from this vector.

public Vector3

Returns:

This vector for chaining
sub
(float
The x-component of the other vector
x
,
float
The y-component of the other vector
y
,
float
The z-component of the other vector
z
)

Subtracts the other vector from this vector.

public Vector3

Returns:

This vector for chaining
sub
(float
The value
value
)

Implements com.badlogic.gdx.math.Vector.sub.

Subtracts the given value from all components of this vector

public String

Returns:

a string representation of this object.
toString
()

Overrides java.lang.Object.toString.

Converts this Vector3 to a string in the format (x,y,z).

public Vector3

Returns:

This vector for chaining
traMul
(final Matrix4
The matrix
matrix
)

Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.

public Vector3

Returns:

This vector for chaining
traMul
(Matrix3
The matrix
matrix
)

Multiplies the vector by the transpose of the given matrix.

public Vector3

Returns:

The vector for chaining
unrotate
(final Matrix4
The transformation matrix
matrix
)

Multiplies this vector by the transpose of the first three columns of the matrix.

public Vector3

Returns:

The vector for chaining
untransform
(final Matrix4
The transformation matrix
matrix
)

Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the transpose of the first three columns of the matrix.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait