Vector3
¶
Vector with 3 floating point components: (x, y, z).
Functions which can be used to create new instances of Vector3.
Vector3() | Default constructor, initializes the vector to (0.0, 0.0, 0.0) |
Vector3() | Constructor, initializes the vector to (x, y, z) |
Vector3() | Constructor, initializes the vector to (v, v, v) |
Default constructor, initializes the vector to (0.0, 0.0, 0.0).
local vector3 = Vector3()
Constructor, initializes the vector to (x, y, z).
local vector3 = Vector3(x, y, z)
x | (float) | x component of the vector. |
y | (float) | y component of the vector. |
z | (float) | z component of the vector. |
Constructor, initializes the vector to (v, v, v).
local vector3 = Vector3(v)
v | (float) | x, y and z components of the vector. |
Methods of Vector3 class.
Vector3.zero() | Returns the vector with each element being zero |
Vector3.one() | Returns the vector with each element being one |
Vector3:getX() | Returns the x element of the vector |
Vector3:getY() | Returns the y element of the vector |
Vector3:getZ() | Returns the z element of the vector |
Vector3:setX() | Sets the x element of the vector |
Vector3:setY() | Sets the y element of the vector |
Vector3:setZ() | Sets the z element of the vector |
Vector3:minimumAxis() | Returns axis based on the minimum component of Vector3 |
Vector3:maximumAxis() | Returns axis based on the largest component of Vector3 |
Vector3:hasNan() | Returns true if and only if at least one of the vector values is NaN |
Vector3:length() | Calculates the length a vectors |
Vector3:squaredLength() | Calculates the squared length a vectors |
Vector3:normalized() | Normalizes the vector and returns the resulting vector |
Vector3.lowestValue() | Returns the vector with each element having the most negative float value |
Vector3.highestValue() | Returns the vector with each element having the most positive float value |
Vector3.nan() | Returns the vector with each element being NaN |
Vector3.positiveInfinity() | Returns the vector with each element being the positive infinity |
Vector3.negativeInfinity() | Returns the vector with each element being the negative infinity |
Vector3.positiveX() | Returns the unit vector pointing right |
Vector3.positiveY() | Returns the unit vector pointing up |
Vector3.positiveZ() | Returns the unit vector pointing backward |
Vector3.negativeX() | Returns the unit vector pointing left |
Vector3.negativeY() | Returns the unit vector pointing down |
Vector3.negativeZ() | Returns the unit vector pointing forward |
Returns the vector with each element being zero.
(Vector3) | Vector with zeroed elements. |
Returns the vector with each element being one.
(Vector3) | 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. |
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. |
Returns axis based on the minimum component of Vector3.
(Vector3) | If X component is smallest, (1, 0, 0), else if Y component is smallest, (0, 1, 0), else (0, 0, 1). |
Returns axis based on the largest component of Vector3.
(Vector3) | If X component is largest, (1, 0, 0), else if Y component is largest, (0, 1, 0), else (0, 0, 1). |
Returns true if and only if at least one of the vector values is NaN.
Calculates the length a vectors.
(float) | sqrt(xx + yy + z*z) |
Calculates the squared length a vectors.
(float) | xx + yy + z*z |
Normalizes the vector and returns the resulting vector.
(Vector3) | The normalized vector. |
Returns the vector with each element having the most negative float value.
(Vector3) | Vector with the lowest possible value. |
Returns the vector with each element having the most positive float value.
(Vector3) | Vector with the highest possible value. |
Returns the vector with each element being NaN.
(Vector3) | Vector with NaN elements. |
Returns the vector with each element being the positive infinity.
(Vector3) | Vector with positive infinity elements. |
Returns the vector with each element being the negative infinity.
(Vector3) | Vector with negative infinity elements. |
Returns the unit vector pointing right.
(Vector3) | Vector3(1.0f, 0.0f, 0.0f). |
Returns the unit vector pointing up.
(Vector3) | Vector3(0.0f, 1.0f, 0.0f). |
Returns the unit vector pointing backward.
(Vector3) | Vector3(0.0f, 0.0f, 1.0f). |
Returns the unit vector pointing left.
(Vector3) | Vector3(-1.0f, 0.0f, 0.0f). |
Returns the unit vector pointing down.
(Vector3) | Vector3(0.0f, -1.0f, 0.0f). |
Returns the unit vector pointing forward.
(Vector3) | Vector3(0.0f, 0.0f, -1.0f). |
Vector3 specific standalone functions, which are not a part of the Vector3 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 |
getOrthogonalVector() | Finds a vector that is orthogonal to the given vector |
sRGBToLinear() | Converts to whole Vector3 from sRGB to linear |
linearTosRGB() | Converts to whole Vector3 from linear to sRGB |
hslTosRGBColor() | Converts a Vector3 from HSL color space to sRGB color space |
sRGBToHSLColor() | Converts a Vector3 from sRGB color space to HSL color space |
Calculates component-wise absolute value for all elements and returns resulting vector.
v | (Vector3) | Vector input. |
(Vector3) | The result vector. |
Calculates component-wise ceil value for all elements and returns resulting vector.
v | (Vector3) | Vector input. |
(Vector3) | The result vector. |
Calculates component-wise floor value for all elements and returns resulting vector.
v | (Vector3) | Vector input. |
(Vector3) | The result vector. |
Calculates component-wise rounded value for all elements and returns resulting vector.
v | (Vector3) | Vector input. |
(Vector3) | The result vector. |
Calculates component-wise square root all elements and returns resulting vector.
v | (Vector3) | Vector input. |
(Vector3) | The result vector. |
Calculates the component-wise maximum for all vector elements and returns the resulting vector.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The result vector. |
Calculates the component-wise minimum for all vector elements and returns the resulting vector.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The result vector. |
Multiplies component-wise all vector elements and returns the resulting vector.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The result vector. |
Divides component-wise all vector elements and returns the resulting vector.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The result vector. |
Calculates component-wise the remainder for all vector elements and returns the resulting vector.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The result vector. |
Adds a value to all elements of a vector and returns the result.
v | (Vector3) | A vector. |
scalar | (float) | A scalar. |
(Vector3) | The result vector. |
Subtracts a value from all elements of a vector and returns the result.
v | (Vector3) | A vector. |
scalar | (float) | A scalar. |
(Vector3) | The result vector. |
Returns whether each component of the first vector is less than the corresponding component of the second vector.
a | (Vector3) | First vector. |
b | (Vector3) | 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 | (Vector3) | First vector. |
b | (Vector3) | 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 | (Vector3) | First vector. |
b | (Vector3) | 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 | (Vector3) | First vector. |
b | (Vector3) | 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 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(float) | The dot product of the vectors. |
Calculates the cross product of two vectors.
v1 | (Vector3) | The first vector. |
v2 | (Vector3) | The second vector. |
(Vector3) | The cross product of the vectors. |
Finds a vector that is orthogonal to the given vector.
v | (Vector3) | Source vector. Length must be 1. |
(Vector3) | Vector orthogonal to the source vector. Not necessarily of unit length. |
Converts to whole Vector3 from sRGB to linear. Since sRGB-to-linear conversion does not take alpha into account, it is possible to interpret Vector3 as just the RGB components.
vec | (Vector3) | Vector3 representing color in sRGB format. |
(Vector3) | Vector3 representing color in linear format. |
Converts to whole Vector3 from linear to sRGB. Since linear-to-sRGB conversion does not take alpha into account, it is possible to interpret Vector3 as just the RGB components.
vec | (Vector3) | Vector3 representing color in linear format. |
(Vector3) | Vector3 representing color in sRGB format. |
Converts a Vector3 from HSL color space to sRGB color space. Since the conversion does not take the alpha channel into account, it is possible to interpret the returned Vector3 as the red, green, and blue components.
vec | (Vector3) | Vector3 that represents a color in the HSL color space. |
(Vector3) | Vector3 that represents the color in the sRGB color space. |
Converts a Vector3 from sRGB color space to HSL color space. Since the conversion does not take the alpha channel into account, it is possible to interpret the returned Vector3 as the hue, saturation, and lightness components.
vec | (Vector3) | Vector3 that represents a color in the sRGB color space. |
(Vector3) | Vector3 that represents the color in the HSL color space. |