## Libraries.Compute.Vector3 Documentation

Vector3 is a class representing a vector in 3D space.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector1
Vector3 vector2
vector1:Set(2, 6, 9)
vector2:Set(1, 7, 2)
vector1:CrossProduct(vector2)
number newX = vector1:GetX()
number newY = vector1:GetY()
output "The cross product of the two vectors is: [" + newX + ", " + newY + "]"
```

*Inherits from: *Libraries.Language.Object

## Summary

### Actions Summary Table

Actions | Description |
---|---|

Add(number xValue, number yValue, number zValue) | This action adds the vector with the passed x, y, and z components to the calling vector. |

Add(number value) | This action adds the passed value to the x, y, and z components of the vector. |

Add(Libraries.Compute.Vector3 vector) | This action adds the passed vector to the calling vector. |

Clamp(number min, number max) | This action clamps the length of the vector to be between the passed minimum and maximum values. |

Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns a CompareResult. |

Copy() | This action returns a copy of the current vector. |

CrossProduct(Libraries.Compute.Vector3 vector) | This action computes the cross product between this vector and the passed vector. |

CrossProduct(number xValue, number yValue, number zValue) | This action computes the cross product between the calling vector and the vector with the passed x, y, and z components. |

Distance(number x1, number y1, number z1, number x2, number y2, number z2) | This action computes the distance between the vectors represented by the passed x, y, and z components. |

Distance(Libraries.Compute.Vector3 vector) | This action computes the distance between the calling vector and the passed vector. |

Distance(number xValue, number yValue, number zValue) | This action computes the distance between the calling vector and the vector represented by the passed x, y, and z components. |

DistanceSquared(Libraries.Compute.Vector3 vector) | This action computes the square of the distance between the calling vector and the passed vector. |

DistanceSquared(number xValue, number yValue, number zValue) | This action computes the square of the distance between the calling vector and the vector represented by the passed x, y, and z components. |

DistanceSquared(number x1, number y1, number z1, number x2, number y2, number z2) | This action computes the square of the distance between the vectors represented by the passed x, y, and z components. |

DotProduct(number x1, number y1, number z1, number x2, number y2, number z2) | This action computes the dot product of the two vectors given by the passed x, y, and z components. |

DotProduct(Libraries.Compute.Vector3 vector) | This action computes the dot product between the calling vector and the passed vector. |

DotProduct(number xValue, number yValue, number zValue) | This action computes the dot product between the calling vector and the vector with the passed x, y, and z components. |

Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |

Equals(Libraries.Compute.Vector3 vector) | This action determines whether the passed vector is equal to this vector. |

EqualsAtPrecision(Libraries.Compute.Vector3 other, number epsilon) | This action determines whether the passed vector equals the calling vector to within the passed precision. |

EqualsAtPrecision(number xVal, number yVal, number zVal, number precision) | This action determines whether the vector represented by the passed x, y, and z components equals the calling vector to within the passed precision. |

GetHashCode() | This action gets the hash code for an object. |

GetX() | This action returns the x component of the vector. |

GetY() | This action returns the y component of the vector. |

GetZ() | This action returns the z component of the vector. |

HasOppositeDirection(Libraries.Compute.Vector3 vector) | This action determines whether the passed vector has the opposite direction as the calling vector. |

HasSameDirection(Libraries.Compute.Vector3 vector) | This action determines whether the passed vector has the same direction as the calling vector. |

IsCollinear(Libraries.Compute.Vector3 other, number precision) | This action determines whether the passed vector is collinear with the calling vector, meaning that it lies on the same line as the calling vector and has the same direction as the calling vector to within the passed precision. |

IsCollinear(Libraries.Compute.Vector3 other) | This action determines whether the passed vector is collinear with the calling vector, meaning that it lies on the same line as the calling vector and has the same direction as the calling vector. |

IsCollinearOpposite(Libraries.Compute.Vector3 other, number precision) | This action determines whether the passed vector is collinear in the opposite direction with the calling vector, meaning that it lies on the same line as the calling vector and has the opposite direction as the calling vector to within the passed precision. |

IsCollinearOpposite(Libraries.Compute.Vector3 other) | This action determines whether the passed vector is collinear in the opposite direction with the calling vector, meaning that it lies on the same line as the calling vector and has the opposite direction as the calling vector. |

IsOnLine(Libraries.Compute.Vector3 other) | This action determines whether the passed vector is on the same line as the calling vector, either in the same or opposite direction. |

IsOnLine(Libraries.Compute.Vector3 other, number precision) | This action determines whether the passed vector is on the same line as the calling vector to within the passed precision, either in the same or opposite direction |

IsPerpendicular(Libraries.Compute.Vector3 vector) | This action determines whether the passed vector is perpendicular to the calling vector. |

IsPerpendicular(Libraries.Compute.Vector3 vector, number precision) | This action determines whether the passed vector is perpendicular to the calling vector to within the passed precision. |

IsUnit() | This action determines whether the vector is a unit vector, meaning it has a length of 1. |

IsUnit(number precision) | This action determines whether the vector is a unit vector, meaning it has a length of 1 to within the passed precision. |

IsZero() | This action determines whether the vector is the zero vector, meaning that its x, y, and z components are 0. |

IsZero(number precision) | This action determines whether the vector is the zero vector to within the passed precision, meaning that its x, y, and z components are 0. |

Length(number x, number y, number z) | This action returns the length of the vector with the passed x, y, and z components measured from the origin (0, 0). |

Length() | This action returns the length of the vector measured from the origin (0, 0) |

LengthSquared() | This action returns the square of the length of the vector measured from the origin (0, 0). |

LengthSquared(number x, number y, number z) | This action returns the square of the length of the vector with the passed x, y, and z components measured from the origin (0, 0). |

Limit(number limit) | This action limits the length of the vector to the passed limit value. |

LimitSquared(number limitSquared) | This action limits the square of the length of the vector to the passed value, which represents the square of the value to limit the length of the vector to. |

LinearInterpolation(Libraries.Compute.Vector3 target, number alpha) | This action performs a linear interpolation between the calling vector and the passed target vector by alpha, which is between 0 and 1, inclusive. |

Multiply(Libraries.Compute.Quaternion quaternion) | This action multiplies the vector by the passed quaternion. |

Multiply(Libraries.Compute.Matrix4 matrix) | This action multiplies the vector by a 4-by-4 matrix assuming the fourth w component of the vector is 1. |

Multiply(Libraries.Compute.Matrix3 matrix) | This action multiplies the vector by the passed 3-by-3 matrix and stores the result in the vector. |

MultiplyAndAdd(Libraries.Compute.Vector3 addVector, Libraries.Compute.Vector3 scaleVector) | This action multiplies the passed vector by the passed scalar vector and adds the result to the calling vector. |

MultiplyAndAdd(Libraries.Compute.Vector3 vector, number scalar) | This action multiplies the passed vector by the passed scalar and adds the result to the calling vector. |

MultiplyBy4x3Matrix(Libraries.Containers.Array<number> matrix) | This action multiplies the vector by a 4-by-3 matrix and stores the result in the vector. |

MultiplyByTranspose(Libraries.Compute.Matrix3 matrix) | This action multiplies the vector by the transpose of the passed 3-by-3 matrix and stores the result in the vector. |

MultiplyByTranspose(Libraries.Compute.Matrix4 matrix) | This action multiplies the vector by the transpose of the passed 4-by-4 matrix assuming the fourth w component of the vector is 1. |

Normalize() | This action produces a normalized vector with the same direction as the original vector but with a length of 1. |

Project(Libraries.Compute.Matrix4 matrix) | This action projects the vector via a perspective projection matrix. |

Rotate(Libraries.Compute.Vector3 axis, number degrees) | This action rotates the vector the given number of degrees around the passed axis. |

Rotate(number degrees, number axisX, number axisY, number axisZ) | This action rotates the vector the given number of degrees around the axis with the passed x, y, and z components. |

Rotate(Libraries.Compute.Matrix4 matrix) | This action multiplies the vector by the first three columns of the passed matrix, effectively applying rotation and scaling to the vector. |

RotateRadians(Libraries.Compute.Vector3 axis, number radians) | This action rotates the vector the given number of radians around the passed axis. |

RotateRadians(number radians, number axisX, number axisY, number axisZ) | This action rotates the vector the given number of radians around the axis with the passed x, y, and z components. |

Scale(Libraries.Compute.Vector3 vector) | This action scales the vector by multiplying the x component by the x component of the passed vector, the y component by the y component of the passed vector, and the z component by the z component of the passed vector. |

Scale(number scalar) | This action scales the vector by multiplying the x, y, and z components by the passed scalar value. |

Scale(number xValue, number yValue, number zValue) | This action scales the vector by multiplying the x component with the passed x value, the y component with the passed y value, and the z component with the passed z value. |

Set(number xValue, number yValue, number zValue) | This action sets the x, y, and z components of the vector to the passed x, y, and z values. |

Set(Libraries.Containers.Array<number> array) | This action sets the x, y, and z components of the vector to the elements of the passed array. |

Set(Libraries.Compute.Vector2 vector, number z) | This action sets the vector's x and y components to the x and y components of the passed 2D vector and sets the z component to the passed z value. |

Set(Libraries.Compute.Vector3 vector) | This action sets the vector's components to the components of the passed vector. |

SetX(number newX) | This action sets the x component of the vector to the passed value. |

SetY(number newY) | This action sets the y component of the vector to the passed value. |

SetZ(number newZ) | This action sets the z component of the vector to the passed value. |

SetZero() | This action sets the vector to the zero vector, meaning the x, y, and z components will be set to 0. |

SphericalLinearInterpolation(Libraries.Compute.Vector3 target, number alpha) | This action performs a spherical interpolation between the calling vector and the passed target vector by alpha, which is between 0 and 1, inclusive. |

Subtract(number value) | This action subtracts the passed value from the x, y, and z components of the vector. |

Subtract(number xValue, number yValue, number zValue) | This action subtracts a vector with the passed components from the calling vector. |

Subtract(Libraries.Compute.Vector3 vector) | This action subtracts the passed vector from the calling vector. |

Unrotate(Libraries.Compute.Matrix4 matrix) | This action multiplies the vector by the first three columns of the transpose of the passed matrix, effectively undoing any rotation and translation of the vector. |

Untransform(Libraries.Compute.Matrix4 matrix) | This action translates the vector in the direction opposite from the translation of the matrix and then multiplies the vector by the first three columns of the matrix. |

## Actions Documentation

### Add(number xValue, number yValue, number zValue)

This action adds the vector with the passed x, y, and z components to the calling vector. This changes the calling vector to the result of the addition.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(4.3, 8.1, 6.6)
vector:Add(3.3, 9.2, -4.3)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number xValue: The x component of the vector to add
- number yValue: The y component of the vector to add
- number zValue: The z component of the vector to add

#### Return

Libraries.Compute.Vector3: The calling vector after addition

### Add(number value)

This action adds the passed value to the x, y, and z components of the vector. This changes the vector to the result of the addition.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(3.5, 5.0, 3.1)
vector:Add(4.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number value: The value to add to the x, y, and z components

#### Return

Libraries.Compute.Vector3: The vector after addition

### Add(Libraries.Compute.Vector3 vector)

This action adds the passed vector to the calling vector. This action changes the calling vector to the result of the addition.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.2, 5.5, 9.0)
secondVector:Set(8.3, 4.2, -7.3)
firstVector:Add(secondVector)
number newX = firstVector:GetX()
number newY = firstVector:GetY()
number newZ = firstVector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The vector to add

#### Return

Libraries.Compute.Vector3: The calling vector after addition

### Clamp(number min, number max)

This action clamps the length of the vector to be between the passed minimum and maximum values. This changes the vector if the length of the vector is greater than the maximum or less than the minimum.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 1.0, 2.0)
vector:Clamp(0.5, 1.5)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number min: The minimum length
- number max: The maximum length

#### Return

Libraries.Compute.Vector3: The vector with a new length if the old length was below the minimum or above the maximum

### Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

**Example Code**

```
use Libraries.Language.Support.CompareResult
Object o
Object t
CompareResult result = o:Compare(t)
```

#### Parameters

- Libraries.Language.Object: The object to compare to.

#### Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

### Copy()

This action returns a copy of the current vector. The new vector's x, y, and z components are the same as the calling vector's x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(4.8, 3.2, -4.2)
Vector3 copyVector
copyVector = vector:Copy()
number newX = copyVector:GetX()
number newY = copyVector:GetY()
number newZ = copyVector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Return

Libraries.Compute.Vector3: a new vector that is a copy of the calling vector

### CrossProduct(Libraries.Compute.Vector3 vector)

This action computes the cross product between this vector and the passed vector. This changes the calling vector to the result of the cross product.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(1.0, 0.0, 0.0)
secondVector:Set(0.0, 1.0, 0.0)
firstVector:CrossProduct(secondVector)
number newX = firstVector:GetX()
number newY = firstVector:GetY()
number newZ = firstVector:GetZ()
output "The cross product is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

Libraries.Compute.Vector3: The calling vector after taking the cross product

### CrossProduct(number xValue, number yValue, number zValue)

This action computes the cross product between the calling vector and the vector with the passed x, y, and z components. This changes the calling vector to the result of the cross product.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(1.0, 0.0, 0.0)
vector:CrossProduct(0.0, 1.0, 0.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The cross product is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number xValue: The x component of the other vector
- number yValue: The y component of the other vector
- number zValue: The z component of the other vector

#### Return

Libraries.Compute.Vector3: The calling vector after taking the cross product

### Distance(number x1, number y1, number z1, number x2, number y2, number z2)

This action computes the distance between the vectors represented by the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
number distance = vector:Distance(2.0, 3.0, 4.0, 2.0, 5.0, 1.0)
output "The distance is " + distance
```

