Add vec3_rotate and vec3_mul_vec3.

This commit is contained in:
Roz K 2022-12-20 15:26:53 +01:00
parent abf1e87a36
commit ccce6c5d83
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
3 changed files with 40 additions and 0 deletions

View File

@ -105,6 +105,20 @@ def _floatp(x):
assert x.typecode == 'f'
return x.buffer_info()[0]
vec3_rotate = _lib.rk_vec3_rotate
vec3_rotate.argtypes = (
_vec3p, # ret
_vec3p, # vec3
_vec3p, # axis
ctypes.c_float) # angle
vec3_mul_vec3 = _lib.rk_vec3_mul_vec3
vec3_mul_vec3.argtypes = (
_vec3p, # ret
_vec3p, # a
_vec3p) # b
mat3_rotation = _lib.rk_mat3_rotation
mat3_rotation.argtypes = (
_mat3p, # ret

View File

@ -15,6 +15,21 @@
#include "math.hpp"
void rk_vec3_rotate(
rk_vec3 & ret,
rk_vec3 const & vec3,
rk_vec3 const & axis,
float const angle) {
ret = glm::angleAxis(angle, axis) * vec3;
}
void rk_vec3_mul_vec3(
rk_vec3 & ret,
rk_vec3 const & a,
rk_vec3 const & b) {
ret = a * b;
}
void rk_mat3_rotation(
rk_mat3 & ret,
rk_vec3 const & axis,

View File

@ -26,6 +26,17 @@ typedef glm::vec4 rk_vec4;
typedef glm::mat3 rk_mat3;
typedef glm::mat4 rk_mat4;
RK_EXPORT void rk_vec3_rotate(
rk_vec3 & ret,
rk_vec3 const & vec3,
rk_vec3 const & axis,
float const angle);
RK_EXPORT void rk_vec3_mul_vec3(
rk_vec3 & ret,
rk_vec3 const & a,
rk_vec3 const & b);
RK_EXPORT void rk_mat3_rotation(
rk_mat3 & ret,
rk_vec3 const & axis,