Libraries.Compute.Vector4 Documentation
Vector4 is a class representing a vector in 3D space. It may be used for operations like 3D color with an alpha component.
Example Code
use Libraries.Compute.Vector4
Vector4 vector1
Vector4 vector2
vector1:Set(2, 6, 9, 3)
vector2:Set(1, 7, 2, 3)
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
Actions Documentation
Add(number value)
This action adds the passed value to the x, y, z, and w components of the vector. This changes the vector to the result of the addition.
Parameters
- number value: The value to add to the x, y, and z components
Return
Libraries.Compute.Vector4: The vector after addition
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(3.5, 5.0, 3.1, 1.0)
vector:Add(4.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Add(number xValue, number yValue, number zValue, number wValue)
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.
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
- number wValue: The w component of the vector to add
Return
Libraries.Compute.Vector4: The calling vector after addition
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(4.3, 8.1, 6.6, 1.0)
vector:Add(3.3, 9.2, -4.3, 1.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = copyVector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Add(Libraries.Compute.Vector4 vector)
This action adds the passed vector to the calling vector. This action changes the calling vector to the result of the addition.
Parameters
- Libraries.Compute.Vector4: The vector to add
Return
Libraries.Compute.Vector4: The calling vector after addition
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(3.2, 5.5, 9.0, 1.0)
secondVector:Set(8.3, 4.2, -7.3, 1.0)
firstVector:Add(secondVector)
number newX = firstVector:GetX()
number newY = firstVector:GetY()
number newZ = firstVector:GetZ()
number newW = copyVector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
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.
Parameters
- number min: The minimum length
- number max: The maximum length
Return
Libraries.Compute.Vector4: The vector with a new length if the old length was below the minimum or above the maximum
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 1.0, 2.0, 3.0)
vector:Clamp(0.5, 1.5)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Copy()
This action returns a copy of the current vector. The new vector's x, y, z, and w components are the same as the calling vector's x, y, z, and w components.
Return
Libraries.Compute.Vector4: a new vector that is a copy of the calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(4.8, 3.2, -4.2, 1.0)
Vector4 copyVector
copyVector = vector:Copy()
number newX = copyVector:GetX()
number newY = copyVector:GetY()
number newZ = copyVector:GetZ()
number newW = copyVector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Distance(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
This action computes the distance between the vectors represented by the passed x, y, z, and w components.
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 w1: The w 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
- number w2: The 2 component of the second vector
Return
number: The distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
number distance = vector:Distance(2.0, 3.0, 4.0, 2.0, 5.0, 1.0)
output "The distance is " + distance
Distance(number xValue, number yValue, number zValue, number wValue)
This action computes the distance between the calling vector and the vector represented by the passed x, y, and z components.
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
- number wValue: The w component of the other vector
Return
number: The distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 3.0, 4.0, 5.0)
number distance = vector:Distance(2.0, 5.0, 1.0, 0.0)
output "The distance is " + distance
Distance(Libraries.Compute.Vector4 vector)
This action computes the distance between the calling vector and the passed vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
number: The distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 otherVector
vector:Set(2.0, 3.0, 4.0, 5.0)
otherVector:Set(2.0, 5.0, 1.0, 5.0)
number distance = vector:Distance(otherVector)
output "The distance is " + distance
DistanceSquared(number xValue, number yValue, number zValue, number wValue)
This action computes the square of the distance between the calling vector and the vector represented by the passed x, y, z, and w components.
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
- number wValue: The w component of the other vector
Return
number: The square of the distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 3.0, 4.0, 5.0)
number distanceSquared = vector:DistanceSquared(2.0, 5.0, 1.0, 0.0)
output "The square of the distance is " + distanceSquared
DistanceSquared(Libraries.Compute.Vector4 vector)
This action computes the square of the distance between the calling vector and the passed vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
number: The square of the distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 otherVector
vector:Set(2.0, 3.0, 4.0, 5.0)
otherVector:Set(2.0, 5.0, 1.0, 0.0)
number distanceSquared = vector:DistanceSquared(otherVector)
output "The square of the distance is " + distanceSquared
DistanceSquared(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
This action computes the square of the distance between the vectors represented by the passed x, y, and z components.
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 w1: The w 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
- number w2: The w component of the second vector
Return
number: The square of the distance between the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
number distanceSquared = vector:DistanceSquared(2.0, 3.0, 4.0, 5.0, 2.0, 5.0, 1.0, 0.0)
output "The square of the distance is " + distanceSquared
DotProduct(number xValue, number yValue, number zValue, number wValue)
This action computes the dot product between the calling vector and the vector with the passed x, y, z, and w components.
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
- number wValue: The w component of the other vector
Return
number: The dot product of the two vectors
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(3.0, 4.0, 5.0, 1.0)
number dotProduct = vector:DotProduct(4.0, 5.0, 6.0, 2.0)
output "The dot product is " + dotProduct
DotProduct(Libraries.Compute.Vector4 vector)
This action computes the dot product between the calling vector and the passed vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
number: The dot product of the two vectors
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(3.0, 4.0, 5.0, 2.0)
secondVector:Set(5.0, 6.0, 7.0, 2.0)
number dotProduct = firstVector:DotProduct(secondVector)
output "The dot product is " + dotProduct
DotProduct(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
This action computes the dot product of the two vectors given by the passed x, y, and z components.
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 w1: The w 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
- number w2: The w component of the second vector
Return
number: The dot product of the two vectors.
Example
use Libraries.Compute.Vector4
Vector4 vector
number dotProduct = vector:DotProduct(3.0, 4.0, 5.0, 6.0. 5.0, 6.0, 7.0, 8.0)
output "The dot product is " + dotProduct
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Equals(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The vector to check if equal
Return
boolean: true if the two vectors are equal, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(2.0, 3.0, 4.0, 1.0)
secondVector:Set(2.0, 3.0, 4.0, 1.0)
boolean areEqual = firstVector:Equals(secondVector)
if areEqual
output "The two vectors are equal."
else
output "The two vectors are not equal."
end
EqualsAtPrecision(number xVal, number yVal, number zVal, number wVal, number precision)
This action determines whether the vector represented by the passed x, y, z, and w components equals the calling vector to within the passed precision.
Parameters
- number xVal
- number yVal
- number zVal
- number wVal
- number precision: The desired precision
Return
boolean: true if the vectors are equal within the passed precision, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(3.0, 4.0, 7.5, 9.0)
boolean areEqual = vector:EqualsAtPrecision(3.0, 4.0000001, 7.5000002, 9.00000001, 0.00001)
if areEqual
output "The two vectors are equal."
else
output "The two vectors are not equal."
end
EqualsAtPrecision(Libraries.Compute.Vector4 other, number epsilon)
This action determines whether the passed vector equals the calling vector to within the passed precision.
Parameters
- Libraries.Compute.Vector4
- number epsilon
Return
boolean: true if the vectors are equal within the passed precision, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(3.0, 4.0, 5.0, 6.0)
secondVector:Set(6.0, 8.0, 10.0, 12.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
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetW()
This action returns the w component of the vector. The w component is the 4th item (past x, y, and z).
Return
number: the z component of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(1, 2, 3, 4)
number w = vector:GetW()
output "The w component is: " + w
GetX()
This action returns the x component of the vector.
Return
number: the x component of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(1, 2, 3, 4)
number x = vector:GetX()
output "The x component is: " + x
GetY()
This action returns the y component of the vector.
Return
number: the y component of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(1, 2, 3, 4)
number y = vector:GetY()
output "The y component is: " + y
GetZ()
This action returns the z component of the vector.
Return
number: the z component of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(1, 2, 3)
number z = vector:GetZ()
output "The z component is: " + z
HasOppositeDirection(Libraries.Compute.Vector4 vector)
This action determines whether the passed vector has the opposite direction as the calling vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the two vectors have the opposite direction, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(3.0, 4.0, 5.0, 6.0)
secondVector:Set(-3.0, -4.0, -5.0, -6.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
HasSameDirection(Libraries.Compute.Vector4 vector)
This action determines whether the passed vector has the same direction as the calling vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the two vectors have the same direction, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(3.0, 4.0, 5.0, 4.0)
secondVector:Set(6.0, 8.0, 10.0, 12.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
IsCollinear(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The other vector
- number precision: The desired precision
Return
boolean: true if the vectors are collinear, false otherwise.
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 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
IsCollinear(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the vectors are collinear, false otherwise.
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 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
IsCollinearOpposite(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The other vector
- number precision: The desired precision
Return
boolean: true if the vectors are collinear in the opposite directions, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 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
IsCollinearOpposite(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the vectors are collinear in the opposite directions, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 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
IsOnLine(Libraries.Compute.Vector4 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
Parameters
- Libraries.Compute.Vector4: The other vector
- number precision: The desired precision
Return
boolean: true if the vectors are on the same line, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(1.0, 2.0, 3.0, 4.0)
secondVector:Set(-2.0, -4.0, -6.0, -8.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
IsOnLine(Libraries.Compute.Vector4 other)
This action determines whether the passed vector is on the same line as the calling vector, either in the same or opposite direction.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the vectors are on the same line, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 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
IsPerpendicular(Libraries.Compute.Vector4 vector)
This action determines whether the passed vector is perpendicular to the calling vector.
Parameters
- Libraries.Compute.Vector4: The other vector
Return
boolean: true if the two vectors are perpendicular, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(1.0, 0.0, 0.0, 0.0)
secondVector:Set(0.0, 1.0, 0.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
IsPerpendicular(Libraries.Compute.Vector4 vector, number precision)
This action determines whether the passed vector is perpendicular to the calling vector to within the passed precision.
Parameters
- Libraries.Compute.Vector4: The other vector
- number precision: The desired precision
Return
boolean: true if the two vectors are perpendicular, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(1.0, 0.0, 0.0, 0.0)
secondVector:Set(0.0, 1.0, 0.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
IsUnit()
This action determines whether the vector is a unit vector, meaning it has a length of 1.
Return
boolean: true if the vector is a unit vector, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(0.0, 1.0, 0.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
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.
Parameters
- number precision: The desired precision
Return
boolean: true if the vector is a unit vector to within the passed precision, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(0.0, 1.0, 0.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
IsZero()
This action determines whether the vector is the zero vector, meaning that its x, y, z, and w components are 0.
Return
boolean: true if the vector is the zero vector, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(5.0, 6.0, 7.0, 8.0)
secondVector:Set(5.0, 6.0, 7.0, 8.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
IsZero(number precision)
This action determines whether the vector is the zero vector to within the passed precision, meaning that its x, y, z, and w components are 0.
Parameters
- number precision: The desired precision
Return
boolean: true if the vector is the zero vector to within the passed precision, false otherwise
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(5.0, 6.0, 7.0, 8.0)
secondVector:Set(5.0, 6.0, 7.0, 8.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
Length(number x, number y, number z, number w)
This action returns the length of the vector with the passed x, y, and z components measured from the origin (0, 0).
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
- number w: The w component of the vector
Return
number: The length of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
number length = vector:Length(1.0, 2.0, 2.0, 3.0)
output "The length of the vector is " + length
Length()
This action returns the length of the vector measured from the origin (0, 0)
Return
number: the length of the calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(1.0, 2.0, 2.0, 3.0)
number length = vector:Length()
output "The length of the vector is " + length
LengthSquared()
This action returns the square of the length of the vector measured from the origin (0, 0).
Return
number: The square of the length of the calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 1.0, 2.0, 3.0)
number lengthSquared = vector:LengthSquared()
output "The square of the length of the vector is " + lengthSquared
LengthSquared(number x, number y, number z, number w)
This action returns the square of the length of the vector with the passed x, y, z, and w components measured from the origin (0, 0).
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
- number w: The z component of the vector
Return
number: The square of the length of the vector
Example
use Libraries.Compute.Vector4
Vector4 vector
number lengthSquared = vector:LengthSquared(1.0, 2.0, 2.0, 3.0)
output "The square of the length of the vector is " + lengthSquared
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.
Parameters
- number limit: The value to limit the length to
Return
Libraries.Compute.Vector4: The vector with a new length if its old length was larger than the passed limit
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 1.0, 2.0, 1.0)
vector:Limit(1.5)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
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.
Parameters
- number limitSquared: the square of the limit
Return
Libraries.Compute.Vector4: the calling vector with a new length if the old length squared was greater than the limit squared
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 1.0, 2.0, 1.0)
vector:LimitSquared(2.25)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
LinearInterpolation(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The target vector
- number alpha: The alpha value
Return
Libraries.Compute.Vector4: The calling vector after linear interpolation
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 target
vector:Set(1.0, 2.0, 1.0, 0.0)
target:Set(2.0, 3.0, 1.0, 0.0)
number alpha = 0.5
vector:LinearInterpolation(target, alpha)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW"]"
MakeOpposite()
This action makes the current vector point in the opposite direction by negating all of its components.
MultiplyAndAdd(Libraries.Compute.Vector4 addVector, Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The vector to multiply by the scale vector
- Libraries.Compute.Vector4: The vector to multiply the add vector by
Return
Libraries.Compute.Vector4: The calling vector after multiplication and addition
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 addVector
Vector4 scaleVector
vector:Set(4.0, 7.0, 5.0, 1.0)
addVector:Set(2.0, 3.0, 1.0, 0.0)
scaleVector:Set(3.0, 1.0, 2.0, 4.0)
vector:MultiplyAndAdd(addVector, scaleVector)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
MultiplyAndAdd(Libraries.Compute.Vector4 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.
Parameters
- Libraries.Compute.Vector4: The vector to multiply by the scalar
- number scalar: The value to multiply the vector by
Return
Libraries.Compute.Vector4: The calling vector after multiplication and addition
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 addVector
vector:Set(4.0, 7.0, 5.0, 4.0)
addVector:Set(2.5, 1.5, 2.0, 1.0)
vector:MultiplyAndAdd(addVector, 2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
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.
Return
Libraries.Compute.Vector4: the normalized vector with a length of 1
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(23.4, 43.2, 45.6, 57.9)
vector:Normalize()
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The normalized vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Output()
Scale(Libraries.Compute.Vector4 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, the z component by the z component, and the w component by the w component.
Parameters
- Libraries.Compute.Vector4: The vector to scale by
Return
Libraries.Compute.Vector4: The calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
Vector4 scaleVector
vector:Set(2.0, 3.0, 4.0, 5.0)
scaleVector:Set(3.0, 4.0, 2.0, 1.0)
vector:Scale(scaleVector)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Scale(number xValue, number yValue, number zValue, number wValue)
This action scales the vector by multiplying the x component with the passed x value, the y component with the passed y value, the z component with the passed z value, and the w component with the passed w component.
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
- number wValue: The value to multiply the w component by
Return
Libraries.Compute.Vector4: The calling vector
Example
use Libraries.Compute.Vector4
Vector4 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()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Scale(number scalar)
This action scales the vector by multiplying the x, y, and z components by the passed scalar value.
Parameters
- number scalar: The scalar value to multiply by
Return
Libraries.Compute.Vector4: The calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(2.0, 3.0, 4.0, 5.0)
vector:Scale(2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Set(Libraries.Compute.Vector2 vector, number z, number w)
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.
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
- number w
Return
Libraries.Compute.Vector4: The calling vector
Example
use Libraries.Compute.Vector4
use Libraries.Compute.Vector2
Vector4 vector
Vector2 setVector
setVector:Set(3.5, -7.0)
vector:Set(setVector, 4.2, 1.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Set(Libraries.Containers.Array<number> array)
This action sets the x, y, z, and w 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. The w component is position 3.
Parameters
- Libraries.Containers.Array: The array containing the numbers to assign as the x, y, z, and alpha components of the vector
Return
Libraries.Compute.Vector4: the calling vector
Example
use Libraries.Compute.Vector4
use Libraries.Containers.Array
Vector4 vector
Array<number> array
array:Add(3.0)
array:Add(-4.5)
array:Add(5.2)
array:Add(1.0)
vector:Set(array)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Set(number xValue, number yValue, number zValue, number wValue)
This action sets the x, y, z, and w components of the vector to the passed x, y, z and w values. The w component is the last number in the vector.
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
- number wValue: the value to set as the w component
Return
Libraries.Compute.Vector4: the calling vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(8.8, 4.2, 9.2, 1.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW"]"
Set(Libraries.Compute.Vector4 vector)
This action sets the vector's components to the components of the passed vector.
Parameters
- Libraries.Compute.Vector4: the vector to use to set the components
Return
Libraries.Compute.Vector4: the calling vector
Example
use Libraries.Compute.Vector4
Vector4 firstVector
firstVector:Set(2.4, 4.3, 2.7, 1.0)
Vector4 secondVector
secondVector:Set(firstVector)
number newX = secondVector:GetX()
number newY = secondVector:GetY()
number newZ = secondVector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
SetW(number newW)
This action sets the w component of the vector to the passed value. The w component is the last item, past x, y, and z.
Parameters
- number newW: The value to set as the z component
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, z, and w components will be set to 0.
Return
Libraries.Compute.Vector4: The calling vector set to the zero vector
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:SetZero()
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Subtract(number xValue, number yValue, number zValue, number wValue)
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.
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
- number wValue: The w component of the vector to subtract
Return
Libraries.Compute.Vector4: The calling vector after subtraction
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(9.0, 8.0, 7.0, 1.0)
vector:Subtract(6.0, 5.0, 4.0, 1.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Subtract(number value)
This action subtracts the passed value from the x, y, z, and w components of the vector. This changes the vector to the result of the subtraction.
Parameters
- number value: The value to subtract from the x, y, and z components
Return
Libraries.Compute.Vector4: The vector after subtraction
Example
use Libraries.Compute.Vector4
Vector4 vector
vector:Set(3.5, 5,0, 3.1, 1.0)
vector:Subtract(2.0)
number newX = vector:GetX()
number newY = vector:GetY()
number newZ = vector:GetZ()
number newW = vector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
Subtract(Libraries.Compute.Vector4 vector)
This action subtracts the passed vector from the calling vector. This changes the calling vector to the result of the subtraction.
Parameters
- Libraries.Compute.Vector4: The vector to subtract
Return
Libraries.Compute.Vector4: The calling vector after subtraction
Example
use Libraries.Compute.Vector4
Vector4 firstVector
Vector4 secondVector
firstVector:Set(9.0, 8.0, 7.0, 1.0)
secondVector:Set(6.0, 5.0, 4.0, 1.0)
firstVector:Subtract(secondVector)
number newX = firstVector:GetX()
number newY = firstVector:GetY()
number newZ = firstVector:GetZ()
number newW = firstVector:GetW()
output "The new vector is: [" + newX + ", " + newY + ", " + newZ + ", " + newW + "]"
On this page
Variables TableAction Documentation- Add(number value)
- Add(number xValue, number yValue, number zValue, number wValue)
- Add(Libraries.Compute.Vector4 vector)
- Clamp(number min, number max)
- Compare(Libraries.Language.Object object)
- Copy()
- Distance(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
- Distance(number xValue, number yValue, number zValue, number wValue)
- Distance(Libraries.Compute.Vector4 vector)
- DistanceSquared(number xValue, number yValue, number zValue, number wValue)
- DistanceSquared(Libraries.Compute.Vector4 vector)
- DistanceSquared(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
- DotProduct(number xValue, number yValue, number zValue, number wValue)
- DotProduct(Libraries.Compute.Vector4 vector)
- DotProduct(number x1, number y1, number z1, number w1, number x2, number y2, number z2, number w2)
- Equals(Libraries.Language.Object object)
- Equals(Libraries.Compute.Vector4 vector)
- EqualsAtPrecision(number xVal, number yVal, number zVal, number wVal, number precision)
- EqualsAtPrecision(Libraries.Compute.Vector4 other, number epsilon)
- GetHashCode()
- GetW()
- GetX()
- GetY()
- GetZ()
- HasOppositeDirection(Libraries.Compute.Vector4 vector)
- HasSameDirection(Libraries.Compute.Vector4 vector)
- IsCollinear(Libraries.Compute.Vector4 other, number precision)
- IsCollinear(Libraries.Compute.Vector4 other)
- IsCollinearOpposite(Libraries.Compute.Vector4 other, number precision)
- IsCollinearOpposite(Libraries.Compute.Vector4 other)
- IsOnLine(Libraries.Compute.Vector4 other, number precision)
- IsOnLine(Libraries.Compute.Vector4 other)
- IsPerpendicular(Libraries.Compute.Vector4 vector)
- IsPerpendicular(Libraries.Compute.Vector4 vector, number precision)
- IsUnit()
- IsUnit(number precision)
- IsZero()
- IsZero(number precision)
- Length(number x, number y, number z, number w)
- Length()
- LengthSquared()
- LengthSquared(number x, number y, number z, number w)
- Limit(number limit)
- LimitSquared(number limitSquared)
- LinearInterpolation(Libraries.Compute.Vector4 target, number alpha)
- MakeOpposite()
- MultiplyAndAdd(Libraries.Compute.Vector4 addVector, Libraries.Compute.Vector4 scaleVector)
- MultiplyAndAdd(Libraries.Compute.Vector4 vector, number scalar)
- Normalize()
- Output()
- Scale(Libraries.Compute.Vector4 vector)
- Scale(number xValue, number yValue, number zValue, number wValue)
- Scale(number scalar)
- Set(Libraries.Compute.Vector2 vector, number z, number w)
- Set(Libraries.Containers.Array
array) - Set(number xValue, number yValue, number zValue, number wValue)
- Set(Libraries.Compute.Vector4 vector)
- SetW(number newW)
- SetX(number newX)
- SetY(number newY)
- SetZ(number newZ)
- SetZero()
- Subtract(number xValue, number yValue, number zValue, number wValue)
- Subtract(number value)
- Subtract(Libraries.Compute.Vector4 vector)
