Handles OpenGL matrix stuff.
More...
#include <stdio.h>
#include "mat4.h"
Go to the source code of this file.
|
| void | mat4_print (const mat4 *m) |
| |
| void | mat4_mul (mat4 *out, const mat4 *m1, const mat4 *m2) |
| | Multiplies two matrices (out = m1 * m2).
|
| |
| void | mat4_apply (mat4 *lhs, const mat4 *rhs) |
| | Applies a transformation to another, storing the result in the left hand side.
|
| |
| void | mat4_scale (mat4 *m, double x, double y, double z) |
| | Scales a homogeneous transformation matrix.
|
| |
| void | mat4_translate (mat4 *m, double x, double y, double z) |
| | Translates a homogenous transformation matrix.
|
| |
| void | mat4_rotate2d (mat4 *m, double angle) |
| | Rotates an angle, in radians, around the z axis.
|
| |
| void | mat4_rotate2dv (mat4 *m, double c, double s) |
| | Rotates the +x axis to the given vector.
|
| |
| void | mat4_rotate (mat4 *m, double angle, double x, double y, double z) |
| | Multiplies the given matrix by a rotation. (Follows the right-hand rule.)
|
| |
| mat4 | mat4_identity (void) |
| | Creates an identity matrix.
|
| |
| mat4 | mat4_ortho (double left, double right, double bottom, double top, double nearVal, double farVal) |
| | Creates an orthographic projection matrix.
|
| |
| mat4 | mat4_lookat (const vec3 *eye, const vec3 *center, const vec3 *up) |
| | Creates a matrix with a transformation to look at a center point from an eye with an up vector.
|
| |
| mat4 | mat4_perspective (double fov, double aspect, double near, double far) |
| | Creates a matrix with a perspective transformation.
|
| |
Handles OpenGL matrix stuff.
Definition in file mat4.c.
◆ mat4_apply()
| void mat4_apply |
( |
mat4 * | lhs, |
|
|
const mat4 * | rhs ) |
Applies a transformation to another, storing the result in the left hand side.
- Parameters
-
| [in,out] | lhs | Left hand side matrix. |
| [in] | rhs | Right hand side matrix. |
Definition at line 53 of file mat4.c.
◆ mat4_identity()
| mat4 mat4_identity |
( |
void | | ) |
|
Creates an identity matrix.
- Returns
- A new identity matrix.
Definition at line 195 of file mat4.c.
◆ mat4_lookat()
Creates a matrix with a transformation to look at a center point from an eye with an up vector.
- Parameters
-
| [in] | eye | Vector representing the eye position that is looking at something. |
| [in] | center | Vector representing the position that is being looked at. |
| [in] | up | Vector representing the "upward" direction. Has to be a unitary vector. |
- Returns
- The newly created matrix.
Definition at line 239 of file mat4.c.
◆ mat4_mul()
| void mat4_mul |
( |
mat4 * | out, |
|
|
const mat4 * | m1, |
|
|
const mat4 * | m2 ) |
Multiplies two matrices (out = m1 * m2).
Note that out should not be neither m1 nor m2.
- Parameters
-
| [out] | out | Output matrix. |
| m1 | First matrix to mulitply. |
| m2 | Second matrix to multiply. |
Definition at line 35 of file mat4.c.
◆ mat4_ortho()
| mat4 mat4_ortho |
( |
double | left, |
|
|
double | right, |
|
|
double | bottom, |
|
|
double | top, |
|
|
double | nearVal, |
|
|
double | farVal ) |
Creates an orthographic projection matrix.
Definition at line 209 of file mat4.c.
◆ mat4_perspective()
| mat4 mat4_perspective |
( |
double | fov, |
|
|
double | aspect, |
|
|
double | near, |
|
|
double | far ) |
Creates a matrix with a perspective transformation.
- Parameters
-
| fov | Field of view. |
| aspect | Aspect ratio. |
| near | Near plane. |
| far | Far plane. |
- Returns
- The newly created matrix.
Definition at line 288 of file mat4.c.
◆ mat4_print()
| void mat4_print |
( |
const mat4 * | m | ) |
|
◆ mat4_rotate()
| void mat4_rotate |
( |
mat4 * | m, |
|
|
double | angle, |
|
|
double | x, |
|
|
double | y, |
|
|
double | z ) |
Multiplies the given matrix by a rotation. (Follows the right-hand rule.)
- Parameters
-
| [in,out] | m | Matrix to multiply with. |
| angle | Angle in radians. |
| x | X component of the axis of rotation. |
| y | Y component of the axis of rotation. |
| z | Z component of the axis of rotation. |
Definition at line 159 of file mat4.c.
◆ mat4_rotate2d()
| void mat4_rotate2d |
( |
mat4 * | m, |
|
|
double | angle ) |
Rotates an angle, in radians, around the z axis.
- Parameters
-
| [in,out] | m | Matrix to multiply with. |
| angle | Angle in radians. |
Definition at line 111 of file mat4.c.
◆ mat4_rotate2dv()
| void mat4_rotate2dv |
( |
mat4 * | m, |
|
|
double | c, |
|
|
double | s ) |
Rotates the +x axis to the given vector.
- Parameters
-
| [in,out] | m | Matrix to multiply with. |
| c | Angle cosine (or x coordinate of the vector). |
| s | Angle sine (or y coordinate of the vector). |
Definition at line 135 of file mat4.c.
◆ mat4_scale()
| void mat4_scale |
( |
mat4 * | m, |
|
|
double | x, |
|
|
double | y, |
|
|
double | z ) |
Scales a homogeneous transformation matrix.
- Parameters
-
| [in,out] | m | Matrix to apply scaling to. |
| x | Scaling on X axis. |
| y | Scaling on Y axis. |
| z | Scaling on Z axis. |
Definition at line 82 of file mat4.c.
◆ mat4_translate()
| void mat4_translate |
( |
mat4 * | m, |
|
|
double | x, |
|
|
double | y, |
|
|
double | z ) |
Translates a homogenous transformation matrix.
- Parameters
-
| [in,out] | m | Matrix to apply scaling to. |
| x | Translation on X axis. |
| y | Translation on Y axis. |
| z | Translation on Z axis. |
Definition at line 99 of file mat4.c.