Compare commits

...

13 Commits

Author SHA1 Message Date
Recep Aslantas
08479f38ce Merge pull request #63 from recp/avx
avx: replace binary constants (resolve https://github.com/recp/cglm/issues/62) with hex and fix glm_mul_avx
2018-10-19 09:52:32 +03:00
Recep Aslantas
dadae4b773 avx: fix glm_mul_avx
* use glm_mat4_mul_avx here. because it seems there is no big difference for now.
2018-10-19 09:40:40 +03:00
Recep Aslantas
20360f2296 avx: replace binary constants with hex 2018-10-12 09:05:42 +03:00
Recep Aslantas
aa2b0f2631 code style and minor optimization[s] 2018-09-22 00:10:50 +03:00
Recep Aslantas
280ac72fd8 Merge pull request #61 from hartenfels/master
Replace non-standard M_PI* constants
2018-09-21 23:39:10 +03:00
Recep Aslantas
7405d5e1d0 Update types.h 2018-09-21 23:33:42 +03:00
Carsten Hartenfels
eefafefbae Also add a load of other number constants
These are all missing from standard C, so we might as well define em.

See https://github.com/recp/cglm/pull/61#discussion_r219406859
2018-09-21 20:03:28 +02:00
Carsten Hartenfels
b9021978cb Replace the use of deprecated CGLM_PI* constants 2018-09-21 19:59:23 +02:00
Carsten Hartenfels
3fd12032e6 Clean up pi constants, deprecating the old names
GLM_PI* is now used for the double versions, GLM_PI*f for the float
versions. The CGLM_ prefixed versions are now deprecated, since that
prefix is kinda only used for constants.

See https://github.com/recp/cglm/pull/61#issuecomment-423069770
2018-09-21 07:29:54 +02:00
Carsten Hartenfels
59ee8c1fd2 Use even more precise definitions for pi constants
See https://github.com/recp/cglm/pull/61#issuecomment-422955122
2018-09-21 07:26:55 +02:00
Carsten Hartenfels
b00f2b9ccc Replace M_PI_4 in test_affine with CGLM_PI_4
As in the previous commit, because it's non-standard and depending on
your settings it can fail to compile because of it.
2018-09-19 20:46:37 +02:00
Carsten Hartenfels
d3c50147cb Replace non-standard M_PI* constants with literals
M_PI, M_PI_2 and M_PI_4 aren't part of the C standard. If you put your
gcc into strict standards mode, like `-std=c11`, you won't get these
constants and including cglm.h will fail.

This commit replaces those constants with their literal values. The cast
to a float remains, to keep exactly the same behavior as before.
2018-09-19 20:42:05 +02:00
Recep Aslantas
98da3daf82 identiy helper for arrays (matrix/quaternion)
this helpers makes all array elements identity
2018-09-12 12:44:11 +03:00
25 changed files with 213 additions and 83 deletions

View File

@@ -7,7 +7,7 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.4.8], [info@recp.me])
AC_INIT([cglm], [0.4.9], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_MACRO_DIR([m4])

View File

@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.4.8'
version = u'0.4.9'
# The full version, including alpha/beta/rc tags.
release = u'0.4.8'
release = u'0.4.9'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -20,6 +20,7 @@ Functions:
1. :c:func:`glm_mat3_copy`
#. :c:func:`glm_mat3_identity`
#. :c:func:`glm_mat3_identity_array`
#. :c:func:`glm_mat3_mul`
#. :c:func:`glm_mat3_transpose_to`
#. :c:func:`glm_mat3_transpose`
@@ -49,6 +50,14 @@ Functions documentation
Parameters:
| *[out]* **mat** matrix
.. c:function:: void glm_mat3_identity_array(mat3 * __restrict mat, size_t count)
make given matrix array's each element identity matrix
Parameters:
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
| *[in]* **count** count of matrices
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
multiply m1 and m2 to dest

View File

@@ -25,6 +25,7 @@ Functions:
1. :c:func:`glm_mat4_ucopy`
#. :c:func:`glm_mat4_copy`
#. :c:func:`glm_mat4_identity`
#. :c:func:`glm_mat4_identity_array`
#. :c:func:`glm_mat4_pick3`
#. :c:func:`glm_mat4_pick3t`
#. :c:func:`glm_mat4_ins3`
@@ -69,6 +70,14 @@ Functions documentation
Parameters:
| *[out]* **mat** matrix
.. c:function:: void glm_mat4_identity_array(mat4 * __restrict mat, size_t count)
make given matrix array's each element identity matrix
Parameters:
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
| *[in]* **count** count of matrices
.. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest)
copy upper-left of mat4 to mat3