#### Parameters

- number x1: The x component of the first vector
- number y1: The y component of the first vector
- number z1: The z component of the first vector
- number x2: The x component of the second vector
- number y2: The y component of the second vector
- number z2: The z component of the second vector

#### Return

number: The distance between the two vectors

### Distance(Libraries.Compute.Vector3 vector)

This action computes the distance between the calling vector and the passed vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 otherVector
vector:Set(2.0, 3.0, 4.0)
otherVector:Set(2.0, 5.0, 1.0)
number distance = vector:Distance(otherVector)
output "The distance is " + distance
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

number: The distance between the two vectors

### Distance(number xValue, number yValue, number zValue)

This action computes the distance between the calling vector and the vector represented by the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 3.0, 4.0)
number distance = vector:Distance(2.0, 5.0, 1.0)
output "The distance is " + distance
```

#### Parameters

- number xValue: The x component of the other vector
- number yValue: The y component of the other vector
- number zValue: The z component of the other vector

#### Return

number: The distance between the two vectors

### DistanceSquared(Libraries.Compute.Vector3 vector)

This action computes the square of the distance between the calling vector and the passed vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 otherVector
vector:Set(2.0, 3.0, 4.0)
otherVector:Set(2.0, 5.0, 1.0)
number distanceSquared = vector:DistanceSquared(otherVector)
output "The square of the distance is " + distanceSquared
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

number: The square of the distance between the two vectors

### DistanceSquared(number xValue, number yValue, number zValue)

This action computes the square of the distance between the calling vector and the vector represented by the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 3.0, 4.0)
number distanceSquared = vector:DistanceSquared(2.0, 5.0, 1.0)
output "The square of the distance is " + distanceSquared
```

