From d8235f126628a1f0487b7b66a0812b93b916685d Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Tue, 6 May 2025 22:24:12 -0700 Subject: [PATCH] Add create_rotation helper function Rotation matrix construction not implemented in MTL yet --- include/fractal.hpp | 4 ++++ src/fractal.cpp | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/fractal.hpp b/include/fractal.hpp index 601b5e6..649809a 100644 --- a/include/fractal.hpp +++ b/include/fractal.hpp @@ -6,6 +6,10 @@ #include #include #include +#include + +// 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 { diff --git a/src/fractal.cpp b/src/fractal.cpp index f314216..6f09809 100644 --- a/src/fractal.cpp +++ b/src/fractal.cpp @@ -2,9 +2,23 @@ #include #include +#include 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 {