mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
10 Commits
vec-update
...
v0.5.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d17c99215d | ||
|
|
dc6eb492c1 | ||
|
|
7219b02d23 | ||
|
|
21834b4ffb | ||
|
|
2ef9c23a6c | ||
|
|
92605f845a | ||
|
|
b23d65bef5 | ||
|
|
2f632c6311 | ||
|
|
b47d148b81 | ||
|
|
a5bc2f710e |
68
README.md
68
README.md
@@ -24,6 +24,8 @@ you have the latest version
|
||||
- **[major change]** by starting v0.4.0, quaternions are stored as [x, y, z, w], it was [w, x, y, z] in v0.3.5 and earlier versions
|
||||
- **[api rename]** by starting v0.4.5, **glm_simd** functions are renamed to **glmm_**
|
||||
- **[new option]** by starting v0.4.5, you can disable alignment requirement, check options in docs.
|
||||
- **[major change]** by starting v0.5.0, vec3 functions use **glm_vec3_** namespace, it was **glm_vec_** until v0.5.0
|
||||
- **[major change]** by starting v0.5.1, built-in alignment is removed from **vec3** and **mat3** types
|
||||
|
||||
#### Note for C++ developers:
|
||||
If you don't aware about original GLM library yet, you may also want to look at:
|
||||
@@ -81,6 +83,7 @@ Currently *cglm* uses default clip space configuration (-1, 1) for camera functi
|
||||
- frustum (extract view frustum planes, corners...)
|
||||
- bounding box (AABB in Frustum (culling), crop, merge...)
|
||||
- project, unproject
|
||||
- and other...
|
||||
|
||||
<hr />
|
||||
|
||||
@@ -122,39 +125,6 @@ glm_mul(T, R, modelMat);
|
||||
glm_inv_tr(modelMat);
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/cglm/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/cglm#backer)]
|
||||
|
||||
<a href="https://opencollective.com/cglm#backers" target="_blank"><img src="https://opencollective.com/cglm/backers.svg?width=890"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/cglm#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/cglm/sponsor/0/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/1/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/2/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/3/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/4/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/5/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/6/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/7/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/8/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/9/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/9/avatar.svg"></a>
|
||||
|
||||
|
||||
|
||||
## License
|
||||
MIT. check the LICENSE file
|
||||
|
||||
## Build
|
||||
|
||||
### Unix (Autotools)
|
||||
@@ -284,3 +254,35 @@ You can pass same way to another APIs e.g. Vulkan, DX...
|
||||
- [ ] Unaligned operations (e.g. `glm_umat4_mul`)
|
||||
- [x] Extra documentation
|
||||
- [ ] ARM Neon Arch (In Progress)
|
||||
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/cglm/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/cglm#backer)]
|
||||
|
||||
<a href="https://opencollective.com/cglm#backers" target="_blank"><img src="https://opencollective.com/cglm/backers.svg?width=890"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/cglm#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/cglm/sponsor/0/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/1/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/2/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/3/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/4/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/5/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/6/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/7/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/8/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/cglm/sponsor/9/website" target="_blank"><img src="https://opencollective.com/cglm/sponsor/9/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
MIT. check the LICENSE file
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#*****************************************************************************
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([cglm], [0.5.0], [info@recp.me])
|
||||
AC_INIT([cglm], [0.5.1], [info@recp.me])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'0.5.0'
|
||||
version = u'0.5.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'0.5.0'
|
||||
release = u'0.5.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -29,6 +29,7 @@ Functions:
|
||||
#. :c:func:`glm_mat3_scale`
|
||||
#. :c:func:`glm_mat3_det`
|
||||
#. :c:func:`glm_mat3_inv`
|
||||
#. :c:func:`glm_mat3_trace`
|
||||
#. :c:func:`glm_mat3_swap_col`
|
||||
#. :c:func:`glm_mat3_swap_row`
|
||||
|
||||
@@ -133,6 +134,16 @@ Functions documentation
|
||||
| *[in]* **mat** matrix
|
||||
| *[out]* **dest** destination (inverse matrix)
|
||||
|
||||
.. c:function:: void glm_mat3_trace(mat3 m)
|
||||
|
||||
| sum of the elements on the main diagonal from upper left to the lower right
|
||||
|
||||
Parameters:
|
||||
| *[in]* **m** matrix
|
||||
|
||||
Returns:
|
||||
trace of matrix
|
||||
|
||||
.. c:function:: void glm_mat3_swap_col(mat3 mat, int col1, int col2)
|
||||
|
||||
swap two matrix columns
|
||||
|
||||
@@ -33,6 +33,8 @@ Functions:
|
||||
#. :c:func:`glm_mat4_mulN`
|
||||
#. :c:func:`glm_mat4_mulv`
|
||||
#. :c:func:`glm_mat4_mulv3`
|
||||
#. :c:func:`glm_mat3_trace`
|
||||
#. :c:func:`glm_mat3_trace3`
|
||||
#. :c:func:`glm_mat4_quat`
|
||||
#. :c:func:`glm_mat4_transpose_to`
|
||||
#. :c:func:`glm_mat4_transpose`
|
||||
@@ -156,6 +158,27 @@ Functions documentation
|
||||
| *[in]* **v** vec3 (right, column vector)
|
||||
| *[out]* **dest** vec3 (result, column vector)
|
||||
|
||||
.. c:function:: void glm_mat4_trace(mat4 m)
|
||||
|
||||
| sum of the elements on the main diagonal from upper left to the lower right
|
||||
|
||||
Parameters:
|
||||
| *[in]* **m** matrix
|
||||
|
||||
Returns:
|
||||
trace of matrix
|
||||
|
||||
.. c:function:: void glm_mat4_trace3(mat4 m)
|
||||
|
||||
| trace of matrix (rotation part)
|
||||
| sum of the elements on the main diagonal from upper left to the lower right
|
||||
|
||||
Parameters:
|
||||
| *[in]* **m** matrix
|
||||
|
||||
Returns:
|
||||
trace of matrix
|
||||
|
||||
.. c:function:: void glm_mat4_quat(mat4 m, versor dest)
|
||||
|
||||
convert mat4's rotation part to quaternion
|
||||
|
||||
@@ -39,7 +39,6 @@ Functions:
|
||||
#. :c:func:`glm_vec3_zero`
|
||||
#. :c:func:`glm_vec3_one`
|
||||
#. :c:func:`glm_vec3_dot`
|
||||
#. :c:func:`glm_vec3_cross`
|
||||
#. :c:func:`glm_vec3_norm2`
|
||||
#. :c:func:`glm_vec3_norm`
|
||||
#. :c:func:`glm_vec3_add`
|
||||
@@ -65,6 +64,8 @@ Functions:
|
||||
#. :c:func:`glm_vec3_negate_to`
|
||||
#. :c:func:`glm_vec3_normalize`
|
||||
#. :c:func:`glm_vec3_normalize_to`
|
||||
#. :c:func:`glm_vec3_cross`
|
||||
#. :c:func:`glm_vec3_crossn`
|
||||
#. :c:func:`glm_vec3_distance2`
|
||||
#. :c:func:`glm_vec3_distance`
|
||||
#. :c:func:`glm_vec3_angle`
|
||||
@@ -125,12 +126,21 @@ Functions documentation
|
||||
|
||||
.. c:function:: void glm_vec3_cross(vec3 a, vec3 b, vec3 d)
|
||||
|
||||
cross product
|
||||
cross product of two vector (RH)
|
||||
|
||||
Parameters:
|
||||
| *[in]* **a** source 1
|
||||
| *[in]* **b** source 2
|
||||
| *[out]* **d** destination
|
||||
| *[in]* **a** vector 1
|
||||
| *[in]* **b** vector 2
|
||||
| *[out]* **dest** destination
|
||||
|
||||
.. c:function:: void glm_vec3_crossn(vec3 a, vec3 b, vec3 dest)
|
||||
|
||||
cross product of two vector (RH) and normalize the result
|
||||
|
||||
Parameters:
|
||||
| *[in]* **a** vector 1
|
||||
| *[in]* **b** vector 2
|
||||
| *[out]* **dest** destination
|
||||
|
||||
.. c:function:: float glm_vec3_norm2(vec3 v)
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ CGLM_EXPORT
|
||||
void
|
||||
glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat3_trace(mat3 m);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_mat3_quat(mat3 m, versor dest);
|
||||
|
||||
@@ -61,6 +61,14 @@ CGLM_EXPORT
|
||||
void
|
||||
glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat4_trace(mat4 m);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat4_trace3(mat4 m);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_mat4_quat(mat4 m, versor dest);
|
||||
|
||||
@@ -42,7 +42,11 @@ glmc_vec3_dot(vec3 a, vec3 b);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec3_cross(vec3 a, vec3 b, vec3 d);
|
||||
glmc_vec3_cross(vec3 a, vec3 b, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec3_crossn(vec3 a, vec3 b, vec3 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
|
||||
@@ -323,9 +323,7 @@ glm_lookat(vec3 eye,
|
||||
glm_vec3_sub(center, eye, f);
|
||||
glm_vec3_normalize(f);
|
||||
|
||||
glm_vec3_cross(f, up, s);
|
||||
glm_vec3_normalize(s);
|
||||
|
||||
glm_vec3_crossn(f, up, s);
|
||||
glm_vec3_cross(s, f, u);
|
||||
|
||||
dest[0][0] = s[0];
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
|
||||
CGLM_INLINE void glm_mat3_transpose(mat3 m);
|
||||
CGLM_INLINE void glm_mat3_mulv(mat3 m, vec3 v, vec3 dest);
|
||||
CGLM_INLINE float glm_mat3_trace(mat3 m);
|
||||
CGLM_INLINE void glm_mat3_scale(mat3 m, float s);
|
||||
CGLM_INLINE float glm_mat3_det(mat3 mat);
|
||||
CGLM_INLINE void glm_mat3_inv(mat3 mat, mat3 dest);
|
||||
@@ -207,6 +208,18 @@ glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
|
||||
dest[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief trace of matrix
|
||||
*
|
||||
* sum of the elements on the main diagonal from upper left to the lower right
|
||||
*
|
||||
* @param[in] m matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_mat3_trace(mat3 m) {
|
||||
return m[0][0] + m[1][1] + m[2][2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief convert mat3 to quaternion
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
CGLM_INLINE void glm_mat4_mulN(mat4 *matrices[], int len, mat4 dest);
|
||||
CGLM_INLINE void glm_mat4_mulv(mat4 m, vec4 v, vec4 dest);
|
||||
CGLM_INLINE void glm_mat4_mulv3(mat4 m, vec3 v, vec3 dest);
|
||||
CGLM_INLINE float glm_mat4_trace(mat4 m);
|
||||
CGLM_INLINE float glm_mat4_trace3(mat4 m);
|
||||
CGLM_INLINE void glm_mat4_transpose_to(mat4 m, mat4 dest);
|
||||
CGLM_INLINE void glm_mat4_transpose(mat4 m);
|
||||
CGLM_INLINE void glm_mat4_scale_p(mat4 m, float s);
|
||||
@@ -338,6 +340,32 @@ glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief trace of matrix
|
||||
*
|
||||
* sum of the elements on the main diagonal from upper left to the lower right
|
||||
*
|
||||
* @param[in] m matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_mat4_trace(mat4 m) {
|
||||
return m[0][0] + m[1][1] + m[2][2] + m[3][3];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief trace of matrix (rotation part)
|
||||
*
|
||||
* sum of the elements on the main diagonal from upper left to the lower right
|
||||
*
|
||||
* @param[in] m matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_mat4_trace3(mat4 m) {
|
||||
return m[0][0] + m[1][1] + m[2][2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief convert mat4's rotation part to quaternion
|
||||
*
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* do not use alignment for older visual studio versions */
|
||||
#if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
||||
# define CGLM_ALL_UNALIGNED
|
||||
# define CGLM_ALIGN(X) /* no alignment */
|
||||
#else
|
||||
# define CGLM_ALIGN(X) __declspec(align(X))
|
||||
#endif
|
||||
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
|
||||
# define CGLM_ALL_UNALIGNED
|
||||
# define CGLM_ALIGN(X) /* no alignment */
|
||||
# else
|
||||
# define CGLM_ALIGN(X) __declspec(align(X))
|
||||
# endif
|
||||
#else
|
||||
# define CGLM_ALIGN(X) __attribute((aligned(X)))
|
||||
#endif
|
||||
@@ -33,20 +33,18 @@
|
||||
#endif
|
||||
|
||||
typedef float vec2[2];
|
||||
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
||||
typedef float vec3[3];
|
||||
typedef int ivec3[3];
|
||||
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
||||
typedef vec4 versor;
|
||||
typedef vec3 mat3[3];
|
||||
|
||||
#ifdef __AVX__
|
||||
typedef CGLM_ALIGN_IF(32) vec3 mat3[3];
|
||||
typedef CGLM_ALIGN_IF(32) vec4 mat4[4];
|
||||
#else
|
||||
typedef vec3 mat3[3];
|
||||
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
||||
#endif
|
||||
|
||||
typedef vec4 versor;
|
||||
|
||||
#define GLM_E 2.71828182845904523536028747135266250 /* e */
|
||||
#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
|
||||
#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
CGLM_INLINE void glm_vec3_zero(vec3 v);
|
||||
CGLM_INLINE void glm_vec3_one(vec3 v);
|
||||
CGLM_INLINE float glm_vec3_dot(vec3 a, vec3 b);
|
||||
CGLM_INLINE void glm_vec3_cross(vec3 a, vec3 b, vec3 d);
|
||||
CGLM_INLINE float glm_vec3_norm2(vec3 v);
|
||||
CGLM_INLINE float glm_vec3_norm(vec3 v);
|
||||
CGLM_INLINE void glm_vec3_add(vec3 a, vec3 b, vec3 dest);
|
||||
@@ -47,6 +46,8 @@
|
||||
CGLM_INLINE void glm_vec3_inv_to(vec3 v, vec3 dest);
|
||||
CGLM_INLINE void glm_vec3_normalize(vec3 v);
|
||||
CGLM_INLINE void glm_vec3_normalize_to(vec3 v, vec3 dest);
|
||||
CGLM_INLINE void glm_vec3_cross(vec3 a, vec3 b, vec3 d);
|
||||
CGLM_INLINE void glm_vec3_crossn(vec3 a, vec3 b, vec3 dest);
|
||||
CGLM_INLINE float glm_vec3_distance(vec3 a, vec3 b);
|
||||
CGLM_INLINE float glm_vec3_angle(vec3 a, vec3 b);
|
||||
CGLM_INLINE void glm_vec3_rotate(vec3 v, float angle, vec3 axis);
|
||||
@@ -166,22 +167,6 @@ glm_vec3_dot(vec3 a, vec3 b) {
|
||||
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief vec3 cross product
|
||||
*
|
||||
* @param[in] a source 1
|
||||
* @param[in] b source 2
|
||||
* @param[out] d destination
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec3_cross(vec3 a, vec3 b, vec3 d) {
|
||||
/* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */
|
||||
d[0] = a[1] * b[2] - a[2] * b[1];
|
||||
d[1] = a[2] * b[0] - a[0] * b[2];
|
||||
d[2] = a[0] * b[1] - a[1] * b[0];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief norm * norm (magnitude) of vec
|
||||
*
|
||||
@@ -444,7 +429,7 @@ glm_vec3_maxadd(vec3 a, vec3 b, vec3 dest) {
|
||||
* it applies += operator so dest must be initialized
|
||||
*
|
||||
* @param[in] a vector
|
||||
* @param[in] s scalar
|
||||
* @param[in] b scalar
|
||||
* @param[out] dest dest += min(a, b)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
@@ -521,6 +506,36 @@ glm_vec3_normalize_to(vec3 v, vec3 dest) {
|
||||
glm_vec3_scale(v, 1.0f / norm, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief cross product of two vector (RH)
|
||||
*
|
||||
* @param[in] a vector 1
|
||||
* @param[in] b vector 2
|
||||
* @param[out] dest destination
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec3_cross(vec3 a, vec3 b, vec3 dest) {
|
||||
/* (u2.v3 - u3.v2, u3.v1 - u1.v3, u1.v2 - u2.v1) */
|
||||
dest[0] = a[1] * b[2] - a[2] * b[1];
|
||||
dest[1] = a[2] * b[0] - a[0] * b[2];
|
||||
dest[2] = a[0] * b[1] - a[1] * b[0];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief cross product of two vector (RH) and normalize the result
|
||||
*
|
||||
* @param[in] a vector 1
|
||||
* @param[in] b vector 2
|
||||
* @param[out] dest destination
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec3_crossn(vec3 a, vec3 b, vec3 dest) {
|
||||
glm_vec3_cross(a, b, dest);
|
||||
glm_vec3_normalize(dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief angle betwen two vector
|
||||
*
|
||||
|
||||
@@ -331,9 +331,9 @@ glm_vec4_subs(vec4 v, float s, vec4 dest) {
|
||||
/*!
|
||||
* @brief multiply two vector (component-wise multiplication)
|
||||
*
|
||||
* @param a vector1
|
||||
* @param b vector2
|
||||
* @param d dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3])
|
||||
* @param a vector1
|
||||
* @param b vector2
|
||||
* @param dest dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3])
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
@@ -426,7 +426,6 @@ glm_vec4_divs(vec4 v, float s, vec4 dest) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* @brief add two vectors and add result to sum
|
||||
*
|
||||
@@ -553,7 +552,7 @@ glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest) {
|
||||
* it applies += operator so dest must be initialized
|
||||
*
|
||||
* @param[in] a vector
|
||||
* @param[in] s scalar
|
||||
* @param[in] b scalar
|
||||
* @param[out] dest dest += min(a, b)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
|
||||
#define CGLM_VERSION_MAJOR 0
|
||||
#define CGLM_VERSION_MINOR 5
|
||||
#define CGLM_VERSION_PATCH 0
|
||||
#define CGLM_VERSION_PATCH 1
|
||||
|
||||
#endif /* cglm_version_h */
|
||||
|
||||
@@ -50,6 +50,12 @@ glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
|
||||
glm_mat3_mulv(m, v, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat3_trace(mat3 m) {
|
||||
return glm_mat3_trace(m);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_mat3_quat(mat3 m, versor dest) {
|
||||
|
||||
12
src/mat4.c
12
src/mat4.c
@@ -74,6 +74,18 @@ glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) {
|
||||
glm_mat4_mulv3(m, v, last, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat4_trace(mat4 m) {
|
||||
return glm_mat4_trace(m);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_mat4_trace3(mat4 m) {
|
||||
return glm_mat4_trace3(m);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_mat4_quat(mat4 m, versor dest) {
|
||||
|
||||
10
src/vec3.c
10
src/vec3.c
@@ -40,8 +40,14 @@ glmc_vec3_dot(vec3 a, vec3 b) {
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec3_cross(vec3 a, vec3 b, vec3 d) {
|
||||
glm_vec3_cross(a, b, d);
|
||||
glmc_vec3_cross(vec3 a, vec3 b, vec3 dest) {
|
||||
glm_vec3_cross(a, b, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec3_crossn(vec3 a, vec3 b, vec3 dest) {
|
||||
glm_vec3_crossn(a, b, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
|
||||
@@ -24,9 +24,9 @@ test_mat3(void **state) {
|
||||
for (i = 0; i < m; i++) {
|
||||
for (j = 0; j < n; j++) {
|
||||
if (i == j)
|
||||
assert_true(m3[i][j] == 1.0f);
|
||||
assert_true(glm_eq(m3[i][j], 1.0f));
|
||||
else
|
||||
assert_true(m3[i][j] == 0.0f);
|
||||
assert_true(glm_eq(m3[i][j], 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ test_mat4(void **state) {
|
||||
for (i = 0; i < m; i++) {
|
||||
for (j = 0; j < n; j++) {
|
||||
if (i == j)
|
||||
assert_true(m3[i][j] == 1.0f);
|
||||
assert_true(glm_eq(m3[i][j], 1.0f));
|
||||
else
|
||||
assert_true(m3[i][j] == 0.0f);
|
||||
assert_true(glm_eq(m3[i][j], 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ test_quat(void **state) {
|
||||
|
||||
/* 0. test identiy quat */
|
||||
glm_quat_identity(q4);
|
||||
assert_true(glm_quat_real(q4) == cosf(glm_rad(0.0f) * 0.5f));
|
||||
assert_true(glm_eq(glm_quat_real(q4), cosf(glm_rad(0.0f) * 0.5f)));
|
||||
glm_quat_mat4(q4, rot1);
|
||||
test_assert_mat4_eq2(rot1, GLM_MAT4_IDENTITY, 0.000009);
|
||||
|
||||
@@ -118,7 +118,7 @@ test_quat(void **state) {
|
||||
/* 9. test imag, real */
|
||||
|
||||
/* 9.1 real */
|
||||
assert_true(glm_quat_real(q4) == cosf(glm_rad(-90.0f) * 0.5f));
|
||||
assert_true(glm_eq(glm_quat_real(q4), cosf(glm_rad(-90.0f) * 0.5f)));
|
||||
|
||||
/* 9.1 imag */
|
||||
glm_quat_imag(q4, imag);
|
||||
|
||||
Reference in New Issue
Block a user