#### Parameters

- number xValue: The x component of the other vector
- number yValue: The y component of the other vector
- number zValue: The z component of the other vector

#### Return

number: The square of the distance between the two vectors

### DistanceSquared(number x1, number y1, number z1, number x2, number y2, number z2)

This action computes the square of the distance between the vectors represented by the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
number distanceSquared = vector:DistanceSquared(2.0, 3.0, 4.0, 2.0, 5.0, 1.0)
output "The square of the distance is " + distanceSquared
```

#### Parameters

- number x1: The x component of the first vector
- number y1: The y component of the first vector
- number z1: The z component of the first vector
- number x2: The x component of the second vector
- number y2: The y component of the second vector
- number z2: The z component of the second vector

#### Return

number: The square of the distance between the two vectors

### DotProduct(number x1, number y1, number z1, number x2, number y2, number z2)

This action computes the dot product of the two vectors given by the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
number dotProduct = vector:DotProduct(3.0, 4.0, 5.0, 5.0, 6.0, 7.0)
output "The dot product is " + dotProduct
```

#### Parameters

- number x1: The x component of the first vector
- number y1: The y component of the first vector
- number z1: The z component of the first vector
- number x2: The x component of the second vector
- number y2: The y component of the second vector
- number z2: The z component of the second vector

#### Return

number: The dot product of the two vectors.

### DotProduct(Libraries.Compute.Vector3 vector)

This action computes the dot product between the calling vector and the passed vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(5.0, 6.0, 7.0)
number dotProduct = firstVector:DotProduct(secondVector)
output "The dot product is " + dotProduct
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

number: The dot product of the two vectors

### DotProduct(number xValue, number yValue, number zValue)

