mirror of
https://github.com/recp/cglm.git
synced 2025-10-04 09:08:53 +00:00
add struct affine functions and headers
This commit is contained in:
@@ -45,6 +45,8 @@ cglm_HEADERS = include/cglm/version.h \
|
||||
include/cglm/mat4.h \
|
||||
include/cglm/mat3.h \
|
||||
include/cglm/mat2.h \
|
||||
include/cglm/affine-pre.h \
|
||||
include/cglm/affine-post.h \
|
||||
include/cglm/affine.h \
|
||||
include/cglm/affine-mat.h \
|
||||
include/cglm/vec2.h \
|
||||
|
184
include/cglm/struct/affine-post.h
Normal file
184
include/cglm/struct/affine-post.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE mat4s glms_translated(mat4s m, vec3s v);
|
||||
CGLM_INLINE mat4s glms_translated_x(mat4s m, float x);
|
||||
CGLM_INLINE mat4s glms_translated_y(mat4s m, float y);
|
||||
CGLM_INLINE mat4s glms_translated_z(mat4s m, float z);
|
||||
CGLM_INLINE mat4s glms_rotated_x(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotated_y(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotated_z(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotated(mat4s m, float angle, vec3s axis);
|
||||
CGLM_INLINE mat4s glms_rotated_at(mat4s m, vec3s pivot, float angle, vec3s axis);
|
||||
CGLM_INLINE mat4s glms_spinned(mat4s m, float angle, vec3s axis);
|
||||
*/
|
||||
|
||||
#ifndef cglms_affines_post_h
|
||||
#define cglms_affines_post_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../types-struct.h"
|
||||
#include "../affine.h"
|
||||
#include "vec3.h"
|
||||
#include "vec4.h"
|
||||
#include "mat4.h"
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by v vector
|
||||
* and stores result in same matrix
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] v translate vector [x, y, z]
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translated(mat4s m, vec3s v) {
|
||||
glm_translated(m.raw, v.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by x factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] x x factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translated_x(mat4s m, float x) {
|
||||
glm_translated_x(m.raw, x);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by y factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] y y factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translated_y(mat4s m, float y) {
|
||||
glm_translated_y(m.raw, y);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by z factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] z z factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translated_z(mat4s m, float z) {
|
||||
glm_translated_z(m.raw, z);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around X axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotated_x(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotated_x(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Y axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotated_y(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotated_y(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Z axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotated_z(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotated_z(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotated(mat4s m, float angle, vec3s axis) {
|
||||
glm_rotated(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform
|
||||
* around given axis by angle at given pivot point (rotation center)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] pivot rotation center
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotated_at(mat4s m, vec3s pivot, float angle, vec3s axis) {
|
||||
glm_rotated_at(m.raw, pivot.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_spinned(mat4s m, float angle, vec3s axis) {
|
||||
glm_spinned(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif /* cglms_affines_post_h */
|
184
include/cglm/struct/affine-pre.h
Normal file
184
include/cglm/struct/affine-pre.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v);
|
||||
CGLM_INLINE mat4s glms_translate_x(mat4s m, float x);
|
||||
CGLM_INLINE mat4s glms_translate_y(mat4s m, float y);
|
||||
CGLM_INLINE mat4s glms_translate_z(mat4s m, float z);
|
||||
CGLM_INLINE mat4s glms_rotate_x(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle);
|
||||
CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis);
|
||||
CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis);
|
||||
CGLM_INLINE mat4s glms_spin(mat4s m, float angle, vec3s axis);
|
||||
*/
|
||||
|
||||
#ifndef cglms_affines_pre_h
|
||||
#define cglms_affines_pre_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../types-struct.h"
|
||||
#include "../affine.h"
|
||||
#include "vec3.h"
|
||||
#include "vec4.h"
|
||||
#include "mat4.h"
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by v vector
|
||||
* and stores result in same matrix
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] v translate vector [x, y, z]
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate(mat4s m, vec3s v) {
|
||||
glm_translate(m.raw, v.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by x factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] x x factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_x(mat4s m, float x) {
|
||||
glm_translate_x(m.raw, x);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by y factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] y y factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_y(mat4s m, float y) {
|
||||
glm_translate_y(m.raw, y);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by z factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] z z factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_z(mat4s m, float z) {
|
||||
glm_translate_z(m.raw, z);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around X axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_x(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_x(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Y axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_y(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_y(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Z axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_z(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_z(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate(mat4s m, float angle, vec3s axis) {
|
||||
glm_rotate(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform
|
||||
* around given axis by angle at given pivot point (rotation center)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] pivot rotation center
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis) {
|
||||
glm_rotate_at(m.raw, pivot.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_spin(mat4s m, float angle, vec3s axis) {
|
||||
glm_spin(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif /* cglms_affines_pre_h */
|
@@ -40,63 +40,6 @@
|
||||
#include "vec4.h"
|
||||
#include "mat4.h"
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by v vector
|
||||
* and stores result in same matrix
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] v translate vector [x, y, z]
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate(mat4s m, vec3s v) {
|
||||
glm_translate(m.raw, v.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by x factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] x x factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_x(mat4s m, float x) {
|
||||
glm_translate_x(m.raw, x);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by y factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] y y factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_y(mat4s m, float y) {
|
||||
glm_translate_y(m.raw, y);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief translate existing transform matrix by z factor
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] z z factor
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_translate_z(mat4s m, float z) {
|
||||
glm_translate_z(m.raw, z);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief creates NEW translate transform matrix by v vector
|
||||
*
|
||||
@@ -156,54 +99,6 @@ glms_scale_uni(mat4s m, float s) {
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around X axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_x(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_x(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Y axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_y(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_y(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around Z axis by angle
|
||||
* and store result in dest
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @returns rotated matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_z(mat4s m, float angle) {
|
||||
mat4s r;
|
||||
glm_rotate_z(m.raw, angle, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief creates NEW rotation matrix by angle and axis
|
||||
*
|
||||
@@ -221,38 +116,6 @@ glms_rotate_make(float angle, vec3s axis) {
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate(mat4s m, float angle, vec3s axis) {
|
||||
glm_rotate(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform
|
||||
* around given axis by angle at given pivot point (rotation center)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] pivot rotation center
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis) {
|
||||
glm_rotate_at(m.raw, pivot.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief creates NEW rotation matrix by angle and axis at given point
|
||||
*
|
||||
@@ -274,21 +137,6 @@ glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis) {
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position)
|
||||
*
|
||||
* @param[in] m affine transfrom
|
||||
* @param[in] angle angle (radians)
|
||||
* @param[in] axis axis
|
||||
* @returns affine transfrom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4s
|
||||
glms_spin(mat4s m, float angle, vec3s axis) {
|
||||
glm_spin(m.raw, angle, axis.raw);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decompose scale vector
|
||||
*
|
||||
@@ -346,4 +194,7 @@ glms_decompose(mat4s m, vec4s * __restrict t, mat4s * __restrict r, vec3s * __re
|
||||
glm_decompose(m.raw, t->raw, r->raw, s->raw);
|
||||
}
|
||||
|
||||
#include "affine-pre.h"
|
||||
#include "affine-post.h"
|
||||
|
||||
#endif /* cglms_affines_h */
|
||||
|
@@ -158,6 +158,8 @@
|
||||
<ClInclude Include="..\include\cglm\simd\x86.h" />
|
||||
<ClInclude Include="..\include\cglm\sphere.h" />
|
||||
<ClInclude Include="..\include\cglm\struct.h" />
|
||||
<ClInclude Include="..\include\cglm\struct\affine-post.h" />
|
||||
<ClInclude Include="..\include\cglm\struct\affine-pre.h" />
|
||||
<ClInclude Include="..\include\cglm\struct\affine.h" />
|
||||
<ClInclude Include="..\include\cglm\struct\affine2d.h" />
|
||||
<ClInclude Include="..\include\cglm\struct\box.h" />
|
||||
|
@@ -597,5 +597,11 @@
|
||||
<ClInclude Include="..\include\cglm\affine-pre.h">
|
||||
<Filter>include\cglm</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\cglm\struct\affine-post.h">
|
||||
<Filter>include\cglm\struct</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\cglm\struct\affine-pre.h">
|
||||
<Filter>include\cglm\struct</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user