Matrix3x3.h 833 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Jelle Raaijmakers <jelle@gmta.nl>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Matrix.h>
  8. #include <LibGfx/Vector3.h>
  9. namespace Gfx {
  10. template<typename T>
  11. using Matrix3x3 = Matrix<3, T>;
  12. template<typename T>
  13. constexpr static Vector3<T> operator*(Matrix3x3<T> const& m, Vector3<T> const& v)
  14. {
  15. auto const& elements = m.elements();
  16. return Vector3<T>(
  17. v.x() * elements[0][0] + v.y() * elements[0][1] + v.z() * elements[0][2],
  18. v.x() * elements[1][0] + v.y() * elements[1][1] + v.z() * elements[1][2],
  19. v.x() * elements[2][0] + v.y() * elements[2][1] + v.z() * elements[2][2]);
  20. }
  21. typedef Matrix3x3<float> FloatMatrix3x3;
  22. typedef Matrix3x3<double> DoubleMatrix3x3;
  23. }
  24. using Gfx::DoubleMatrix3x3;
  25. using Gfx::FloatMatrix3x3;
  26. using Gfx::Matrix3x3;