diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-05-13 11:48:22 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-05-13 11:48:22 +0200 |
| commit | 5635d61927b2fc864d92f9f7b40cdb164eeab275 (patch) | |
| tree | 5a9fa7c0cd9a4e662b0ad63d87143890880af173 /vendor | |
| parent | 723c4602c6ec9b74e841501754e651ef359f6385 (diff) | |
| download | scop-5635d61927b2fc864d92f9f7b40cdb164eeab275.tar.gz scop-5635d61927b2fc864d92f9f7b40cdb164eeab275.tar.bz2 scop-5635d61927b2fc864d92f9f7b40cdb164eeab275.zip | |
Added model center translation
Diffstat (limited to 'vendor')
| m--------- | vendor/libft | 0 | ||||
| -rw-r--r-- | vendor/libftm/inc/libftm_vec3.h | 13 | ||||
| -rw-r--r-- | vendor/libftm/src/mat4/ftm_mat4rotate.c | 29 |
3 files changed, 26 insertions, 16 deletions
diff --git a/vendor/libft b/vendor/libft -Subproject 966eb29634a84496e0851ef2b5a7d64f413d33e +Subproject 3a3915eb488ebc8cf6c686dce85aaee1af64dd9 diff --git a/vendor/libftm/inc/libftm_vec3.h b/vendor/libftm/inc/libftm_vec3.h index e9df2c7..c40d6c8 100644 --- a/vendor/libftm/inc/libftm_vec3.h +++ b/vendor/libftm/inc/libftm_vec3.h @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/12 11:02:29 by charles #+# #+# */ -/* Updated: 2020/05/12 11:04:08 by charles ### ########.fr */ +/* Updated: 2020/05/13 11:13:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,16 @@ typedef struct { - float v[3]; + union + { + float v[3]; + struct + { + float x; + float y; + float z; + }; + }; } t_ftmvec3; t_ftmvec3 *ftm_vec3init(t_ftmvec3 *vec3, float x, float y, float z); diff --git a/vendor/libftm/src/mat4/ftm_mat4rotate.c b/vendor/libftm/src/mat4/ftm_mat4rotate.c index 6d0432e..0d9f32b 100644 --- a/vendor/libftm/src/mat4/ftm_mat4rotate.c +++ b/vendor/libftm/src/mat4/ftm_mat4rotate.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/12 11:44:18 by charles #+# #+# */ -/* Updated: 2020/05/12 17:07:23 by charles ### ########.fr */ +/* Updated: 2020/05/12 19:52:55 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,6 +41,7 @@ t_ftmmat4 *ftm_mat4rotate(t_ftmmat4 *mat4, float theta, t_ftmvec3 *axis) float z; float sin_t; float cos_t; + float m_cos_t; t_ftmmat4 rot; x = axis->v[0]; @@ -48,23 +49,23 @@ t_ftmmat4 *ftm_mat4rotate(t_ftmmat4 *mat4, float theta, t_ftmvec3 *axis) z = axis->v[2]; sin_t = sinf(theta); cos_t = cosf(theta); - ftm_mat4init_fill(&rot, 0.0); - ftm_mat4set(&rot, 0, 0, cos_t + x * x * (1 - cos_t)); - ftm_mat4set(&rot, 1, 0, y * x * (1 - cos_t) + z * sin_t); - ftm_mat4set(&rot, 2, 0, z * x * (1 - cos_t) + y * sin_t); + m_cos_t = 1.0 - cos_t; + ftm_mat4init_eye(&rot, 1.0); + ftm_mat4set(&rot, 0, 0, cos_t + x * x * m_cos_t); + ftm_mat4set(&rot, 1, 0, y * x * m_cos_t + z * sin_t); + ftm_mat4set(&rot, 2, 0, z * x * m_cos_t - y * sin_t); ftm_mat4set(&rot, 3, 0, 0.0); - ftm_mat4set(&rot, 0, 1, x * y * (1 - cos_t) - z * sin_t); - ftm_mat4set(&rot, 1, 1, cos_t + y * y * (1 - cos_t)); - ftm_mat4set(&rot, 2, 1, z * y * (1 - cos_t) + x * sin_t); - ftm_mat4set(&rot, 3, 1, 0); + ftm_mat4set(&rot, 0, 1, x * y * m_cos_t - z * sin_t); + ftm_mat4set(&rot, 1, 1, cos_t + y * y * m_cos_t); + ftm_mat4set(&rot, 2, 1, z * y * m_cos_t + x * sin_t); + ftm_mat4set(&rot, 3, 1, 0.0); - ftm_mat4set(&rot, 0, 2, x * z * (1 - cos_t) + y * sin_t); - ftm_mat4set(&rot, 1, 2, y * z * (1 - cos_t) - x * sin_t); - ftm_mat4set(&rot, 2, 2, cos_t + z * z * (1 - cos_t)); - ftm_mat4set(&rot, 3, 2, 0); + ftm_mat4set(&rot, 0, 2, x * z * m_cos_t + y * sin_t); + ftm_mat4set(&rot, 1, 2, y * z * m_cos_t - x * sin_t); + ftm_mat4set(&rot, 2, 2, cos_t + z * z * m_cos_t); + ftm_mat4set(&rot, 3, 2, 0.0); - ftm_mat4set(&rot, 3, 3, 1.0); ftm_mat4mul(mat4, &rot); return (mat4); } |