This action computes the dot product between the calling vector and the vector with the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(3.0, 4.0, 5.0)
number dotProduct = vector:DotProduct(4.0, 5.0, 6.0)
output "The dot product is " + dotProduct
```

#### Parameters

- number xValue: The x component of the other vector
- number yValue: The y component of the other vector
- number zValue: The z component of the other vector

#### Return

number: The dot product of the two vectors

### Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

**Example Code**

```
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
```

#### Parameters

- Libraries.Language.Object: The to be compared.

#### Return

boolean: True if the hash codes are equal and false if they are not equal.

### Equals(Libraries.Compute.Vector3 vector)

This action determines whether the passed vector is equal to this vector. Two vectors are equal if they have the same x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(2.0, 3.0, 4.0)
secondVector:Set(2.0, 3.0, 4.0)
boolean areEqual = firstVector:Equals(secondVector)
if areEqual
output "The two vectors are equal."
else
output "The two vectors are not equal."
end
```

#### Parameters

- Libraries.Compute.Vector3: The vector to check if equal

#### Return

boolean: true if the two vectors are equal, false otherwise

### EqualsAtPrecision(Libraries.Compute.Vector3 other, number epsilon)

This action determines whether the passed vector equals the calling vector to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(6.0, 8.0, 10.0)
secondVector:Scale(0.5)
boolean areEqual = firstVector:EqualsAtPrecision(secondVector, 0.00001)
if areEqual
output "The two vectors are equal."
else
output "The two vectors are not equal."
end
```

#### Parameters

#### Return

boolean: true if the vectors are equal within the passed precision, false otherwise

### EqualsAtPrecision(number xVal, number yVal, number zVal, number precision)

This action determines whether the vector represented by the passed x, y, and z components equals the calling vector to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(3.0, 4.0, 7.5)
boolean areEqual = vector:EqualsAtPrecision(3.0, 4.0000001, 7.5000002, 0.00001)
if areEqual
output "The two vectors are equal."
else
output "The two vectors are not equal."
end
```

#### Parameters

- number precision: The desired precision

#### Return

boolean: true if the vectors are equal within the passed precision, false otherwise

### GetHashCode()

This action gets the hash code for an object.

**Example Code**

```
Object o
integer hash = o:GetHashCode()
```

#### Return

integer: The integer hash code of the object.

### GetX()

This action returns the x component of the vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(1, 2, 3)
number x = vector:GetX()
output "The x component is: " + x
```

#### Return

number: the x component of the vector

### GetY()

This action returns the y component of the vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(1, 2, 3)
number y = vector:GetY()
output "The y component is: " + y
```

#### Return

number: the y component of the vector

### GetZ()

This action returns the z component of the vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(1, 2, 3)
number z = vector:GetZ()
output "The z component is: " + z
```

#### Return

number: the z component of the vector

### HasOppositeDirection(Libraries.Compute.Vector3 vector)

This action determines whether the passed vector has the opposite direction as the calling vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(-3.0, -4.0, -5.0)
boolean isOpposite = firstVector:HasOppositeDirection(secondVector)
if isOpposite
output "The two vectors have opposite directions."
else
output "The two vectors do not have opposite directions."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the two vectors have the opposite direction, false otherwise

### HasSameDirection(Libraries.Compute.Vector3 vector)

This action determines whether the passed vector has the same direction as the calling vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(6.0, 8.0, 10.0)
boolean isSame = firstVector:HasSameDirection(secondVector)
if isSame
output "The two vectors have the same direction."
else
output "The two vectors do not have the same direction."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the two vectors have the same direction, false otherwise

### IsCollinear(Libraries.Compute.Vector3 other, number precision)

This action determines whether the passed vector is collinear with the calling vector, meaning that it lies on the same line as the calling vector and has the same direction as the calling vector to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(6.0, 8.0, 10.0)
boolean collinear = firstVector:IsCollinear(secondVector, 0.00001)
if collinear
output "The two vectors are collinear in the same direction"
else
output "The two vectors are not collinear in the same direction"
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector
- number precision: The desired precision

#### Return

boolean: true if the vectors are collinear, false otherwise.

### IsCollinear(Libraries.Compute.Vector3 other)

This action determines whether the passed vector is collinear with the calling vector, meaning that it lies on the same line as the calling vector and has the same direction as the calling vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(6.0, 8.0, 10.0)
boolean collinear = firstVector:IsCollinear(secondVector)
if collinear
output "The two vectors are collinear in the same direction"
else
output "The two vectors are not collinear in the same direction"
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the vectors are collinear, false otherwise.

### IsCollinearOpposite(Libraries.Compute.Vector3 other, number precision)

This action determines whether the passed vector is collinear in the opposite direction with the calling vector, meaning that it lies on the same line as the calling vector and has the opposite direction as the calling vector to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(-6.0, -8.0, -10.0)
boolean collinearOpposite = firstVector:IsCollinearOpposite(secondVector, 0.00001)
if collinearOpposite
output "The two vectors are collinear in the opposite direction"
else
output "The two vectors are not collinear in the opposite direction"
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector
- number precision: The desired precision

#### Return

boolean: true if the vectors are collinear in the opposite directions, false otherwise

### IsCollinearOpposite(Libraries.Compute.Vector3 other)

This action determines whether the passed vector is collinear in the opposite direction with the calling vector, meaning that it lies on the same line as the calling vector and has the opposite direction as the calling vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(3.0, 4.0, 5.0)
secondVector:Set(-6.0, -8.0, -10.0)
boolean collinearOpposite = firstVector:IsCollinearOpposite(secondVector)
if collinearOpposite
output "The two vectors are collinear in the opposite direction"
else
output "The two vectors are not collinear in the opposite direction"
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the vectors are collinear in the opposite directions, false otherwise

### IsOnLine(Libraries.Compute.Vector3 other)

This action determines whether the passed vector is on the same line as the calling vector, either in the same or opposite direction.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(1.0, 2.0, 3.0)
secondVector:Set(-2.0, -4.0, -6.0)
boolean onLine = firstVector:IsOnLine(secondVector)
if onLine
output "The two vectors are on the same line."
else
output "The two vectors are not on the same line."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the vectors are on the same line, false otherwise

### IsOnLine(Libraries.Compute.Vector3 other, number precision)

This action determines whether the passed vector is on the same line as the calling vector to within the passed precision, either in the same or opposite direction

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(1.0, 2.0, 3.0)
secondVector:Set(-2.0, -4.0, -6.0)
boolean onLine = firstVector:IsOnLine(secondVector, 0.00001)
if onLine
output "The two vectors are on the same line."
else
output "The two vectors are not on the same line."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector
- number precision: The desired precision

#### Return

boolean: true if the vectors are on the same line, false otherwise

### IsPerpendicular(Libraries.Compute.Vector3 vector)

This action determines whether the passed vector is perpendicular to the calling vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(1.0, 0.0, 0.0)
secondVector:Set(0.0, 1.0, 0.0)
boolean isPerpendicular = firstVector:IsPerpendicular(secondVector)
if isPerpendicular
output "The two vectors are perpendicular."
else
output "The two vectors are not perpendicular."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector

#### Return

boolean: true if the two vectors are perpendicular, false otherwise

### IsPerpendicular(Libraries.Compute.Vector3 vector, number precision)

This action determines whether the passed vector is perpendicular to the calling vector to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(1.0, 0.0, 0.0)
secondVector:Set(0.0, 1.0, 0.0)
boolean isPerpendicular = firstVector:IsPerpendicular(secondVector, 0.00001)
if isPerpendicular
output "The two vectors are perpendicular."
else
output "The two vectors are not perpendicular."
end
```

