Add create_rotation helper function

Rotation matrix construction not implemented in MTL yet
This commit is contained in:
Madeline Busig 2025-05-06 22:24:12 -07:00
parent 65c395c551
commit d8235f1266
2 changed files with 19 additions and 1 deletions

View File

@ -6,6 +6,10 @@
#include <mtl/fixed.hpp> #include <mtl/fixed.hpp>
#include <mtl/vec.hpp> #include <mtl/vec.hpp>
#include <mtl/mat.hpp> #include <mtl/mat.hpp>
#include <mtl/exception.hpp>
// TODO: Implement in MTL and create version that doesn't need cos of the angle
mtl::mat<2, 2> create_rotation(mtl::fixed angle_cos);
namespace fractal { namespace fractal {

View File

@ -2,9 +2,23 @@
#include <mtl/exception.hpp> #include <mtl/exception.hpp>
#include <mtl/log.hpp> #include <mtl/log.hpp>
#include <cmath>
using mtl::endl; using mtl::endl;
namespace log = mtl::log; namespace mlog = mtl::log;
using mtl::fixed;
using mtl::vec2;
using mtl::mat;
mtl::mat<2, 2> create_rotation(mtl::fixed angle_cos) {
fixed angle_sin = fixed(1) - angle_cos * angle_cos;
return mat<2, 2>({
{ angle_cos, -angle_sin },
{ angle_sin, angle_cos }
});
}
namespace fractal { namespace fractal {