matrix.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * 3D Engine
  3. * matrice.h:
  4. * Based on pikuma.com 3D software renderer in C
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 06/03/2021.
  8. */
  9. #ifndef THREEDENGINE_SOURCE_INCLUDE_MATRICE_H
  10. #define THREEDENGINE_SOURCE_INCLUDE_MATRICE_H
  11. #include <vector.h>
  12. /***********************************************************************************************************************
  13. * Data types
  14. **********************************************************************************************************************/
  15. typedef struct matrix4_t
  16. {
  17. double v[4*4];
  18. } matrix4_t;
  19. /***********************************************************************************************************************
  20. * Global variables
  21. **********************************************************************************************************************/
  22. static const struct matrix4_t mat4Identity =
  23. {
  24. 1, 0, 0, 0,
  25. 0, 1, 0, 0,
  26. 0, 0, 1, 0,
  27. 0, 0, 0, 1
  28. };
  29. /***********************************************************************************************************************
  30. * Prototypes
  31. **********************************************************************************************************************/
  32. #define FastGet4(_m, _x, _y) ((_m).v[4 * (_x) + (_y)])
  33. matrix4_t mat4Scale(double scaleX, double scaleY, double scaleZ);
  34. matrix4_t mat4Translate(double tX, double tY, double tZ);
  35. matrix4_t mat4RotationX(double angle);
  36. matrix4_t mat4RotationY(double angle);
  37. matrix4_t mat4RotationZ(double angle);
  38. vec4_t mat4ProdVec4(matrix4_t mat, vec4_t v);
  39. #endif /* THREEDENGINE_SOURCE_INCLUDE_MATRICE_H */