#### Parameters

- Libraries.Compute.Vector3: The other vector
- number precision: The desired precision

#### Return

boolean: true if the two vectors are perpendicular, false otherwise

### IsUnit()

This action determines whether the vector is a unit vector, meaning it has a length of 1.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(0.0, 1.0, 0.0)
boolean isUnit = vector:IsUnit()
if isUnit
output "The vector is a unit vector."
else
output "The vector is not a unit vector."
end
```

#### Return

boolean: true if the vector is a unit vector, false otherwise

### IsUnit(number precision)

This action determines whether the vector is a unit vector, meaning it has a length of 1 to within the passed precision.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(0.0, 1.0, 0.0)
boolean isUnit = vector:IsUnit(0.00001)
if isUnit
output "The vector is a unit vector."
else
output "The vector is not a unit vector."
end
```

#### Parameters

- number precision: The desired precision

#### Return

boolean: true if the vector is a unit vector to within the passed precision, false otherwise

### IsZero()

This action determines whether the vector is the zero vector, meaning that its x, y, and z components are 0.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(5.0, 6.0, 7.0)
secondVector:Set(5.0, 6.0, 7.0)
firstVector:Subtract(secondVector)
boolean isZero = firstVector:IsZero()
if isZero
output "The vector is the zero vector."
else
output "The vector is not the zero vector."
end
```

#### Return

boolean: true if the vector is the zero vector, false otherwise

### IsZero(number precision)

This action determines whether the vector is the zero vector to within the passed precision, meaning that its x, y, and z components are 0.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(5.0, 6.0, 7.0)
secondVector:Set(5.0, 6.0, 7.0)
firstVector:Subtract(secondVector)
boolean isZero = firstVector:IsZero(0.00001)
if isZero
output "The vector is the zero vector."
else
output "The vector is not the zero vector."
end
```

#### Parameters

- number precision: The desired precision

#### Return

boolean: true if the vector is the zero vector to within the passed precision, false otherwise

### Length(number x, number y, number z)

This action returns the length of the vector with the passed x, y, and z components measured from the origin (0, 0).

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
number length = vector:Length(1.0, 2.0, 2.0)
output "The length of the vector is " + length
```

#### Parameters

- number x: The x component of the vector
- number y: The y component of the vector
- number z: The z component of the vector

#### Return

number: The length of the vector

### Length()

This action returns the length of the vector measured from the origin (0, 0)

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(1.0, 2.0, 2.0)
number length = vector:Length()
output "The length of the vector is " + length
```

#### Return

number: the length of the calling vector

### LengthSquared()

This action returns the square of the length of the vector measured from the origin (0, 0).

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 1.0, 2.0)
number lengthSquared = vector:LengthSquared()
output "The square of the length of the vector is " + lengthSquared
```

#### Return

number: The square of the length of the calling vector

### LengthSquared(number x, number y, number z)

This action returns the square of the length of the vector with the passed x, y, and z components measured from the origin (0, 0).

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
number lengthSquared = vector:LengthSquared(1.0, 2.0, 2.0)
output "The square of the length of the vector is " + lengthSquared
```

#### Parameters

- number x: The x component of the vector
- number y: The y component of the vector
- number z: The z component of the vector

#### Return

number: The square of the length of the vector

### Limit(number limit)

This action limits the length of the vector to the passed limit value. This changes the calling vector to have a new length if its old length was greater than the passed limit.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 1.0, 2.0)
vector:Limit(1.5)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number limit: The value to limit the length to

#### Return

Libraries.Compute.Vector3: The vector with a new length if its old length was larger than the passed limit

### LimitSquared(number limitSquared)

This action limits the square of the length of the vector to the passed value, which represents the square of the value to limit the length of the vector to. This changes the calling vector to have a new length if the old length squared was greater than the limit squared.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 1.0, 2.0)
vector:LimitSquared(2.25)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number limitSquared: the square of the limit

#### Return

Libraries.Compute.Vector3: the calling vector with a new length if the old length squared was greater than the limit squared

### LinearInterpolation(Libraries.Compute.Vector3 target, number alpha)

This action performs a linear interpolation between the calling vector and the passed target vector by alpha, which is between 0 and 1, inclusive. This changes the calling vector to the result of the linear interpolation.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 target
vector:Set(1.0, 2.0, 1.0)
target:Set(2.0, 3.0, 1.0)
number alpha = 0.5
vector:LinearInterpolation(target, alpha)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The target vector
- number alpha: The alpha value