View File

@@ -27,6 +27,7 @@ Macros:
Functions:
1. :c:func:`glm_quat_identity`
#. :c:func:`glm_quat_identity_array`
#. :c:func:`glm_quat_init`
#. :c:func:`glm_quat`
#. :c:func:`glm_quatv`
@@ -70,6 +71,14 @@ Functions documentation
Parameters:
| *[in, out]* **q** quaternion
.. c:function:: void glm_quat_identity_array(versor * __restrict q, size_t count)
| make given quaternion array's each element identity quaternion
Parameters:
| *[in, out]* **q** quat array (must be aligned (16) if alignment is not disabled)
| *[in]* **count** count of quaternions
.. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w)
| inits quaternion with given values

View File

@@ -24,6 +24,10 @@ CGLM_EXPORT
void
glmc_mat3_identity(mat3 mat);
CGLM_EXPORT
void
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count);
CGLM_EXPORT
void
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest);

View File

@@ -29,6 +29,10 @@ CGLM_EXPORT
void
glmc_mat4_identity(mat4 mat);
CGLM_EXPORT
void
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count);
CGLM_EXPORT
void
glmc_mat4_pick3(mat4 mat, mat3 dest);

View File

@@ -17,6 +17,10 @@ CGLM_EXPORT
void
glmc_quat_identity(versor q);
CGLM_EXPORT
void
glmc_quat_identity_array(versor * __restrict q, size_t count);
CGLM_EXPORT
void
glmc_quat_init(versor q, float x, float y, float z, float w);

View File

