mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
add some missing non-square matrix funcs
This commit is contained in:
@@ -11,7 +11,13 @@
|
||||
GLM_MAT3X2_ZERO
|
||||
|
||||
Functions:
|
||||
CGLM_INLINE void glm_mat3x2_make(float * restrict src, mat3x2 dest)
|
||||
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
||||
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
|
||||
CGLM_INLINE void glm_mat3x2_make(float * __restrict src, mat3x2 dest);
|
||||
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest);
|
||||
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest);
|
||||
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
||||
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
||||
*/
|
||||
|
||||
#ifndef cglm_mat3x2_h
|
||||
@@ -110,4 +116,49 @@ glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
||||
dest[2][2] = a20 * b02 + a21 * b12;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief multiply matrix with column vector and store in dest vector
|
||||
*
|
||||
* @param[in] m matrix (left)
|
||||
* @param[in] v vector (right, column vector)
|
||||
* @param[out] dest result vector
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest) {
|
||||
float v0 = v[0], v1 = v[1];
|
||||
|
||||
dest[0] = m[0][0] * v0 + m[0][1] * v1;
|
||||
dest[1] = m[1][0] * v0 + m[1][1] * v1;
|
||||
dest[2] = m[2][0] * v0 + m[2][1] * v1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief transpose matrix and store in dest
|
||||
*
|
||||
* @param[in] m matrix
|
||||
* @param[out] dest result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat3x2_transpose(mat3x2 m, mat2x3 dest) {
|
||||
dest[0][0] = m[0][0]; dest[0][1] = m[1][0]; dest[0][2] = m[2][0];
|
||||
dest[1][0] = m[0][1]; dest[1][1] = m[1][1]; dest[1][2] = m[2][1];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief scale (multiply with scalar) matrix
|
||||
*
|
||||
* multiply matrix with scalar
|
||||
*
|
||||
* @param[in, out] m matrix
|
||||
* @param[in] s scalar
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat3x2_scale(mat3x2 m, float s) {
|
||||
m[0][0] *= s; m[0][1] *= s; m[1][0] *= s;
|
||||
m[1][1] *= s; m[2][0] *= s; m[2][1] *= s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user