Elements.pyECSS.math_utilities¶
Utilities and helper functions for basic computer graphics linear/quaternion algebra & real-time rendering components
Elements.pyECSS (Entity Component Systems in a Scenegraph) package @Copyright 2021-2022 Dr. George Papagiannakis
Most methods have been tested against glm equivalent methods: https://github.com/Zuzu-Typ/PyGLM/tree/master/wiki/function-reference
Functions
|
|
|
|
|
Utility function to calculate a 4x4 Rotation Transformation matrix from a vector of euler angles |
|
Alternative Perspective projection matrix creation function, where the viewing volume is a truncated pyramid. |
|
generate a numpy identity matrix |
|
call numpy linalg.inv(a)[source] to compute the inverse of a numpy matrix |
|
standard linear interpolation between two vectors and a fraction value |
|
Utility function to calculate a 4x4 camera lookat matrix, based on the eye, target and up camera vectors: based on the gluLookAt() convenience method of https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml and the implementation of https://github.com/g-truc/glm/blob/master/glm/ext/matrix_transform.inl and https://github.com/Zuzu-Typ/PyGLM/blob/master/wiki/function-reference/stable_extensions/matrix_transform.md#lookAt-function |
|
Utility function to calculate a 4x4 camera lookat matrix, based on the eye, target and up camera vectors: based on the gluLookAt() convenience method of https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml and the implementation of https://github.com/g-truc/glm/blob/master/glm/ext/matrix_transform.inl and https://github.com/Zuzu-Typ/PyGLM/blob/master/wiki/function-reference/stable_extensions/matrix_transform.md#lookAt-function |
|
standard vector normalization over any numpy array |
|
Orthographic projection matrix creation function, where the viewing volume is a rectangular parallelepiped, or more informally, a box. |
|
Perspective projection matrix creation function, where the viewing volume is a truncated pyramid. |
|
Generate a quaternion array from 4 values or a vec3 for vector and w for scalar parts (scalar-last list scipy) It has been tested against: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html#scipy.spatial.transform.Rotation |
|
Generate a quaternion from a rotation axis and an angle, scalar-last like scipy # https://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm # https://en.wikipedia.org/wiki/Axis–angle_representation#Rotation_vector |
|
Create a quaternion out of euler angles (pitch = x, yaw = y, roll = z), scalar-last like scipy https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm |
Compute and return a 4x4 matrix from the quaternion q, scalar-last like scipy https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm |
|
|
Compute and return a new quaternion which is the product of two quaternions, scalar-last like scipy https://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/arithmetic/index.htm |
|
Spherical linear interpolation from unit q0 to unit q1 based on fraction f: https://en.wikipedia.org/wiki/Slerp#Quaternion_Slerp https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Slerp.html#scipy.spatial.transform.Slerp http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/ |
|
From a euclidean axis vector and a rotation angle, generate a standard 4x4 Rotation Transformation matrix based on the original OpenGL formulas defined in: http://www.glprogramming.com/red/appendixf.html and axis-angle theoretical matrix specification: https://en.wikipedia.org/wiki/Rotation_matrix |
|
Convert a euclidean scaling vector in homogeneous coordinates to a standard 4x4 Scaling Transformation matrix based on the original OpenGL formulas defined in: http://www.glprogramming.com/red/appendixf.html and OpenGL 1.0 specification. |
|
Utility function to calculate with one call sine and cosine of an angle in radians or degrees If there is one argument, then assumes that single input is in degrees, otherwise ignores first value and takes second for radians (needs two in that case) It returns the value in radians, first sin then cos |
|
Convert a euclidean translation vector in homogeneous coordinates to a standard 4x4 Translation Transformation matrix based on the original OpenGL formulas defined in: http://www.glprogramming.com/red/appendixf.html and OpenGL 1.0 specification. |
|
return a numpy vector out of any iterable (list, tuple…) as column-major (‘F’) |