diff --git a/src/m_rotation.scad b/src/m_rotation.scad new file mode 100644 index 00000000..c141cb40 --- /dev/null +++ b/src/m_rotation.scad @@ -0,0 +1,34 @@ +include <__private__/_m_multiply.scad>; + +function _m_xRotation(a) = + let(c = cos(a), s = sin(a)) + [ + [1, 0, 0, 0], + [0, c, -s, 0], + [0, s, c, 0], + [0, 0, 0, 1] + ]; + +function _m_yRotation(a) = + let(c = cos(a), s = sin(a)) + [ + [c, 0, s, 0], + [0, 1, 0, 0], + [-s, 0, c, 0], + [0, 0, 0, 1] + ]; + +function _m_zRotation(a) = + let(c = cos(a), s = sin(a)) + [ + [c, -s, 0, 0], + [s, c, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1] + ]; + +function m_rotation(a) = _m_multiply( + _m_zRotation(a[2]), _m_multiply( + _m_yRotation(a[1]), _m_xRotation(a[0]) + ) +);