Class geom3d
3D geometry module : rotation,transformation matrix generation and manipulation
external dependencies : numlua (https://github.com/carvalho/numlua) -- needed to pull the lua_number2int fix for this repository
not a class but works better with ldoc if we say it is
Methods
geom3d:get14mtx () | initialises a 1x4 matrix |
geom3d:get41mtx () | initialises a 4x1 matrix |
geom3d:get44mtx () | initialises a 4x4 matrix |
geom3d:genMt (x, y, z) | generate 3D transformation matrix |
geom3d:genMrx (angr) | generate 3D X axis rotation matrix |
geom3d:genMry (angr) | generate 3D Y axis rotation matrix |
geom3d:genMrz (angr) | generate 3D Z axis rotation matrix |
geom3d:getSphericalCoordinates (m) | given m[ x y z ], return m[ theta phi distance 1 ] |
geom3d:getDistance3d (m1, m2) | calculate distance between two points (1D vectors) |
geom3d:getAngleS3 (d0, d1, d2) | calculate angle a1a2a3 from lengths of 3 sides of triangle |
geom3d:matrixAreEqual (m1, m2) | test two matrices for equality |
geom3d:coordSpace (a1, a2, a3, r) | generate transformation matrix to coordinate space defined by 3 points |
Methods
- geom3d:get14mtx ()
-
initialises a 1x4 matrix
Returns:
-
a 1x4 matrix with element [1][4]=1.0
- geom3d:get41mtx ()
-
initialises a 4x1 matrix
Returns:
-
a 4x1 matrix with element [4][1]=1.0
- geom3d:get44mtx ()
-
initialises a 4x4 matrix
Returns:
-
a 4x4 matrix with diagonal elements = 1.0
- geom3d:genMt (x, y, z)
-
generate 3D transformation matrix
Parameters:
- x offset in X dimension
- y offset in Y dimension
- z offset in Z dimension
Returns:
-
a 4x4 3D transformation matrix
- geom3d:genMrx (angr)
-
generate 3D X axis rotation matrix
Parameters:
- angr rotation angle in radians
Returns:
-
a 4x4 3D rotation matrix
- geom3d:genMry (angr)
-
generate 3D Y axis rotation matrix
Parameters:
- angr rotation angle in radians
Returns:
-
a 4x4 3D rotation matrix
- geom3d:genMrz (angr)
-
generate 3D Z axis rotation matrix
Parameters:
- angr rotation angle in radians
Returns:
-
a 4x4 3D rotation matrix
- geom3d:getSphericalCoordinates (m)
-
given m[ x y z ], return m[ theta phi distance 1 ]
Parameters:
- m nx1 (n>=3) matrix specifying X, Y, Z coordinates in first dimension
Returns:
-
4x1 matrix [1][1] = theta radians, [2][1] = phi radians, [3][1] = distance
- geom3d:getDistance3d (m1, m2)
-
calculate distance between two points (1D vectors)
Parameters:
- m1 nx1 matrix specifying coordinates for first point, e.g. [1][1] = x, [2][1] = y, [3][1] = z
- m2 nx1 matrix specifying coordinates for second point
Returns:
-
euclidean distance between m1 and m2
- geom3d:getAngleS3 (d0, d1, d2)
-
calculate angle a1a2a3 from lengths of 3 sides of triangle
Parameters:
- d0 length a1a2
- d1 length a2a3
- d2 length a1a3
Returns:
-
angle a1a2a3 in radians
- geom3d:matrixAreEqual (m1, m2)
-
test two matrices for equality
Parameters:
- m1 matrix 1 to compare
- m2 matrix 2 to compare
Returns:
-
boolean true if equal
- geom3d:coordSpace (a1, a2, a3, r)
-
generate transformation matrix to coordinate space defined by 3 points
Parameters:
- a1 nx1 (n>=3) matrix specifying X,Y,Z coordinates of point on XZ plane orienting the new coordinate space
- a2 nx1 (n>=3) matrix specifying X,Y,Z coordinates of point at origin of the new coordinate space
- a3 nx1 (n>=3) matrix specifying X,Y,Z coordinates of point on Z axis orienting the new coordinate space
- r boolean flag, if true return second matrix which reverses the transformation, bringing points in the new coordinate space back to the original coordinate space
Returns:
-
4x4 3D transformation matrix placing a1 on XZ plane, a2 at 0,0,0, a3 at 0,0,+Z ; optionally (r flag) also return matrix implementing the reverse transformation