Vector4
¶
Vector with 4 floating point components: (x, y, z, w).
Functions which can be used to create new instances of Vector4.
Vector4() | Default constructor, initializes the vector to (0.0, 0.0, 0.0, 0.0) |
Vector4() | Constructor, initializes the vector to (v, v, v, v) |
Vector4() | Constructor, initializes the vector to (x, y, z, w) |
Default constructor, initializes the vector to (0.0, 0.0, 0.0, 0.0).
local vector4 = Vector4()
Constructor, initializes the vector to (v, v, v, v).
local vector4 = Vector4(v)
v | (float) | x, y, z, and w component of the vector. |
Constructor, initializes the vector to (x, y, z, w).
local vector4 = Vector4(x, y, z, w)
x | (float) | x component of the vector. |
y | (float) | y component of the vector. |
z | (float) | z component of the vector. |
w | (float) | w component of the vector. |
Methods of Vector4 class.
Vector4.zero() | Returns the vector with each element being zero |
Vector4.one() | Returns the vector with each element being one |
Vector4:getX() | Returns the x element of the vector |
Vector4:getY() | Returns the y element of the vector |
Vector4:getZ() | Returns the z element of the vector |
Vector4:getW() | Returns the w element of the vector |
Vector4:setX() | Sets the x element of the vector |
Vector4:setY() | Sets the y element of the vector |
Vector4:setZ() | Sets the z element of the vector |
Vector4:setW() | Sets the w element of the vector |
Vector4:hasNan() | Returns true if and only if at least one of the vector values is NaN |
Vector4:length() | Calculates the length of the vector |
Vector4:squaredLength() | Calculates the squared length of the vector |
Vector4:normalized() | Normalizes the vector and returns the resulting vector |
Vector4.lowestValue() | Returns the vector with each element having the most negative float value |
Vector4.highestValue() | Returns the vector with each element having the most positive float value |
Vector4.nan() | Returns the vector with each element being NaN |
Vector4.positiveInfinity() | Returns the vector with each element being the positive infinity |
Vector4.negativeInfinity() | Returns the vector with each element being the negative infinity |
Returns the vector with each element being zero.
(Vector4) | Vector with zeroed elements. |
Returns the vector with each element being one.
(Vector4) | Vector with unit element values. |
Returns the x element of the vector.
(float) | The x element. |
Returns the y element of the vector.
(float) | The y element. |
Returns the z element of the vector.
(float) | The z element. |
Returns the w element of the vector.
(float) | The w element. |
Sets the x element of the vector.
value | (float) | The new value of the x element. |
Sets the y element of the vector.
value | (float) | The new value of the y element. |
Sets the z element of the vector.
value | (float) | The new value of the z element. |
Sets the w element of the vector.
value | (float) | The new value of the w element. |
Returns true if and only if at least one of the vector values is NaN.
Calculates the length of the vector.
(float) | sqrt(dot product of the vector). |
Calculates the squared length of the vector.
(float) | Dot product of the vector. |
Normalizes the vector and returns the resulting vector.
(Vector4) | The normalized vector. |
Returns the vector with each element having the most negative float value.
(Vector4) | Vector with the lowest possible value. |
Returns the vector with each element having the most positive float value.
(Vector4) | Vector with the highest possible value. |
Returns the vector with each element being NaN.
(Vector4) | Vector with NaN elements. |
Returns the vector with each element being the positive infinity.
(Vector4) | Vector with positive infinity elements. |
Returns the vector with each element being the negative infinity.
(Vector4) | Vector with negative infinity elements. |
Vector4 specific standalone functions, which are not a part of the Vector4 class.
componentAbs() | Calculates component-wise absolute value for all elements and returns resulting vector |
componentCeil() | Calculates component-wise ceil value for all elements and returns resulting vector |
componentFloor() | Calculates component-wise floor value for all elements and returns resulting vector |
componentRound() | Calculates component-wise rounded value for all elements and returns resulting vector |
componentSqrt() | Calculates component-wise square root all elements and returns resulting vector |
componentWiseMax() | Calculates the component-wise maximum for all vector elements and returns the resulting vector |
componentWiseMin() | Calculates the component-wise minimum for all vector elements and returns the resulting vector |
componentWiseMultiply() | Multiplies component-wise all vector elements and returns the resulting vector |
componentWiseDivide() | Divides component-wise all vector elements and returns the resulting vector |
componentWiseRemainder() | Calculates component-wise the remainder for all vector elements and returns the resulting vector |
componentAdd() | Adds a value to all elements of a vector and returns the result |
componentSubtract() | Subtracts a value from all elements of a vector and returns the result |
componentAllLessThan() | Returns whether each component of the first vector is less than the corresponding component of the second vector |
componentAllLessThanOrEqual() | Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector |
componentAllGreaterThan() | Returns whether each component of the first vector is greater than the corresponding component of the second vector |
componentAllGreaterThanOrEqual() | Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector |
dotProduct() | Calculates the dot product of two vectors |
crossProduct() | Calculates the cross product of two vectors |
sRGBToLinear() | Conversion to whole Vector4 from sRGB to linear |
linearTosRGB() | Conversion to whole Vector4 from linear to sRGB |
sRGBToHSLColor() | Converts a Vector4 from RGBA color space to HSLA color space |
hslTosRGBColor() | Converts a Vector4 from HSLA color space to RGBA color space |
Calculates component-wise absolute value for all elements and returns resulting vector.
v | (Vector4) | Vector input. |
(Vector4) | The result vector. |
Calculates component-wise ceil value for all elements and returns resulting vector.
v | (Vector4) | Vector input. |
(Vector4) | The result vector. |
Calculates component-wise floor value for all elements and returns resulting vector.
v | (Vector4) | Vector input. |
(Vector4) | The result vector. |
Calculates component-wise rounded value for all elements and returns resulting vector.
v | (Vector4) | Vector input. |
(Vector4) | The result vector. |
Calculates component-wise square root all elements and returns resulting vector.
v | (Vector4) | Vector input. |
(Vector4) | The result vector. |
Calculates the component-wise maximum for all vector elements and returns the resulting vector.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The result vector. |
Calculates the component-wise minimum for all vector elements and returns the resulting vector.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The result vector. |
Multiplies component-wise all vector elements and returns the resulting vector.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The result vector. |
Divides component-wise all vector elements and returns the resulting vector.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The result vector. |
Calculates component-wise the remainder for all vector elements and returns the resulting vector.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The result vector. |
Adds a value to all elements of a vector and returns the result.
v | (Vector4) | A vector. |
scalar | (float) | A scalar. |
(Vector4) | The result vector. |
Subtracts a value from all elements of a vector and returns the result.
v | (Vector4) | A vector. |
scalar | (float) | A scalar. |
(Vector4) | The result vector. |
Returns whether each component of the first vector is less than the corresponding component of the second vector.
a | (Vector4) | First vector. |
b | (Vector4) | Second vector. |
(bool) | If each component of the first vector is less than the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.
a | (Vector4) | First vector. |
b | (Vector4) | Second vector. |
(bool) | If each component of the first vector is less than or equal to the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is greater than the corresponding component of the second vector.
a | (Vector4) | First vector. |
b | (Vector4) | Second vector. |
(bool) | If each component of the first vector is greater than the corresponding component of the second vector, true, otherwise false. |
Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.
a | (Vector4) | First vector. |
b | (Vector4) | Second vector. |
(bool) | If each component of the first vector is greater than or equal to the corresponding component of the second vector, true, otherwise false. |
Calculates the dot product of two vectors.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(float) | The dot product of the vectors. |
Calculates the cross product of two vectors.
v1 | (Vector4) | The first vector. |
v2 | (Vector4) | The second vector. |
(Vector4) | The cross product of the vectors. |
Conversion to whole Vector4 from sRGB to linear.
vec | (Vector4) | Vector4 representing color in sRGB format. |
(Vector4) | Vector4 representing color in linear format. |
Conversion to whole Vector4 from linear to sRGB.
vec | (Vector4) | Vector4 representing color in linear format. |
(Vector4) | Vector4 representing color in sRGB format. |
Converts a Vector4 from RGBA color space to HSLA color space. The function passes the value of the alpha channel as is.
vec | (Vector4) | Vector4 that represents the red, green, blue, and alpha values of the color. |
(Vector4) | Vector4 that represents the hue, saturation, lightness, and alpha values of the color. |
Converts a Vector4 from HSLA color space to RGBA color space. The function passes the value of the alpha channel as is.
vec | (Vector4) | Vector4 that represents the hue, saturation, lightness, and alpha values of the color. |
(Vector4) | Vector4 that represents the red, green, blue, and alpha values of the color. |