#### Return

Libraries.Compute.Vector3: The calling vector after linear interpolation

### Multiply(Libraries.Compute.Quaternion quaternion)

This action multiplies the vector by the passed quaternion.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Quaternion
Vector3 vector
Quaternion quaternion
vector:Set(3.0, 4.0, 7.0)
quaternion:Set(4.0, 3.0, 6.0, 6.0)
vector:Multiply(quaternion)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Quaternion: The Quaternion to multiply by

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### Multiply(Libraries.Compute.Matrix4 matrix)

This action multiplies the vector by a 4-by-4 matrix assuming the fourth w component of the vector is 1. This action is mainly used for game graphics.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
Vector3 vector
Matrix4 matrix
Array<number> values
integer i = 0
repeat 16 times
array:Add(i)
i = i + 1
end
matrix:Set(values)
vector:Multiply(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The matrix to multiply

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### Multiply(Libraries.Compute.Matrix3 matrix)

This action multiplies the vector by the passed 3-by-3 matrix and stores the result in the vector.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix3
use Libraries.Containers.Array
Vector3 vector
Matrix3 matrix
vector:Set(2.0, 3.0, 5.0)
Array<number> values
integer i = 0
repeat 9 times
values:Add(i)
i = i + 1
end
matrix:Set(values)
vector:Multiply(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix3: The matrix to multiply

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### MultiplyAndAdd(Libraries.Compute.Vector3 addVector, Libraries.Compute.Vector3 scaleVector)

This action multiplies the passed vector by the passed scalar vector and adds the result to the calling vector. This changes the calling vector to the result of the multiplication and addition.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 addVector
Vector3 scaleVector
vector:Set(4.0, 7.0, 5.0)
addVector:Set(2.0, 3.0, 1.0)
scaleVector:Set(3.0, 1.0, 2.0)
vector:MultiplyAndAdd(addVector, scaleVector)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The vector to multiply by the scale vector
- Libraries.Compute.Vector3: The vector to multiply the add vector by

#### Return

Libraries.Compute.Vector3: The calling vector after multiplication and addition

### MultiplyAndAdd(Libraries.Compute.Vector3 vector, number scalar)

This action multiplies the passed vector by the passed scalar and adds the result to the calling vector. This changes the calling vector to the result of the multiplication and addition.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 addVector
vector:Set(4.0, 7.0, 5.0)
addVector:Set(2.5, 1.5, 2.0)
vector:MultiplyAndAdd(addVector, 2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The vector to multiply by the scalar
- number scalar: The value to multiply the vector by

#### Return

Libraries.Compute.Vector3: The calling vector after multiplication and addition

### MultiplyBy4x3Matrix(Libraries.Containers.Array<number> matrix)

This action multiplies the vector by a 4-by-3 matrix and stores the result in the vector. This action is mainly used in graphics programming where the matrix is composed of a 3-by-3 matrix representing rotation and scale and a 1-by-3 matrix representing translation.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Containers.Array
Vector3 vector
vector:Set(3.0, 4.0, 2.0)
Array<number> matrix
matrix:Add(2.0)
matrix:Add(0.0)
matrix:Add(0.0)
matrix:Add(0.0)
matrix:Add(2.0)
matrix:Add(0.0)
matrix:Add(0.0)
matrix:Add(0.0)
matrix:Add(2.0)
matrix:Add(1.0)
matrix:Add(1.0)
matrix:Add(1.0)
vector:MultiplyBy4x3Matrix(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Containers.Array: The array representing the 4-by-3 matrix values

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### MultiplyByTranspose(Libraries.Compute.Matrix3 matrix)

This action multiplies the vector by the transpose of the passed 3-by-3 matrix and stores the result in the vector.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix3
use Libraries.Containers.Array
Vector3 vector
Matrix3 matrix
vector:Set(2.0, 3.0, 5.0)
Array<number> values
integer i = 0
repeat 9 times
values:Add(i)
i = i + 1
end
matrix:Set(values)
vector:MultiplyByTranspose(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix3: The matrix to multiply

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### MultiplyByTranspose(Libraries.Compute.Matrix4 matrix)

This action multiplies the vector by the transpose of the passed 4-by-4 matrix assuming the fourth w component of the vector is 1. This action is mainly used for game graphics.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
Vector3 vector
Matrix4 matrix
Array<number> values
integer i = 0
repeat 16 times
array:Add(i)
i = i + 1
end
matrix:Set(values)
vector:MultiplyByTranspose(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The matrix to multiply

#### Return

Libraries.Compute.Vector3: The vector after multiplication

### Normalize()

This action produces a normalized vector with the same direction as the original vector but with a length of 1. This action changes the calling vector to the normalized vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(23.4, 43.2, 45.6)
vector:Normalize()
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The normalized vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Return

Libraries.Compute.Vector3: the normalized vector with a length of 1

### Project(Libraries.Compute.Matrix4 matrix)

This action projects the vector via a perspective projection matrix. This is mainly useful for game graphics.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
Vector3 vector
Matrix4 matrix
Array<number> values
vector:Set(3.0, 4.0, 2.0)
values:Set(matrix:M00, 2 * 3 / (100 - 0))
values:Set(matrix:M01, 0)
values:Set(matrix:M02, (100 + 0) / (100 - 0))
values:Set(matrix:M03, 0)
values:Set(matrix:M10, 0)
values:Set(matrix:M11, 2 * 3 / (100 - 0))
values:Set(matrix:M12, (100 + 0) / (100 - 0))
values:Set(matrix:M13, 0)
values:Set(matrix:M20, 0)
values:Set(matrix:M21, 0)
values:Set(matrix:M22, -1 * (10 + 3) / (10 - 3))
values:Set(matrix:M23, -2 * 10 * 3 / (10 - 3))
values:Set(matrix:M30, 0)
values:Set(matrix:M31, 0)
values:Set(matrix:M32, -1)
values:Set(matrix:M33, 0)
matrix:Set(values)
vector:Project(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The perspective matrix

#### Return

Libraries.Compute.Vector3: The vector after projection

### Rotate(Libraries.Compute.Vector3 axis, number degrees)

This action rotates the vector the given number of degrees around the passed axis.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 axis
vector:Set(3.0, 2.0, 5.0)
axis:Set(1.0, 0.0, 0.0)
vector:Rotate(axis, 45)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The rotation axis
- number degrees: The rotation angle in degrees

#### Return

Libraries.Compute.Vector3: The vector after rotation

### Rotate(number degrees, number axisX, number axisY, number axisZ)

This action rotates the vector the given number of degrees around the axis with the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(3.0, 2.0, 5.0)
vector:Rotate(45, 1, 0, 0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number degrees: The rotation angle in degrees
- number axisX: The x component of the axis to rotate around
- number axisY: The y component of the axis to rotate around
- number axisZ: The z component of the axis to rotate around

#### Return

Libraries.Compute.Vector3: The vector after rotation

### Rotate(Libraries.Compute.Matrix4 matrix)

This action multiplies the vector by the first three columns of the passed matrix, effectively applying rotation and scaling to the vector. This action is mainly used in game graphics.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
use Libraries.Compute.Math
Math math
Vector3 vector
vector:Set(3, 2, 5)
Matrix4 matrix
Array<number> values
values:SetSize(16)
values:Set(matrix:M00, math:Cosine(math:pi / 4))
values:Set(matrix:M01, -1 * math:Sine(math:pi / 4))
values:Set(matrix:M02, 0)
values:Set(matrix:M03, 1)
values:Set(matrix:M10, math:Sine(math:pi / 4))
values:Set(matrix:M11, math:Cosine(math:pi / 4))
values:Set(matrix:M12, 0)
values:Set(matrix:M13, 1)
values:Set(matrix:M20, 0)
values:Set(matrix:M21, 0)
values:Set(matrix:M22, 1)
values:Set(matrix:M23, 1)
values:Set(matrix:M30, 1)
values:Set(matrix:M31, 1)
values:Set(matrix:M32, 1)
values:Set(matrix:M33, 1)
matrix:Set(values)
vector:Rotate(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The transformation matrix

#### Return

Libraries.Compute.Vector3: The vector after rotation

### RotateRadians(Libraries.Compute.Vector3 axis, number radians)

This action rotates the vector the given number of radians around the passed axis.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Math
Math math
Vector3 vector
Vector3 axis
vector:Set(3.0, 2.0, 5.0)
axis:Set(1.0, 0.0, 0.0)
vector:RotateRadians(axis, math:pi / 4)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The rotation axis
- number radians: The rotation angle in radians

#### Return

Libraries.Compute.Vector3: The vector after rotation

### RotateRadians(number radians, number axisX, number axisY, number axisZ)

This action rotates the vector the given number of radians around the axis with the passed x, y, and z components.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Math
Math math
Vector3 vector
vector:Set(3.0, 2.0, 5.0)
vector:RotateRadians(math:pi / 4, 1, 0, 0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number radians: The rotation angle in radians
- number axisX: The x component of the axis to rotate around
- number axisY: The y component of the axis to rotate around
- number axisZ: The z component of the axis to rotate around

#### Return

Libraries.Compute.Vector3: The vector after rotation

### Scale(Libraries.Compute.Vector3 vector)

This action scales the vector by multiplying the x component by the x component of the passed vector, the y component by the y component of the passed vector, and the z component by the z component of the passed vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 scaleVector
vector:Set(2.0, 3.0, 4.0)
scaleVector:Set(3.0, 4.0, 2.0)
vector:Scale(scaleVector)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The vector to scale by

#### Return

Libraries.Compute.Vector3: The calling vector

### Scale(number scalar)

This action scales the vector by multiplying the x, y, and z components by the passed scalar value.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 3.0, 4.0)
vector:Scale(2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number scalar: The scalar value to multiply by

#### Return

Libraries.Compute.Vector3: The calling vector

### Scale(number xValue, number yValue, number zValue)

This action scales the vector by multiplying the x component with the passed x value, the y component with the passed y value, and the z component with the passed z value.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(2.0, 3.0, 4.0)
vector:Scale(3.0, 4.0, 2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number xValue: The value to multiply the x component by
- number yValue: The value to multiply the y component by
- number zValue: The value to multiply the z component by

#### Return

Libraries.Compute.Vector3: The calling vector

### Set(number xValue, number yValue, number zValue)

This action sets the x, y, and z components of the vector to the passed x, y, and z values.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(8.8, 4.2, 9.2)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number xValue: the value to set as the x component
- number yValue: the value to set as the y component
- number zValue: the value to set as the z component

#### Return

Libraries.Compute.Vector3: the calling vector

### Set(Libraries.Containers.Array<number> array)

This action sets the x, y, and z components of the vector to the elements of the passed array. The x component is assigned the element at array position 0, the y component the element at array position 1, and the z component the element at array position 2.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Containers.Array
Vector3 vector
Array<number> array
array:Add(3.0)
array:Add(-4.5)
array:Add(5.2)
vector:Set(array)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Containers.Array: The array containing the numbers to assign as the x, y, and z components of the vector

#### Return

Libraries.Compute.Vector3: the calling vector

### Set(Libraries.Compute.Vector2 vector, number z)

This action sets the vector's x and y components to the x and y components of the passed 2D vector and sets the z component to the passed z value.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Vector2
Vector3 vector
Vector2 setVector
setVector:Set(3.5, -7.0)
vector:Set(setVector, 4.2)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector2: The 2D vector to set this vector's x and y components
- number z: The value to set the z component to

#### Return

Libraries.Compute.Vector3: The calling vector

### Set(Libraries.Compute.Vector3 vector)

This action sets the vector's components to the components of the passed vector.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
firstVector:Set(2.4, 4.3, 2.7)
Vector3 secondVector
secondVector:Set(firstVector)
number newX = secondVector:GetX()
number newY = secondVector:GetY()
number newZ = secondVector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: the vector to use to set the components

#### Return

Libraries.Compute.Vector3: the calling vector

### SetX(number newX)

This action sets the x component of the vector to the passed value.

#### Parameters

- number newX: The value to set as the x component

### SetY(number newY)

This action sets the y component of the vector to the passed value.

#### Parameters

- number newY: The value to set as the y component

### SetZ(number newZ)

This action sets the z component of the vector to the passed value.

#### Parameters

- number newZ: The value to set as the z component

### SetZero()

This action sets the vector to the zero vector, meaning the x, y, and z components will be set to 0.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:SetZero()
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Return

Libraries.Compute.Vector3: The calling vector set to the zero vector

### SphericalLinearInterpolation(Libraries.Compute.Vector3 target, number alpha)

This action performs a spherical interpolation between the calling vector and the passed target vector by alpha, which is between 0 and 1, inclusive. This changes the calling vector to the result of the spherical linear interpolation.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
Vector3 target
vector:Set(0.4, 0.3, 0.2)
target:Set(0.1, 0.2, 0.3)
alpha = 0.5
vector:SphericalLinearInterpolation(target, alpha)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The target vector
- number alpha: The alpha value

#### Return

Libraries.Compute.Vector3: The calling vector after spherical linear interpolation

### Subtract(number value)

This action subtracts the passed value from the x, y, and z components of the vector. This changes the vector to the result of the subtraction.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(3.5, 5,0, 3.1)
vector:Subtract(2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number value: The value to subtract from the x, y, and z components

#### Return

Libraries.Compute.Vector3: The vector after subtraction

### Subtract(number xValue, number yValue, number zValue)

This action subtracts a vector with the passed components from the calling vector. This action changes the calling vector to the result of the subtraction.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 vector
vector:Set(9.0, 8.0, 7.0)
vector:Subtract(6.0, 5.0, 4.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- number xValue: The x component of the vector to subtract
- number yValue: The y component of the vector to subtract
- number zValue: The z component of the vector to subtract

#### Return

Libraries.Compute.Vector3: The calling vector after subtraction

### Subtract(Libraries.Compute.Vector3 vector)

This action subtracts the passed vector from the calling vector. This changes the calling vector to the result of the subtraction.

**Example Code**

```
use Libraries.Compute.Vector3
Vector3 firstVector
Vector3 secondVector
firstVector:Set(9.0, 8.0, 7.0)
secondVector:Set(6.0, 5.0, 4.0)
firstVector:Subtract(secondVector)
number newX = firstVector:GetX()
number newY = firstVector:GetY()
number newZ = firstVector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Vector3: The vector to subtract

#### Return

Libraries.Compute.Vector3: The calling vector after subtraction

### Unrotate(Libraries.Compute.Matrix4 matrix)

This action multiplies the vector by the first three columns of the transpose of the passed matrix, effectively undoing any rotation and translation of the vector.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
use Libraries.Compute.Math
Math math
Vector3 vector
vector:Set(3, 2, 5)
Matrix4 matrix
Array<number> values
values:SetSize(16)
values:Set(matrix:M00, math:Cosine(math:pi / 4))
values:Set(matrix:M01, -1 * math:Sine(math:pi / 4))
values:Set(matrix:M02, 0)
values:Set(matrix:M03, 1)
values:Set(matrix:M10, math:Sine(math:pi / 4))
values:Set(matrix:M11, math:Cosine(math:pi / 4))
values:Set(matrix:M12, 0)
values:Set(matrix:M13, 1)
values:Set(matrix:M20, 0)
values:Set(matrix:M21, 0)
values:Set(matrix:M22, 1)
values:Set(matrix:M23, 1)
values:Set(matrix:M30, 1)
values:Set(matrix:M31, 1)
values:Set(matrix:M32, 1)
values:Set(matrix:M33, 1)
matrix:Set(values)
vector:Rotate(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
vector:Unrotate(matrix)
newX = vector:GetX()
newY = vector:GetY()
newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The transformation matrix

#### Return

Libraries.Compute.Vector3: The vector after unrotating

### Untransform(Libraries.Compute.Matrix4 matrix)

This action translates the vector in the direction opposite from the translation of the matrix and then multiplies the vector by the first three columns of the matrix. This undoes the translations and rotations applied to the vector.

**Example Code**

```
use Libraries.Compute.Vector3
use Libraries.Compute.Matrix4
use Libraries.Containers.Array
Vector3 vector
Matrix4 matrix
Array<number> values
vector:Set(3.0, 4.0, 2.0)
values:Set(matrix:M00, 2 * 3 / (100 - 0))
values:Set(matrix:M01, 0)
values:Set(matrix:M02, (100 + 0) / (100 - 0))
values:Set(matrix:M03, 0)
values:Set(matrix:M10, 0)
values:Set(matrix:M11, 2 * 3 / (100 - 0))
values:Set(matrix:M12, (100 + 0) / (100 - 0))
values:Set(matrix:M13, 0)
values:Set(matrix:M20, 0)
values:Set(matrix:M21, 0)
values:Set(matrix:M22, -1 * (10 + 3) / (10 - 3))
values:Set(matrix:M23, -2 * 10 * 3 / (10 - 3))
values:Set(matrix:M30, 0)
values:Set(matrix:M31, 0)
values:Set(matrix:M32, -1)
values:Set(matrix:M33, 0)
matrix:Set(values)
vector:Project(matrix)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + "]"
```

#### Parameters

- Libraries.Compute.Matrix4: The transformation matrix

#### Return

Libraries.Compute.Vector3: The vector after untransforming