miniRT
By Marcelo Magalhães and Ygor G. Sena, 2023.
matrices.h
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* matrices.h :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: yde-goes <yde-goes@student.42sp.org.br> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2023/03/17 13:52:06 by yde-goes #+# #+# */
9 /* Updated: 2023/06/16 13:40:07 by yde-goes ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
14 #ifndef MATRICES_H
15 # define MATRICES_H
16 
17 # define MAX 4
18 # define SIZE 16
19 
20 # include "libft.h"
21 # include "tuples.h"
22 
33 typedef struct s_matrix
34 {
35  double matrix[MAX][MAX];
36  size_t size;
38 
54 typedef struct s_shearing
55 {
56  double p1;
57  double p2;
59 
60 /* ************************************************************************** */
61 /* MX_OPERATIONS.C */
62 /* ************************************************************************** */
63 
75 
88 
101 
120 
121 /* ************************************************************************** */
122 /* MX_TRANSFORMATIONS.C */
123 /* ************************************************************************** */
124 
137 t_matrix translation(double x, double y, double z);
138 
152 t_matrix scaling(double x, double y, double z);
153 
172 
173 /* ************************************************************************** */
174 /* MX_ROTATIONS.C */
175 /* ************************************************************************** */
176 
184 t_matrix rotation_x(double rad);
185 
193 t_matrix rotation_y(double rad);
194 
202 t_matrix rotation_z(double rad);
203 
204 /* ************************************************************************** */
205 /* MX_ATTRIBUTES.C */
206 /* ************************************************************************** */
207 
220 double get_determinant(t_matrix t);
221 
236 t_matrix get_submatrix(t_matrix t, size_t del_row, size_t del_col);
237 
248 double get_minor(t_matrix t, size_t row, size_t col);
249 
265 double get_cofactor(t_matrix t, size_t row, size_t col);
266 
276 
277 /* ************************************************************************** */
278 /* MX_UTILS.C */
279 /* ************************************************************************** */
280 
281 t_shearing to_shear(double a, double b);
282 
292 t_matrix create_matrix(const double table[MAX][MAX], size_t size);
293 
305 
316 t_bool is_invertible(t_matrix t);
317 
325 
326 #endif
t_matrix get_identity_matrix(void)
This fucntion gets a new matrix with the special attribute of being an identity matrix or multiplicat...
Definition: mx_attributes.c:72
double get_determinant(t_matrix t)
This function gets the determinant of a given matrix. The determinant is a number that is derived fro...
Definition: mx_attributes.c:15
t_matrix rotation_z(double rad)
This function rotates a given matrix around the z-axis.
Definition: mx_rotations.c:81
t_matrix multiply_mx_mx(t_matrix a, t_matrix b)
This function multiplies two matrices. "Mx" means matrix. For more information about how matrix multi...
Definition: mx_operations.c:16
t_matrix rotation_y(double rad)
This function rotates a given matrix around the y-axis.
Definition: mx_rotations.c:67
t_matrix scaling(double x, double y, double z)
This function scales a given matrix by multiplication. When applied to an object centered at the orig...
Definition: mx_transformations.c:27
struct s_shearing t_shearing
The struct t_shearing is a helper type to allow shearing operation on matrices. Shearing (or skew) is...
int compare_matrix(t_matrix a, t_matrix b)
The function compare_matrix() checks if two matrices are identical or not. The matrices passed as par...
Definition: mx_utils.c:29
t_matrix translation(double x, double y, double z)
This function translates a given matrix. Translation is a transformation that moves a point....
Definition: mx_transformations.c:15
double get_minor(t_matrix t, size_t row, size_t col)
This function gets the minor of a given matrix. To put it differently, the minor of an element at row...
Definition: mx_attributes.c:52
t_matrix transpose(t_matrix t)
This function transposes the matrix passed to the function as parameter. In other words,...
Definition: mx_operations.c:54
t_matrix rotation_x(double rad)
This function rotates a given matrix around the x-axis.
Definition: mx_rotations.c:53
t_matrix shearing(t_shearing x, t_shearing y, t_shearing z)
This function applies shearing (or skew) transformation to a given matrix. It has the effect of makin...
Definition: mx_transformations.c:39
t_bool is_invertible(t_matrix t)
This function checks if a given matrix is invertible or not. Not every matrix is invertible....
Definition: mx_utils.c:34
t_matrix rotation_matrix(t_vector vector)
Calculates the rotation matrix for a given vector.
Definition: mx_rotations.c:17
t_matrix get_submatrix(t_matrix t, size_t del_row, size_t del_col)
This functions gets the submatrix of a given matrix. That is, what is left when you delete a single r...
Definition: mx_attributes.c:33
struct s_matrix t_matrix
The struct t_matrix stores a matrix up to 4x4 and size of 16. A matrix is a grid of numbers that can ...
t_matrix create_matrix(const double table[MAX][MAX], size_t size)
This function creates a matrix up to 4x4 and, therefore, size of 16 (4x4). For instance,...
Definition: mx_utils.c:20
t_matrix inverse(t_matrix t)
This function get the inverse of a given matrix. That is, if you multiply some matrix A by another ma...
Definition: mx_operations.c:70
double get_cofactor(t_matrix t, size_t row, size_t col)
This function gets the cofactor of a given matrix. Cofactors are minors that have (possibly) had thei...
Definition: mx_attributes.c:62
t_tuple multiply_tp_mx(t_matrix a, t_tuple b)
This function multiplies a matrix by a tuple. "Mx" means matrix and "tp" means tuple....
Definition: mx_operations.c:38
The struct t_matrix stores a matrix up to 4x4 and size of 16. A matrix is a grid of numbers that can ...
Definition: matrices.h:34
The struct t_shearing is a helper type to allow shearing operation on matrices. Shearing (or skew) is...
Definition: matrices.h:55
Tuple means a list of ordered things. The struct t_tuple stores coordinates for a left-handed coordin...
Definition: tuples.h:33
t_tuple vector(double x, double y, double z)
This function is a simplification of the function tuple(). It will create a point with the given coor...
Definition: models.c:25