/* * 3D Engine * matrice.h: * Based on pikuma.com 3D software renderer in C * Copyright (c) 2021 986-Studio. All rights reserved. * * Created by Manoƫl Trapier on 06/03/2021. */ #ifndef THREEDENGINE_SOURCE_INCLUDE_MATRICE_H #define THREEDENGINE_SOURCE_INCLUDE_MATRICE_H #include /*********************************************************************************************************************** * Data types **********************************************************************************************************************/ typedef struct matrix4_t { double v[4*4]; } matrix4_t; /*********************************************************************************************************************** * Global variables **********************************************************************************************************************/ static const struct matrix4_t mat4Identity = { .v = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 } }; /*********************************************************************************************************************** * Prototypes **********************************************************************************************************************/ #define FastGet4(_m, _x, _y) ((_m).v[4 * (_x) + (_y)]) #define FastSet4(_m, _x, _y, _v) (((_m).v[4 * (_x) + (_y)]) = (_v)) vec4_t mat4ProdVec4(matrix4_t mat, vec4_t v); matrix4_t mat4ProdMat4(matrix4_t a, matrix4_t b); vec4_t mat4ProdVec4Project(matrix4_t mat, vec4_t v); matrix4_t mat4Scale(double scaleX, double scaleY, double scaleZ); matrix4_t mat4Translate(double tX, double tY, double tZ); matrix4_t mat4RotationX(double angle); matrix4_t mat4RotationY(double angle); matrix4_t mat4RotationZ(double angle); matrix4_t mat4Perspective(double aspectRation, double FOV, double zNear, double zFar); matrix4_t mat4LookAt(vec3_t eye, vec3_t target, vec3_t up); #endif /* THREEDENGINE_SOURCE_INCLUDE_MATRICE_H */