# 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 are equal if each component is equal within a tolerance. boolean equals(Object other) Returns true if the other object is a Vector3 and each component is equal within a tolerance. static Vector3 forward() Gets a Vector3 set to (0, 0, -1) static Vector3 left() Gets a Vector3 set to (-1, 0, 0) float length() float 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 toString() static Vector3 up() Gets a Vector3 set to (0, 1, 0) static Vector3 zero() Gets a Vector3 with all values set to zero

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

#### public Vector3(Vector3 v)

Construct a Vector3 and copy the values

## Public Methods

#### public static Vector3 add(Vector3 lhs, Vector3 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.

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

##### Returns
• A Vector3 perpendicular to Vector3's

#### public static float dot(Vector3 lhs, Vector3 rhs)

Get dot product of two Vector3's

##### 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 are equal if each component is equal within a tolerance.

#### public boolean equals(Object other)

Returns true if the other object is a Vector3 and each component is equal within a tolerance.

#### 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 static Vector3 lerp(Vector3 a, Vector3 b, float t)

Linearly interpolates between a and b.

##### Parameters
a the beginning value the ending value 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

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

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

##### Returns
• a Vector3 multiplied by a scalar amount

#### public void set(Vector3 v)

Copy the values from another Vector3 to this Vector3

Set each value

#### public static Vector3 subtract(Vector3 lhs, Vector3 rhs)

Subtract two Vector3

##### Returns
• The combined Vector3

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

[]
[]
{"lastModified": "Last updated 2024-06-26 UTC."}