pythagoras.f

## Class Vector3

• All Implemented Interfaces:
Serializable, IVector3

```public class Vector3
extends Object
implements IVector3, Serializable```
A three element vector.
Serialized Form
• ### Field Summary

Fields
Modifier and Type Field and Description
`static IVector3` `MAX_VALUE`
A vector containing the maximum floating point value for all components.
`static IVector3` `MIN_VALUE`
A vector containing the minimum floating point value for all components (note: the components are -`Float.MAX_VALUE`, not `Float.MIN_VALUE`).
`static IVector3` `NORMAL_XYZ`
A normalized version of UNIT_XYZ.
`static IVector3` `UNIT_X`
A unit vector in the X+ direction.
`static IVector3` `UNIT_XYZ`
A vector containing unity for all components.
`static IVector3` `UNIT_Y`
A unit vector in the Y+ direction.
`static IVector3` `UNIT_Z`
A unit vector in the Z+ direction.
`float` `x`
The components of the vector.
`float` `y`
The components of the vector.
`float` `z`
The components of the vector.
`static IVector3` `ZERO`
The zero vector.
• ### Constructor Summary

Constructors
Constructor and Description
`Vector3()`
Creates a zero vector.
`Vector3(float[] values)`
Creates a vector from an array of values.
```Vector3(float x, float y, float z)```
Creates a vector from three components.
`Vector3(IVector3 other)`
Copy constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Vector3` `abs()`
Absolute-values this vector.
`Vector3` `abs(Vector3 result)`
Absolute-values this vector, storing the result in the supplied object.
`Vector3` `absLocal()`
Absolute-values this vector in-place.
`Vector3` ```add(float x, float y, float z)```
Adds a vector to this one.
`Vector3` ```add(float x, float y, float z, Vector3 result)```
Adds a vector to this one and stores the result in the object provided.
`Vector3` `add(IVector3 other)`
Adds a vector to this one.
`Vector3` ```add(IVector3 other, Vector3 result)```
Adds a vector to this one, storing the result in the object provided.
`Vector3` ```addLocal(float x, float y, float z)```
Adds a vector in-place to this one.
`Vector3` `addLocal(IVector3 other)`
Adds a vector in-place to this one.
`Vector3` ```addScaled(IVector3 other, float v)```
Adds a scaled vector to this one.
`Vector3` ```addScaled(IVector3 other, float v, Vector3 result)```
Adds a scaled vector to this one and stores the result in the supplied vector.
`Vector3` ```addScaledLocal(IVector3 other, float v)```
Adds a scaled vector in-place to this one.
`float` `angle(IVector3 other)`
Returns the angle between this vector and the specified other vector.
`Vector3` `cross(IVector3 other)`
Computes the cross product of this and the specified other vector.
`Vector3` ```cross(IVector3 other, Vector3 result)```
Computes the cross product of this and the specified other vector, placing the result in the object supplied.
`Vector3` `crossLocal(IVector3 other)`
Computes the cross product of this and the specified other vector, storing the result in this vector.
`float` `distance(IVector3 other)`
Returns the distance from this vector to the specified other vector.
`float` `distanceSquared(IVector3 other)`
Returns the squared distance from this vector to the specified other.
`float` `dot(IVector3 other)`
Computes and returns the dot product of this and the specified other vector.
`boolean` `equals(Object other)`
`void` `get(float[] values)`
Populates the supplied array with the contents of this vector.
`FloatBuffer` `get(FloatBuffer buf)`
Populates the supplied buffer with the contents of this vector.
`float` `get(int idx)`
Returns the element at the idx'th position of the vector.
`int` `hashCode()`
`float` `length()`
Returns the length of this vector.
`float` `lengthSquared()`
Returns the squared length of this vector.
`Vector3` ```lerp(IVector3 other, float t)```
Linearly interpolates between this and the specified other vector by the supplied amount.
`Vector3` ```lerp(IVector3 other, float t, Vector3 result)```
Linearly interpolates between this and the supplied other vector by the supplied amount, storing the result in the supplied object.
`Vector3` ```lerpLocal(IVector3 other, float t)```
Linearly interpolates between this and the specified other vector in-place by the supplied amount.
`float` `manhattanDistance(IVector3 other)`
Returns the Manhattan distance between this vector and the specified other.
`Vector3` `mult(float v)`
Multiplies this vector by a scalar.
`Vector3` ```mult(float v, Vector3 result)```
Multiplies this vector by a scalar and places the result in the supplied object.
`Vector3` `mult(IVector3 other)`
Multiplies this vector by another.
`Vector3` ```mult(IVector3 other, Vector3 result)```
Multiplies this vector by another, storing the result in the object provided.
`Vector3` `multLocal(float v)`
Multiplies this vector in-place by a scalar.
`Vector3` `multLocal(IVector3 other)`
Multiplies this vector in-place by another.
`Vector3` `negate()`
Negates this vector.
`Vector3` `negate(Vector3 result)`
Negates this vector, storing the result in the supplied object.
`Vector3` `negateLocal()`
Negates this vector in-place.
`Vector3` `normalize()`
Normalizes this vector.
`Vector3` `normalize(Vector3 result)`
Normalizes this vector, storing the result in the object supplied.
`Vector3` `normalizeLocal()`
Normalizes this vector in-place.
`Vector3` `set(float[] values)`
Copies the elements of an array.
`Vector3` ```set(float x, float y, float z)```
Sets all of the elements of the vector.
`Vector3` `set(IVector3 other)`
Copies the elements of another vector.
`Vector3` `subtract(IVector3 other)`
Subtracts a vector from this one.
`Vector3` ```subtract(IVector3 other, Vector3 result)```
Subtracts a vector from this one and places the result in the supplied object.
`Vector3` `subtractLocal(IVector3 other)`
Subtracts a vector in-place from this one.
`String` `toString()`
`float` ```triple(IVector3 b, IVector3 c)```
Computes the triple product of this and the specified other vectors, which is equal to `this.dot(b.cross(c))`.
`float` `x()`
Returns the x-component of this vector.
`float` `y()`
Returns the y-component of this vector.
`float` `z()`
Returns the z-component of this vector.
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### UNIT_X

`public static final IVector3 UNIT_X`
A unit vector in the X+ direction.
• #### UNIT_Y

`public static final IVector3 UNIT_Y`
A unit vector in the Y+ direction.
• #### UNIT_Z

`public static final IVector3 UNIT_Z`
A unit vector in the Z+ direction.
• #### UNIT_XYZ

`public static final IVector3 UNIT_XYZ`
A vector containing unity for all components.
• #### NORMAL_XYZ

`public static final IVector3 NORMAL_XYZ`
A normalized version of UNIT_XYZ.
• #### ZERO

`public static final IVector3 ZERO`
The zero vector.
• #### MAX_VALUE

`public static final IVector3 MAX_VALUE`
A vector containing the maximum floating point value for all components.
• #### x

`public float x`
The components of the vector.
• #### y

`public float y`
The components of the vector.
• #### z

`public float z`
The components of the vector.
• ### Constructor Detail

• #### Vector3

```public Vector3(float x,
float y,
float z)```
Creates a vector from three components.
• #### Vector3

`public Vector3(float[] values)`
Creates a vector from an array of values.
• #### Vector3

`public Vector3(IVector3 other)`
Copy constructor.
• #### Vector3

`public Vector3()`
Creates a zero vector.
• ### Method Detail

• #### crossLocal

`public Vector3 crossLocal(IVector3 other)`
Computes the cross product of this and the specified other vector, storing the result in this vector.
Returns:
a reference to this vector, for chaining.
• #### negateLocal

`public Vector3 negateLocal()`
Negates this vector in-place.
Returns:
a reference to this vector, for chaining.
• #### absLocal

`public Vector3 absLocal()`
Absolute-values this vector in-place.
Returns:
a reference to this vector, for chaining.
• #### normalizeLocal

`public Vector3 normalizeLocal()`
Normalizes this vector in-place.
Returns:
a reference to this vector, for chaining.
• #### multLocal

`public Vector3 multLocal(float v)`
Multiplies this vector in-place by a scalar.
Returns:
a reference to this vector, for chaining.
• #### multLocal

`public Vector3 multLocal(IVector3 other)`
Multiplies this vector in-place by another.
Returns:
a reference to this vector, for chaining.

`public Vector3 addLocal(IVector3 other)`
Adds a vector in-place to this one.
Returns:
a reference to this vector, for chaining.
• #### subtractLocal

`public Vector3 subtractLocal(IVector3 other)`
Subtracts a vector in-place from this one.
Returns:
a reference to this vector, for chaining.

```public Vector3 addLocal(float x,
float y,
float z)```
Adds a vector in-place to this one.
Returns:
a reference to this vector, for chaining.

```public Vector3 addScaledLocal(IVector3 other,
float v)```
Adds a scaled vector in-place to this one.
Returns:
a reference to this vector, for chaining.
• #### lerpLocal

```public Vector3 lerpLocal(IVector3 other,
float t)```
Linearly interpolates between this and the specified other vector in-place by the supplied amount.
Returns:
a reference to this vector, for chaining.
• #### set

`public Vector3 set(IVector3 other)`
Copies the elements of another vector.
Returns:
a reference to this vector, for chaining.
• #### set

`public Vector3 set(float[] values)`
Copies the elements of an array.
Returns:
a reference to this vector, for chaining.
• #### set

```public Vector3 set(float x,
float y,
float z)```
Sets all of the elements of the vector.
Returns:
a reference to this vector, for chaining.
• #### x

`public float x()`
Description copied from interface: `IVector3`
Returns the x-component of this vector.
Specified by:
`x` in interface `IVector3`
• #### y

`public float y()`
Description copied from interface: `IVector3`
Returns the y-component of this vector.
Specified by:
`y` in interface `IVector3`
• #### z

`public float z()`
Description copied from interface: `IVector3`
Returns the z-component of this vector.
Specified by:
`z` in interface `IVector3`
• #### dot

`public float dot(IVector3 other)`
Description copied from interface: `IVector3`
Computes and returns the dot product of this and the specified other vector.
Specified by:
`dot` in interface `IVector3`
• #### cross

`public Vector3 cross(IVector3 other)`
Description copied from interface: `IVector3`
Computes the cross product of this and the specified other vector.
Specified by:
`cross` in interface `IVector3`
Returns:
a new vector containing the result.
• #### cross

```public Vector3 cross(IVector3 other,
Vector3 result)```
Description copied from interface: `IVector3`
Computes the cross product of this and the specified other vector, placing the result in the object supplied.
Specified by:
`cross` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### triple

```public float triple(IVector3 b,
IVector3 c)```
Description copied from interface: `IVector3`
Computes the triple product of this and the specified other vectors, which is equal to `this.dot(b.cross(c))`.
Specified by:
`triple` in interface `IVector3`
• #### negate

`public Vector3 negate()`
Description copied from interface: `IVector3`
Negates this vector.
Specified by:
`negate` in interface `IVector3`
Returns:
a new vector containing the result.
• #### negate

`public Vector3 negate(Vector3 result)`
Description copied from interface: `IVector3`
Negates this vector, storing the result in the supplied object.
Specified by:
`negate` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### abs

`public Vector3 abs()`
Description copied from interface: `IVector3`
Absolute-values this vector.
Specified by:
`abs` in interface `IVector3`
Returns:
a new vector containing the result.
• #### abs

`public Vector3 abs(Vector3 result)`
Description copied from interface: `IVector3`
Absolute-values this vector, storing the result in the supplied object.
Specified by:
`abs` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### normalize

`public Vector3 normalize()`
Description copied from interface: `IVector3`
Normalizes this vector.
Specified by:
`normalize` in interface `IVector3`
Returns:
a new vector containing the result.
• #### normalize

`public Vector3 normalize(Vector3 result)`
Description copied from interface: `IVector3`
Normalizes this vector, storing the result in the object supplied.
Specified by:
`normalize` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### angle

`public float angle(IVector3 other)`
Description copied from interface: `IVector3`
Returns the angle between this vector and the specified other vector.
Specified by:
`angle` in interface `IVector3`
• #### length

`public float length()`
Description copied from interface: `IVector3`
Returns the length of this vector.
Specified by:
`length` in interface `IVector3`
• #### lengthSquared

`public float lengthSquared()`
Description copied from interface: `IVector3`
Returns the squared length of this vector.
Specified by:
`lengthSquared` in interface `IVector3`
• #### distance

`public float distance(IVector3 other)`
Description copied from interface: `IVector3`
Returns the distance from this vector to the specified other vector.
Specified by:
`distance` in interface `IVector3`
• #### distanceSquared

`public float distanceSquared(IVector3 other)`
Description copied from interface: `IVector3`
Returns the squared distance from this vector to the specified other.
Specified by:
`distanceSquared` in interface `IVector3`
• #### manhattanDistance

`public float manhattanDistance(IVector3 other)`
Description copied from interface: `IVector3`
Returns the Manhattan distance between this vector and the specified other.
Specified by:
`manhattanDistance` in interface `IVector3`
• #### mult

`public Vector3 mult(float v)`
Description copied from interface: `IVector3`
Multiplies this vector by a scalar.
Specified by:
`mult` in interface `IVector3`
Returns:
a new vector containing the result.
• #### mult

```public Vector3 mult(float v,
Vector3 result)```
Description copied from interface: `IVector3`
Multiplies this vector by a scalar and places the result in the supplied object.
Specified by:
`mult` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### mult

`public Vector3 mult(IVector3 other)`
Description copied from interface: `IVector3`
Multiplies this vector by another.
Specified by:
`mult` in interface `IVector3`
Returns:
a new vector containing the result.
• #### mult

```public Vector3 mult(IVector3 other,
Vector3 result)```
Description copied from interface: `IVector3`
Multiplies this vector by another, storing the result in the object provided.
Specified by:
`mult` in interface `IVector3`
Returns:
a reference to the result vector, for chaining.

`public Vector3 add(IVector3 other)`
Description copied from interface: `IVector3`
Adds a vector to this one.
Specified by:
`add` in interface `IVector3`
Returns:
a new vector containing the result.

```public Vector3 add(IVector3 other,
Vector3 result)```
Description copied from interface: `IVector3`
Adds a vector to this one, storing the result in the object provided.
Specified by:
`add` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### subtract

`public Vector3 subtract(IVector3 other)`
Description copied from interface: `IVector3`
Subtracts a vector from this one.
Specified by:
`subtract` in interface `IVector3`
Returns:
a new vector containing the result.
• #### subtract

```public Vector3 subtract(IVector3 other,
Vector3 result)```
Description copied from interface: `IVector3`
Subtracts a vector from this one and places the result in the supplied object.
Specified by:
`subtract` in interface `IVector3`
Returns:
a reference to the result, for chaining.

```public Vector3 add(float x,
float y,
float z)```
Description copied from interface: `IVector3`
Adds a vector to this one.
Specified by:
`add` in interface `IVector3`
Returns:
a new vector containing the result.

```public Vector3 add(float x,
float y,
float z,
Vector3 result)```
Description copied from interface: `IVector3`
Adds a vector to this one and stores the result in the object provided.
Specified by:
`add` in interface `IVector3`
Returns:
a reference to the result, for chaining.

```public Vector3 addScaled(IVector3 other,
float v)```
Description copied from interface: `IVector3`
Adds a scaled vector to this one.
Specified by:
`addScaled` in interface `IVector3`
Returns:
a new vector containing the result.

```public Vector3 addScaled(IVector3 other,
float v,
Vector3 result)```
Description copied from interface: `IVector3`
Adds a scaled vector to this one and stores the result in the supplied vector.
Specified by:
`addScaled` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### lerp

```public Vector3 lerp(IVector3 other,
float t)```
Description copied from interface: `IVector3`
Linearly interpolates between this and the specified other vector by the supplied amount.
Specified by:
`lerp` in interface `IVector3`
Returns:
a new vector containing the result.
• #### lerp

```public Vector3 lerp(IVector3 other,
float t,
Vector3 result)```
Description copied from interface: `IVector3`
Linearly interpolates between this and the supplied other vector by the supplied amount, storing the result in the supplied object.
Specified by:
`lerp` in interface `IVector3`
Returns:
a reference to the result, for chaining.
• #### get

`public float get(int idx)`
Description copied from interface: `IVector3`
Returns the element at the idx'th position of the vector.
Specified by:
`get` in interface `IVector3`
• #### get

`public void get(float[] values)`
Description copied from interface: `IVector3`
Populates the supplied array with the contents of this vector.
Specified by:
`get` in interface `IVector3`
• #### get

`public FloatBuffer get(FloatBuffer buf)`
Description copied from interface: `IVector3`
Populates the supplied buffer with the contents of this vector.
Specified by:
`get` in interface `IVector3`
Returns:
a reference to the buffer, for chaining.
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### equals

`public boolean equals(Object other)`
Overrides:
`equals` in class `Object`