1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libftm_mat4.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/12 11:04:59 by charles #+# #+# */
/* Updated: 2020/05/14 16:46:03 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFTM_MAT4_H
# define LIBFTM_MAT4_H
# include <stddef.h>
# include <math.h>
# include "libftm_vec3.h"
typedef struct
{
float m[4 * 4];
} t_ftmmat4;
/*
** http://www.songho.ca/opengl/gl_projectionmatrix.html
*/
typedef struct
{
float near;
float far;
float left;
float right;
float top;
float bottom;
} t_ftmfrustum;
typedef struct
{
float near;
float far;
float width;
float height;
} t_ftmfrustum_sym;
t_ftmmat4 *ftm_mat4init_eye(t_ftmmat4 *mat4, float x);
t_ftmmat4 *ftm_mat4init_fill(t_ftmmat4 *mat4, float x);
t_ftmmat4 *ftm_mat4init_frustum(t_ftmmat4 *mat4, t_ftmfrustum *frustum);
t_ftmmat4 *ftm_mat4init_frustum_sym(
t_ftmmat4 *mat4, t_ftmfrustum_sym *frustum);
t_ftmmat4 *ftm_mat4init_perspective(
t_ftmmat4 *mat4, float fov, float aspect_ratio,
float near, float far);
t_ftmmat4 *ftm_mat4translate(t_ftmmat4 *mat4, float x, float y, float z);
t_ftmmat4 *ftm_mat4rotate(t_ftmmat4 *mat4, float radian, t_ftmvec3 *axis);
t_ftmmat4 *ftm_mat4scale(t_ftmmat4 *mat4, float x, float y, float z);
t_ftmmat4 *ftm_mat4mul(t_ftmmat4 *dst, t_ftmmat4 *other);
t_ftmmat4 *ftm_mat4set(t_ftmmat4 *mat4, size_t y, size_t x, float value);
float ftm_mat4get(t_ftmmat4 *mat4, size_t y, size_t x);
#endif
|