Vector3

public class Vector3

A Vector with 3 floats.

Fields

public float x
public float y
public float z

Public Constructors

Vector3()
Construct a Vector3 and assign zero to all values
Vector3(float x, float y, float z)
Construct a Vector3 and assign each value
Vector3(Vector3 v)
Construct a Vector3 and copy the values

Public Methods

static Vector3
add(Vector3 lhs, Vector3 rhs)
Adds two Vector3's
static float
angleBetweenVectors(Vector3 a, Vector3 b)
Returns the shortest angle in degrees between two vectors.
static Vector3
back()
Gets a Vector3 set to (0, 0, 1)
static Vector3
cross(Vector3 lhs, Vector3 rhs)
Get cross product of two Vector3's
static float
dot(Vector3 lhs, Vector3 rhs)
Get dot product of two Vector3's
static Vector3
down()
Gets a Vector3 set to (0, -1, 0)
static boolean
equals(Vector3 lhs, Vector3 rhs)
Compares two Vector3's
static Vector3
forward()
Gets a Vector3 set to (0, 0, -1)
static Vector3
left()
Gets a Vector3 set to (-1, 0, 0)
float
length()
static Vector3
lerp(Vector3 a, Vector3 b, float t)
Linearly interpolates between a and b.
static Vector3
max(Vector3 lhs, Vector3 rhs)
Get a Vector3 with each value set to the element wise maximum of two Vector3's values
static Vector3
min(Vector3 lhs, Vector3 rhs)
Get a Vector3 with each value set to the element wise minimum of two Vector3's values
Vector3
negated()
Negates a Vector3
Vector3
normalized()
Scales the Vector3 to the unit length
static Vector3
one()
Gets a Vector3 with all values set to one
static Vector3
right()
Gets a Vector3 set to (1, 0, 0)
Vector3
scaled(float a)
Uniformly scales a Vector3
void
set(Vector3 v)
Copy the values from another Vector3 to this Vector3
void
set(float vx, float vy, float vz)
Set each value
static Vector3
subtract(Vector3 lhs, Vector3 rhs)
Subtract two Vector3
String
static Vector3
up()
Gets a Vector3 set to (0, 1, 0)
static Vector3
zero()
Gets a Vector3 with all values set to zero

Inherited Methods

Fields

public float x

public float y

public float z

Public Constructors

public Vector3 ()

Construct a Vector3 and assign zero to all values

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

Construct a Vector3 and assign each value

Parameters
x
y
z

public Vector3 (Vector3 v)

Construct a Vector3 and copy the values

Parameters
v

Public Methods

public static Vector3 add (Vector3 lhs, Vector3 rhs)

Adds two Vector3's

Parameters
lhs
rhs
Returns
  • The combined Vector3

public static float angleBetweenVectors (Vector3 a, Vector3 b)

Returns the shortest angle in degrees between two vectors. The result is never greater than 180 degrees.

Parameters
a
b

public static Vector3 back ()

Gets a Vector3 set to (0, 0, 1)

public static Vector3 cross (Vector3 lhs, Vector3 rhs)

Get cross product of two Vector3's

Parameters
lhs
rhs
Returns
  • A Vector3 perpendicular to Vector3's

public static float dot (Vector3 lhs, Vector3 rhs)

Get dot product of two Vector3's

Parameters
lhs
rhs
Returns
  • The scalar product of the Vector3's

public static Vector3 down ()

Gets a Vector3 set to (0, -1, 0)

public static boolean equals (Vector3 lhs, Vector3 rhs)

Compares two Vector3's

Parameters
lhs
rhs

public static Vector3 forward ()

Gets a Vector3 set to (0, 0, -1)

public static Vector3 left ()

Gets a Vector3 set to (-1, 0, 0)

public float length ()

public static Vector3 lerp (Vector3 a, Vector3 b, float t)

Linearly interpolates between a and b.

Parameters
a the beginning value
b the ending value
t ratio between the two floats.
Returns
  • interpolated value between the two floats

public static Vector3 max (Vector3 lhs, Vector3 rhs)

Get a Vector3 with each value set to the element wise maximum of two Vector3's values

Parameters
lhs
rhs

public static Vector3 min (Vector3 lhs, Vector3 rhs)

Get a Vector3 with each value set to the element wise minimum of two Vector3's values

Parameters
lhs
rhs

public Vector3 negated ()

Negates a Vector3

Returns
  • A Vector3 with opposite direction

public Vector3 normalized ()

Scales the Vector3 to the unit length

public static Vector3 one ()

Gets a Vector3 with all values set to one

public static Vector3 right ()

Gets a Vector3 set to (1, 0, 0)

public Vector3 scaled (float a)

Uniformly scales a Vector3

Parameters
a
Returns
  • a Vector3 multiplied by a scalar amount

public void set (Vector3 v)

Copy the values from another Vector3 to this Vector3

Parameters
v

public void set (float vx, float vy, float vz)

Set each value

Parameters
vx
vy
vz

public static Vector3 subtract (Vector3 lhs, Vector3 rhs)

Subtract two Vector3

Parameters
lhs
rhs
Returns
  • The combined Vector3

public String toString ()

public static Vector3 up ()

Gets a Vector3 set to (0, 1, 0)

public static Vector3 zero ()

Gets a Vector3 with all values set to zero

Send feedback about...