Module vec3_util
Provides additional vector functions, and adds metatables to vectors (to allow arithmetic operations using the +/-/* operators).
All methods of the original vec3 module can be accessed to.
Functions
| vec3Util.toTable (v) | Converts a vector to a list with the three vector components as values |
| vec3Util.fromTable (v) | Create a vector from a list of numbers |
| vec3Util.toString (v[, precision=0.01]) | Return a string representation of the given vector |
| vec3Util.flipAroundZ (v) | Rotate the vector by 180° around the z-axis |
| vec3Util.transform (v, t[, transl]) | Apply a transformation matrix and an optional translation to a vector |
| vec3Util.rotateAxis (n) | Returns a function to rotate a vector around a defined axis |
| vec3Util.multiply (a, b) | Multiplies a vector with another vector (dot) or a number |
Functions
- vec3Util.toTable (v)
-
Converts a vector to a list with the three vector components as values
Parameters:
- v vec3
Returns:
-
{number,number,number}
- vec3Util.fromTable (v)
-
Create a vector from a list of numbers
Parameters:
- v {number,number,number}
Returns:
-
vec3
- vec3Util.toString (v[, precision=0.01])
-
Return a string representation of the given vector
Parameters:
- v {number,number,number} or vec3
- precision number (default 0.01)
Returns:
- vec3Util.flipAroundZ (v)
-
Rotate the vector by 180° around the z-axis
Parameters:
- v {number,number,number} or vec3
Returns:
-
vec3
- vec3Util.transform (v, t[, transl])
-
Apply a transformation matrix and an optional translation to a vector
Parameters:
- v {number,number,number} or vec3
- t ug.linalg.Mat4x4
- transl {number,number,number} or vec3 (optional)
Returns:
-
vec3
- vec3Util.rotateAxis (n)
-
Returns a function to rotate a vector around a defined axis
Parameters:
- n vec3 the rotation axis
Returns:
-
function(vec3,number)
- vec3Util.multiply (a, b)
-
Multiplies a vector with another vector (dot) or a number
Parameters:
- a vec3 or number
- b vec3 or number
Returns:
-
vec3 or number