![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
A 4-component vector class.
Enumeration of the components raw data index. The components can be accessed by using the [] operator.
Murl.Math.Vector.X | The index to the X component. |
Murl.Math.Vector.Y | The index to the Y component. |
Murl.Math.Vector.Z | The index to the Z component. |
Murl.Math.Vector.W | The index to the W component. |
Murl.Math.Vector.NUM_COMPONENTS | The number of components. |
Enumeration of the components' bit masks
Murl.Math.Vector.MASK_NONE | No component |
Murl.Math.Vector.MASK_X | X component mask |
Murl.Math.Vector.MASK_Y | Y component mask |
Murl.Math.Vector.MASK_Z | Z component mask |
Murl.Math.Vector.MASK_W | W component mask |
Murl.Math.Vector.MASK_XY | Component mask for X and Y |
Murl.Math.Vector.MASK_XZ | Component mask for X and Z |
Murl.Math.Vector.MASK_YZ | Component mask for Y and Z |
Murl.Math.Vector.MASK_XYZ | Component mask for X, Y and Z |
Murl.Math.Vector.MASK_ALL | All components |
Enumeration of the predefined initialization types for constructing a Vector(PredefinedType type).
Murl.Math.Vector.ZERO_DIRECTION | Initialize with zero direction {0, 0, 0, 0}. |
Murl.Math.Vector.ZERO_POSITION | Initialize with zero position {0, 0, 0, 1}. |
Murl.Math.Vector.UNINITIALIZED | Create an uninitialized instance. |
The default constructor.
Murl.Math.Vector new()
Constructor to create a vector from a predefined type.
Murl.Math.Vector new(Murl.Math.Vector.PredefinedType type)
type | The predefined type. |
Constructor to initialize a vector with given component values.
Murl.Math.Vector new(Number vx, Number vy, Number vz, Number vw)
vx | The x component. |
vy | The y component. |
vz | The z component. |
vw | The w component. |
Constructor to initialize an axis/angle vector from a quaternion.
Murl.Math.Vector new(Murl.Math.Quaternion q)
q | The quaternion. |
Clear all components of the vector instance. Set all components to default constructor of data type.
Clear()
Set all components of the vector instance to a given value.
Set(Number v)
v | The value to set. |
Set all components of the vector instance to a set of given component values.
Set(Number vx, Number vy, Number vz, Number vw)
vx | The x-component value to set. |
vy | The y-component value to set. |
vz | The z-component value to set. |
vw | The w-component value to set. |
Convert a given quaternion to an axis/angle vector.
Set(Murl.Math.Quaternion q)
q | The quaternion to convert from. |
Copy the content of a source vector to the vector instance.
Set(Murl.Math.Vector v)
v | The vector to copy from. |
In-place addition.
AddSelf(Murl.Math.Vector v)
v | The vector to add. |
In-place subtraction.
SubtractSelf(Murl.Math.Vector v)
v | The vector to subtract. |
In-place multiplication (scaling).
MultiplySelf(Number v)
v | The value to multiply. |
In-place component-wise multiplication.
MultiplySelf(Murl.Math.Vector v)
v | The vector to multiply. |
In-place division (inverse scaling).
DivideSelf(Number v)
v | The value to divide. |
In-place component-wise division.
DivideSelf(Murl.Math.Vector v)
v | The vector to divide. |
In-place cross product.
CrossSelf(Murl.Math.Vector v)
v | The vector to cross. |
In-place linear interpolation. Interpolation along a straight line between the vector instance (first vector) and a given second vector. For t=0.0, the result equals the first vector and for t=1.0 the second one.
InterpolateSelf(Murl.Math.Vector v, Number t)
v | The vector to interpolate. |
t | The distance for interplation. |
In-place projection of a given second vector. Project the given second vector onto the vector instance (first vector). The first vector gets normalized and then multiplied by the length retrieved from a dot-product multiplication between the two vectors (i.e. the vector instance retains its direction, but retrieves the length of the projection).
ProjectSelf(Murl.Math.Vector v)
v | The vector to project from. |
In-place set each component to the minimum from the vector instance and a given second vector.
MinSelf(Murl.Math.Vector v)
v | The vector to evaluate the minimum from. |
In-place set each component to the maximum from the vector instance and a given second vector.
MaxSelf(Murl.Math.Vector v)
v | The vector to evaluate the maximum from. |
In-place clamp each component to the value range given by the min and max vector parameters.
ClampSelf(Murl.Math.Vector min, Murl.Math.Vector max)
min | The component-wise minimum to clamp to. |
max | The component-wise maximum to clamp to. |
Rescale the vector to a length below or equal a given minimum. See MinLength().
MinLengthSelf(Number v)
v | The minimum length. |
Rescale the vector to a length above or equal a given maximum. See MaxLength().
MaxLengthSelf(Number v)
v | The maximum length. |
Clamp the vector to a length within a given range. See ClampLength().
ClampLengthSelf(Number min, Number max)
min | The minimum length. |
max | The maximum length. |
Set all vector components to their absolute value.
AbsSelf()
Set all vector components to either -1, 0 or +1 depending on their sign.
SgnSelf()
In-place inversion (negation) of the vector instance.
InvertSelf()
In-place normalization of the vector instance. Normalization retains the direction and sets the length to 1.0.
NormalizeSelf()
In-place normalization of the x, y and z components. Calculates the normalization without touching the w component, for normalizing the axis of an axis/angle representation.
NormalizeAxisSelf()
Get the addition of a vector.
Murl.Math.Vector Add(Murl.Math.Vector v)
v | The vector to add. |
Get the subtraction of a vector.
Murl.Math.Vector Subtract(Murl.Math.Vector v)
v | The vector to subtract. |
Get the multiplication (scaling).
Murl.Math.Vector Multiply(Number v)
v | The value to multiply. |
Get the multiplication with a quaternion.
Murl.Math.Quaternion Multiply(Murl.Math.Quaternion q)
q | The quaternion to multiply. |
Get the component-wise multiplication.
Murl.Math.Vector Multiply(Murl.Math.Vector v)
v | The vector to multiply. |
Get the division (inverse scaling).
Murl.Math.Vector Divide(Number v)
v | The value to divide. |
Get the component-wise division
Murl.Math.Vector Divide(Murl.Math.Vector v)
v | The vector to divide. |
Get the cross product.
Murl.Math.Vector Cross(Murl.Math.Vector v)
v | The vector to cross. |
Get the linear interpolation. Interpolation along a straight line between the vector instance (first vector) and a given second vector. For t=0.0, the result equals the first vector and for t=1.0 the second one.
Murl.Math.Vector Interpolate(Murl.Math.Vector v, Number t)
v | The vector to interpolate. |
t | The interpolation factor. |
Get the projection of a given second vector. Project the given second vector onto the vector instance (first vector). The first vector gets normalized and then multiplied by the length retrieved from a dot-product multiplication between the two vectors (i.e. the vector instance retains its direction, but retrieves the length of the projection).
Murl.Math.Vector Project(Murl.Math.Vector v)
v | The vector to project from. |
Get the minimum of each component from the vector instance and a given second vector.
Murl.Math.Vector Min(Murl.Math.Vector v)
v | The vector to evaluate the minimum from. |
Get the maximum of each component from the vector instance and a given second vector.
Murl.Math.Vector Max(Murl.Math.Vector v)
v | The vector to evaluate the maximum from. |
Clamp each component to the value range given by the min and max vector parameters.
Murl.Math.Vector Clamp(Murl.Math.Vector min, Murl.Math.Vector max)
min | The component-wise minimum to clamp to. |
max | The component-wise maximum to clamp to. |
Get a vector with a length below or equal a given minimum. If the current vector's length is below or equal the given minimum value, the vector is directly returned. Otherwise a scaled vector is returned, with the original direction and given length.
Murl.Math.Vector MinLength(Number v)
v | The minimum length. |
Get a vector with a length above or equal a given maximum. If the current vector's length is above or equal the given maximum value, the vector is directly returned. Otherwise a scaled vector is returned, with the original direction and given length. If the vector has zero length (i.e. undefined direction) a zero vector is returned with its w component set to either 0 or 1, depending on the current vector's w value.
Murl.Math.Vector MaxLength(Number v)
v | The maximum length. |
Get the a vector with clamped length. This method returns a vector in the direction of the vector instance, but with its length clamped to the given range.
Murl.Math.Vector ClampLength(Number min, Number max)
min | The minimum length. |
max | The maximum length. |
Get a vector containing absolute values for each of the instance's components.
Murl.Math.Vector Abs()
Get a vector containing component values of either -1, 0 or +1, depending on the instance component's signs.
Murl.Math.Vector Sgn()
Get the inversion (negation) of the vector instance.
Murl.Math.Vector Invert()
Get the normalization of the vector instance. Normalization retains the direction and sets the length to 1.0.
Murl.Math.Vector Normalize()
Get the normalization of the x, y and z components. Calculates the normalization without touching the w component, for normalizing the axis of an axis/angle representation.
Murl.Math.Vector NormalizeAxis()
Get the dot product of the vector instance and a given second vector.
Number Dot(Murl.Math.Vector v)
v | The second vector. |
Get the length of the vector instance.
Number GetLength()
Get the squared length of the vector instance.
Number GetSquaredLength()
Get the x/y angle of the vector instance.
Number GetAngle2D()
Check if the vector instance equals the null vector. Compares all values within the default epsilon range Limits::Epsilon().
Boolean IsZero()
Check if the vector instance equals the null vector. Compares all values within a given epsilon range.
Boolean IsZero(Number epsilon)
epsilon | The epsilon to compare. |
Check if the vector instance equals the zero position. Compares the x, y and z values within the default epsilon range Limits::Epsilon().
Boolean IsZeroPosition()
Check if the vector instance equals the zero position. Compares the x, y and z values within a given epsilon range.
Boolean IsZeroPosition(Number epsilon)
epsilon | The epsilon to compare. |
Check if the vector instance is equal to a given second vector. Compares all values within the default epsilon range Limits::Epsilon().
Boolean IsEqual(Murl.Math.Vector v)
v | The vector to compare. |
Check if the vector instance is equal to a given second vector. Compares all values within a given epsilon range.
Boolean IsEqual(Murl.Math.Vector v, Number epsilon)
v | The vector to compare. |
epsilon | The epsilon to compare. |
Get base vectors for this vector instance. This method tries to calculate three direction vectors from the current instance, so that they form an orthonormal base. If the current vector has zero length, false is returned.
Boolean, Murl.Math.Vector, Murl.Math.Vector, Murl.Math.Vector GetBaseNormals(Murl.Math.Vector n1, Murl.Math.Vector n2, Murl.Math.Vector n3)
n1 | Base vector 1 |
n2 | Base vector 2 |
n3 | Base vector 3 |
Get the string representation of the object.
String ToString()
Get the number of elements in the object.
Integer GetCount()
The length operator is denoted by the unary prefix operator #.
Converts the object content to a string in a reasonable format.
Get a reference to one of the 4 component values.
index | The component index, see enum Component. |
Addition operator.
Inversion (negation) operator.
Subtraction operator.
Multiplication (scaling) operator.
Multiplication operator for quaternion.
Component-wise multiplication operator.
Division (inverse scaling) operator.
Component-wise division operator.
Equal to comparison operator. Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Vector> class. To compare within an epsilon range use Vector::IsEqual().
The X component.
The Y component.
The Z component.
The W component.