Class Vector4

Vector with 4 floating point components: (x, y, z, w).

Vector4 constructors

Functions which can be used to create new instances of Vector4.

Synopsis

Methods
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)

Vector4()

Default constructor, initializes the vector to (0.0, 0.0, 0.0, 0.0).

Example
local vector4 = Vector4()
Vector4(v)

Constructor, initializes the vector to (v, v, v, v).

Example
local vector4 = Vector4(v)
Parameters
v (float)

x, y, z, and w component of the vector.

Vector4(x, y, z, w)

Constructor, initializes the vector to (x, y, z, w).

Example
local vector4 = Vector4(x, y, z, w)
Parameters
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.

Vector4 methods

Methods of Vector4 class.

Synopsis

Methods
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

Vector4.zero()

Returns the vector with each element being zero.

Return Values
(Vector4)

Vector with zeroed elements.

Vector4.one()

Returns the vector with each element being one.

Return Values
(Vector4)

Vector with unit element values.

Vector4:getX()

Returns the x element of the vector.

Return Values
(float)

The x element.

Vector4:getY()

Returns the y element of the vector.

Return Values
(float)

The y element.

Vector4:getZ()

Returns the z element of the vector.

Return Values
(float)

The z element.

Vector4:getW()

Returns the w element of the vector.

Return Values
(float)

The w element.

Vector4:setX(value)

Sets the x element of the vector.

Parameters
value (float)

The new value of the x element.

Vector4:setY(value)

Sets the y element of the vector.

Parameters
value (float)

The new value of the y element.

Vector4:setZ(value)

Sets the z element of the vector.

Parameters
value (float)

The new value of the z element.

Vector4:setW(value)

Sets the w element of the vector.

Parameters
value (float)

The new value of the w element.

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.

Return Values
(float)

sqrt(dot product of the vector).

Vector4:squaredLength()

Calculates the squared length of the vector.

Return Values
(float)

Dot product of the vector.

Vector4:normalized()

Normalizes the vector and returns the resulting vector.

Return Values
(Vector4)

The normalized vector.

Vector4.lowestValue()

Returns the vector with each element having the most negative float value.

Return Values
(Vector4)

Vector with the lowest possible value.

Vector4.highestValue()

Returns the vector with each element having the most positive float value.

Return Values
(Vector4)

Vector with the highest possible value.

Vector4.nan()

Returns the vector with each element being NaN.

Return Values
(Vector4)

Vector with NaN elements.

Vector4.positiveInfinity()

Returns the vector with each element being the positive infinity.

Return Values
(Vector4)

Vector with positive infinity elements.

Vector4.negativeInfinity()

Returns the vector with each element being the negative infinity.

Return Values
(Vector4)

Vector with negative infinity elements.

Vector4 functions

Vector4 specific standalone functions, which are not a part of the Vector4 class.

Synopsis

Functions
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

componentAbs(v)

Calculates component-wise absolute value for all elements and returns resulting vector.

Parameters
v (Vector4)

Vector input.

Return Values
(Vector4)

The result vector.

componentCeil(v)

Calculates component-wise ceil value for all elements and returns resulting vector.

Parameters
v (Vector4)

Vector input.

Return Values
(Vector4)

The result vector.

componentFloor(v)

Calculates component-wise floor value for all elements and returns resulting vector.

Parameters
v (Vector4)

Vector input.

Return Values
(Vector4)

The result vector.

componentRound(v)

Calculates component-wise rounded value for all elements and returns resulting vector.

Parameters
v (Vector4)

Vector input.

Return Values
(Vector4)

The result vector.

componentSqrt(v)

Calculates component-wise square root all elements and returns resulting vector.

Parameters
v (Vector4)

Vector input.

Return Values
(Vector4)

The result vector.

componentWiseMax(v1, v2)

Calculates the component-wise maximum for all vector elements and returns the resulting vector.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The result vector.

componentWiseMin(v1, v2)

Calculates the component-wise minimum for all vector elements and returns the resulting vector.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The result vector.

componentWiseMultiply(v1, v2)

Multiplies component-wise all vector elements and returns the resulting vector.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The result vector.

componentWiseDivide(v1, v2)

Divides component-wise all vector elements and returns the resulting vector.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The result vector.

componentWiseRemainder(v1, v2)

Calculates component-wise the remainder for all vector elements and returns the resulting vector.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The result vector.

componentAdd(v, scalar)

Adds a value to all elements of a vector and returns the result.

Parameters
v (Vector4)

A vector.

scalar (float)

A scalar.

Return Values
(Vector4)

The result vector.

componentSubtract(v, scalar)

Subtracts a value from all elements of a vector and returns the result.

Parameters
v (Vector4)

A vector.

scalar (float)

A scalar.

Return Values
(Vector4)

The result vector.

componentAllLessThan(a, b)

Returns whether each component of the first vector is less than the corresponding component of the second vector.

Parameters
a (Vector4)

First vector.

b (Vector4)

Second vector.

Return Values
(bool)

If each component of the first vector is less than the corresponding component of the second vector, true, otherwise false.

componentAllLessThanOrEqual(a, b)

Returns whether each component of the first vector is less than or equal to the corresponding component of the second vector.

Parameters
a (Vector4)

First vector.

b (Vector4)

Second vector.

Return Values
(bool)

If each component of the first vector is less than or equal to the corresponding component of the second vector, true, otherwise false.

componentAllGreaterThan(a, b)

Returns whether each component of the first vector is greater than the corresponding component of the second vector.

Parameters
a (Vector4)

First vector.

b (Vector4)

Second vector.

Return Values
(bool)

If each component of the first vector is greater than the corresponding component of the second vector, true, otherwise false.

componentAllGreaterThanOrEqual(a, b)

Returns whether each component of the first vector is greater than or equal to the corresponding component of the second vector.

Parameters
a (Vector4)

First vector.

b (Vector4)

Second vector.

Return Values
(bool)

If each component of the first vector is greater than or equal to the corresponding component of the second vector, true, otherwise false.

dotProduct(v1, v2)

Calculates the dot product of two vectors.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(float)

The dot product of the vectors.

crossProduct(v1, v2)

Calculates the cross product of two vectors.

Parameters
v1 (Vector4)

The first vector.

v2 (Vector4)

The second vector.

Return Values
(Vector4)

The cross product of the vectors.

sRGBToLinear(vec)

Conversion to whole Vector4 from sRGB to linear.

Parameters
vec (Vector4)

Vector4 representing color in sRGB format.

Return Values
(Vector4)

Vector4 representing color in linear format.

linearTosRGB(vec)

Conversion to whole Vector4 from linear to sRGB.

Parameters
vec (Vector4)

Vector4 representing color in linear format.

Return Values
(Vector4)

Vector4 representing color in sRGB format.

sRGBToHSLColor(vec)

Converts a Vector4 from RGBA color space to HSLA color space. The function passes the value of the alpha channel as is.

Parameters
vec (Vector4)

Vector4 that represents the red, green, blue, and alpha values of the color.

Return Values
(Vector4)

Vector4 that represents the hue, saturation, lightness, and alpha values of the color.

hslTosRGBColor(vec)

Converts a Vector4 from HSLA color space to RGBA color space. The function passes the value of the alpha channel as is.

Parameters
vec (Vector4)

Vector4 that represents the hue, saturation, lightness, and alpha values of the color.

Return Values
(Vector4)

Vector4 that represents the red, green, blue, and alpha values of the color.