@@ -198,26 +198,15 @@ glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
*/
CGLM_INLINE
void
glm_ortho_default(float aspect,
mat4 dest) {
glm_ortho_default(float aspect, mat4 dest) {
if (aspect >= 1.0f) {
glm_ortho(-1.0f * aspect,
1.0f * aspect,
-1.0f,
1.0f,
-100.0f,
100.0f,
dest);
return;
glm_ortho(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
return;
}
glm_ortho(-1.0f,
1.0f,
-1.0f / aspect,
1.0f / aspect,
-100.0f,
100.0f,
dest);
aspect = 1.0f / aspect;
glm_ortho(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
}
/*!
@@ -240,7 +229,7 @@ glm_ortho_default_s(float aspect,
-size - 100.0f,
size + 100.0f,
dest);
return;
return;
}
glm_ortho(-size,
@@ -291,13 +280,8 @@ glm_perspective(float fovy,
*/
CGLM_INLINE
void
glm_perspective_default(float aspect,
mat4 dest) {
glm_perspective((float)CGLM_PI_4,
aspect,
0.01f,
100.0f,
dest);
glm_perspective_default(float aspect, mat4 dest) {
glm_perspective(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
}
/*!
@@ -310,8 +294,7 @@ glm_perspective_default(float aspect,
*/
CGLM_INLINE
void
glm_perspective_resize(float aspect,
mat4 proj) {
glm_perspective_resize(float aspect, mat4 proj) {
if (proj[0][0] == 0.0f)
return;

View File

@@ -19,19 +19,19 @@ glm_ease_linear(float t) {
CGLM_INLINE
float
glm_ease_sine_in(float t) {
return sinf((t - 1.0f) * CGLM_PI_2) + 1.0f;
return sinf((t - 1.0f) * GLM_PI_2f) + 1.0f;
}
CGLM_INLINE
float
glm_ease_sine_out(float t) {
return sinf(t * CGLM_PI_2);
return sinf(t * GLM_PI_2f);
}
CGLM_INLINE
float
glm_ease_sine_inout(float t) {
return 0.5f * (1.0f - cosf(t * CGLM_PI));
return 0.5f * (1.0f - cosf(t * GLM_PIf));
}
CGLM_INLINE
@@ -254,13 +254,13 @@ glm_ease_back_inout(float t) {
CGLM_INLINE
float
glm_ease_elast_in(float t) {
return sinf(13.0f * CGLM_PI_2 * t) * powf(2.0f, 10.0f * (t - 1.0f));
return sinf(13.0f * GLM_PI_2f * t) * powf(2.0f, 10.0f * (t - 1.0f));
}
CGLM_INLINE
float
glm_ease_elast_out(float t) {
return sinf(-13.0f * CGLM_PI_2 * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f;
return sinf(-13.0f * GLM_PI_2f * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f;
}
CGLM_INLINE
@@ -271,10 +271,10 @@ glm_ease_elast_inout(float t) {
a = 2.0f * t;
if (t < 0.5f)
return 0.5f * sinf(13.0f * CGLM_PI_2 * a)
return 0.5f * sinf(13.0f * GLM_PI_2f * a)
* powf(2.0f, 10.0f * (a - 1.0f));
return 0.5f * (sinf(-13.0f * CGLM_PI_2 * a)
return 0.5f * (sinf(-13.0f * GLM_PI_2f * a)
* powf(2.0f, -10.0f * (a - 1.0f)) + 2.0f);
}

View File

@@ -84,12 +84,12 @@ glm_euler_angles(mat4 m, vec3 dest) {
thetaZ = atan2f(-m10, m00);
} else { /* m20 == -1 */
/* Not a unique solution */
thetaY = -CGLM_PI_2;
thetaY = -GLM_PI_2f;
thetaX = -atan2f(m01, m11);
thetaZ = 0.0f;
}
} else { /* m20 == +1 */
thetaY = CGLM_PI_2;
thetaY = GLM_PI_2f;
thetaX = atan2f(m01, m11);
thetaZ = 0.0f;
}

View File

@@ -25,7 +25,7 @@
CGLM_INLINE
void
glm_mat4_print(mat4 matrix,
glm_mat4_print(mat4 matrix,
FILE * __restrict ostream) {
int i;
int j;
@@ -55,7 +55,7 @@ glm_mat4_print(mat4 matrix,
CGLM_INLINE
void
glm_mat3_print(mat3 matrix,
glm_mat3_print(mat3 matrix,
FILE * __restrict ostream) {
int i;
int j;
@@ -85,7 +85,7 @@ glm_mat3_print(mat3 matrix,
CGLM_INLINE
void
glm_vec4_print(vec4 vec,
glm_vec4_print(vec4 vec,
FILE * __restrict ostream) {
int i;
@@ -107,7 +107,7 @@ glm_vec4_print(vec4 vec,
CGLM_INLINE
void
glm_vec3_print(vec3 vec,
glm_vec3_print(vec3 vec,
FILE * __restrict ostream) {
int i;
@@ -129,7 +129,7 @@ glm_vec3_print(vec3 vec,
CGLM_INLINE
void
glm_ivec3_print(ivec3 vec,
glm_ivec3_print(ivec3 vec,
FILE * __restrict ostream) {
int i;
@@ -151,7 +151,7 @@ glm_ivec3_print(ivec3 vec,
CGLM_INLINE
void
glm_versor_print(versor vec,
glm_versor_print(versor vec,
FILE * __restrict ostream) {
int i;

View File

@@ -16,6 +16,7 @@
Functions:
CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest);
CGLM_INLINE void glm_mat3_identity(mat3 mat);
CGLM_INLINE void glm_mat3_identity_array(mat3 * restrict mat, size_t count);
CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
CGLM_INLINE void glm_mat3_transpose(mat3 m);
@@ -85,6 +86,25 @@ glm_mat3_identity(mat3 mat) {
glm_mat3_copy(t, mat);
}
/*!
* @brief make given matrix array's each element identity matrix
*
* @param[in, out] mat matrix array (must be aligned (16/32)
* if alignment is not disabled)
*
* @param[in] count count of matrices
*/
CGLM_INLINE
void
glm_mat3_identity_array(mat3 * __restrict mat, size_t count) {
CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
size_t i;
for (i = 0; i < count; i++) {
glm_mat3_copy(t, mat[i]);
}
}
/*!
* @brief multiply m1 and m2 to dest
*

View File

@@ -23,6 +23,7 @@
CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest);
CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest);
CGLM_INLINE void glm_mat4_identity(mat4 mat);
CGLM_INLINE void glm_mat4_identity_array(mat4 * restrict mat, size_t count);
CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest);
CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest);
CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest);
@@ -143,6 +144,25 @@ glm_mat4_identity(mat4 mat) {
glm_mat4_copy(t, mat);
}
/*!
* @brief make given matrix array's each element identity matrix
*
* @param[in, out] mat matrix array (must be aligned (16/32)
* if alignment is not disabled)
*
* @param[in] count count of matrices
*/
CGLM_INLINE
void
glm_mat4_identity_array(mat4 * __restrict mat, size_t count) {
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
size_t i;
for (i = 0; i < count; i++) {
glm_mat4_copy(t, mat[i]);
}
}
/*!
* @brief copy upper-left of mat4 to mat3
*

View File

@@ -103,6 +103,25 @@ glm_quat_identity(versor q) {
glm_vec4_copy(v, q);
}
/*!
* @brief make given quaternion array's each element identity quaternion
*
* @param[in, out] q quat array (must be aligned (16)
* if alignment is not disabled)
*
* @param[in] count count of quaternions
*/
CGLM_INLINE
void
glm_quat_identity_array(versor * __restrict q, size_t count) {
CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT;
size_t i;
for (i = 0; i < count; i++) {
glm_vec4_copy(v, q[i]);
}
}
/*!
* @brief inits quaterion with raw values
*
@@ -670,7 +689,7 @@ glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
dot = glm_vec_dot(dir, fwd);
if (fabsf(dot + 1.0f) < 0.000001f) {
glm_quat_init(dest, up[0], up[1], up[2], CGLM_PI);
glm_quat_init(dest, up[0], up[1], up[2], GLM_PIf);
return;
}

View File

@@ -27,21 +27,24 @@ glm_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000000); /* l k j i l k j i */
/* 0x03: 0b00000011 */
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
/* f f f f a a a a */
/* g g g g c c c c */
/* h h h h c c c c */
/* e e e e b b b b */
y7 = _mm256_permute_ps(y0, 0b10101010);
/* g g g g d d d d */
y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0));
y7 = _mm256_permutevar_ps(y0, _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2));
y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1));
y9 = _mm256_permutevar_ps(y0, _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3));
glmm_store256(dest[0],
_mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6),
_mm256_mul_ps(y4, y8)),
_mm256_mul_ps(y5, y7)));
_mm256_mul_ps(y3, y7)),
_mm256_add_ps(_mm256_mul_ps(y4, y8),
_mm256_mul_ps(y5, y9))));
/* n n n n i i i i */
/* p p p p k k k k */

View File

@@ -27,8 +27,9 @@ glm_mat4_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000011); /* l k j i p o n m */
/* 0x03: 0b00000011 */
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
/* f f f f a a a a */
/* h h h h c c c c */

View File

@@ -16,7 +16,7 @@
CGLM_INLINE
void
glm_mat4_scale_sse2(mat4 m, float s){
glm_mat4_scale_sse2(mat4 m, float s) {
__m128 x0;
x0 = _mm_set1_ps(s);
@@ -28,7 +28,7 @@ glm_mat4_scale_sse2(mat4 m, float s){
CGLM_INLINE
void
glm_mat4_transp_sse2(mat4 m, mat4 dest){
glm_mat4_transp_sse2(mat4 m, mat4 dest) {
__m128 r0, r1, r2, r3;
r0 = glmm_load(m[0]);

View File

@@ -45,11 +45,39 @@ typedef vec3 mat3[3];
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
#endif
typedef vec4 versor;
#define CGLM_PI ((float)M_PI)
#define CGLM_PI_2 ((float)M_PI_2)
#define CGLM_PI_4 ((float)M_PI_4)
#define GLM_E 2.71828182845904523536028747135266250 /* e */
#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
#define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */
#define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */
#define GLM_PI 3.14159265358979323846264338327950288 /* pi */
#define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
#define GLM_Ef ((float)GLM_E)
#define GLM_LOG2Ef ((float)GLM_LOG2E)
#define GLM_LOG10Ef ((float)GLM_LOG10E)
#define GLM_LN2f ((float)GLM_LN2)
#define GLM_LN10f ((float)GLM_LN10)
#define GLM_PIf ((float)GLM_PI)
#define GLM_PI_2f ((float)GLM_PI_2)
#define GLM_PI_4f ((float)GLM_PI_4)
#define GLM_1_PIf ((float)GLM_1_PI)
#define GLM_2_PIf ((float)GLM_2_PI)
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
#define GLM_SQRT2f ((float)GLM_SQRT2)
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
/* DEPRECATED! use GLM_PI and friends */
#define CGLM_PI GLM_PIf
#define CGLM_PI_2 GLM_PI_2f
#define CGLM_PI_4 GLM_PI_4f
#endif /* cglm_types_h */

View File

@@ -58,7 +58,7 @@ glm_signf(float val) {
CGLM_INLINE
float
glm_rad(float deg) {
return deg * CGLM_PI / 180.0f;
return deg * GLM_PIf / 180.0f;
}
/*!
@@ -69,7 +69,7 @@ glm_rad(float deg) {
CGLM_INLINE
float
glm_deg(float rad) {
return rad * 180.0f / CGLM_PI;
return rad * 180.0f / GLM_PIf;
}
/*!
@@ -80,7 +80,7 @@ glm_deg(float rad) {
CGLM_INLINE
void
glm_make_rad(float *deg) {
*deg = *deg * CGLM_PI / 180.0f;
*deg = *deg * GLM_PIf / 180.0f;
}
/*!
@@ -91,7 +91,7 @@ glm_make_rad(float *deg) {
CGLM_INLINE
void
glm_make_deg(float *rad) {
*rad = *rad * 180.0f / CGLM_PI;
*rad = *rad * 180.0f / GLM_PIf;
}
/*!

View File

@@ -10,6 +10,6 @@
#define CGLM_VERSION_MAJOR 0
#define CGLM_VERSION_MINOR 4
#define CGLM_VERSION_PATCH 8
#define CGLM_VERSION_PATCH 9
#endif /* cglm_version_h */

View File

@@ -20,6 +20,12 @@ glmc_mat3_identity(mat3 mat) {
glm_mat3_identity(mat);
}
CGLM_EXPORT
void
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count) {
glm_mat3_identity_array(mat, count);
}
CGLM_EXPORT
void
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) {

View File

@@ -26,6 +26,12 @@ glmc_mat4_identity(mat4 mat) {
glm_mat4_identity(mat);
}
CGLM_EXPORT
void
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count) {
glm_mat4_identity_array(mat, count);
}
CGLM_EXPORT
void
glmc_mat4_pick3(mat4 mat, mat3 dest) {

View File

@@ -8,13 +8,18 @@
#include "../include/cglm/cglm.h"
#include "../include/cglm/call.h"
CGLM_EXPORT
void
glmc_quat_identity(versor q) {
glm_quat_identity(q);
}
CGLM_EXPORT
void
glmc_quat_identity_array(versor * __restrict q, size_t count) {
glm_quat_identity_array(q, count);
}
CGLM_EXPORT
void
glmc_quat_init(versor q, float x, float y, float z, float w) {

View File

@@ -12,7 +12,7 @@ test_affine(void **state) {
mat4 t1, t2, t3, t4, t5;
/* test translate is postmultiplied */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t1, t2, t3); /* R * T */
@@ -21,16 +21,16 @@ test_affine(void **state) {
test_assert_mat4_eq(t1, t3);
/* test rotate is postmultiplied */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t2, t1, t3); /* T * R */
glm_rotate(t2, M_PI_4, GLM_YUP);
glm_rotate(t2, GLM_PI_4f, GLM_YUP);
test_assert_mat4_eq(t2, t3);
/* test scale is postmultiplied */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){34, 57, 36});
glm_scale_make(t4, (vec3){3, 5, 6});
@@ -41,7 +41,7 @@ test_affine(void **state) {
test_assert_mat4_eq(t3, t5);
/* test translate_x */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){34, 0, 0});
glmc_mat4_mul(t1, t2, t3); /* R * T */
@@ -49,7 +49,7 @@ test_affine(void **state) {
test_assert_mat4_eq(t1, t3);
/* test translate_y */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){0, 57, 0});
glmc_mat4_mul(t1, t2, t3); /* R * T */
@@ -57,7 +57,7 @@ test_affine(void **state) {
test_assert_mat4_eq(t1, t3);
/* test translate_z */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){0, 0, 36});
glmc_mat4_mul(t1, t2, t3); /* R * T */
@@ -65,43 +65,43 @@ test_affine(void **state) {
test_assert_mat4_eq(t1, t3);
/* test rotate_x */
glmc_rotate_make(t1, M_PI_4, (vec3){1, 0, 0});
glmc_rotate_make(t1, GLM_PI_4f, (vec3){1, 0, 0});
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t2, t1, t3); /* T * R */
glm_rotate_x(t2, M_PI_4, t2);
glm_rotate_x(t2, GLM_PI_4f, t2);
test_assert_mat4_eq(t2, t3);
/* test rotate_y */
glmc_rotate_make(t1, M_PI_4, (vec3){0, 1, 0});
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 1, 0});
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t2, t1, t3); /* T * R */
glm_rotate_y(t2, M_PI_4, t2);
glm_rotate_y(t2, GLM_PI_4f, t2);
test_assert_mat4_eq(t2, t3);
/* test rotate_z */
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t2, t1, t3); /* T * R */
glm_rotate_z(t2, M_PI_4, t2);
glm_rotate_z(t2, GLM_PI_4f, t2);
test_assert_mat4_eq(t2, t3);
/* test rotate */
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
glm_translate_make(t2, (vec3){34, 57, 36});
glmc_mat4_mul(t2, t1, t3); /* T * R */
glmc_rotate(t2, M_PI_4, (vec3){0, 0, 1});
glmc_rotate(t2, GLM_PI_4f, (vec3){0, 0, 1});
test_assert_mat4_eq(t3, t2);
/* test scale_uni */
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
glm_translate_make(t2, (vec3){34, 57, 36});
glm_scale_make(t4, (vec3){3, 3, 3});