16 static_assert(D == 2 || D == 3,
"Only 2D or 3D rotation-matrices are supported");
23 [[nodiscard]]
rotate(
float angle,
vector<3> axis)
noexcept requires(D == 3) : _v()
25 hi_axiom(axis.holds_invariant());
26 hi_axiom(std::abs(hypot(axis) - 1.0f) < 0.0001f);
28 hilet half_angle = angle * 0.5f;
32 _v =
static_cast<f32x4>(axis) * S;
36 [[nodiscard]]
rotate(
float angle)
noexcept requires(D == 2) : _v()
38 hilet half_angle = angle * 0.5f;
42 _v =
f32x4{0.0f, 0.0f, 1.0f, 0.0f} * S;
49 [[nodiscard]]
constexpr operator matrix<D>() const noexcept
62 hilet x_mul = _v.xxxx() * _v;
63 hilet y_mul = _v.yyyy() * _v;
64 hilet z_mul = _v.zzzz() * _v;
66 auto twos =
f32x4(-2.0f, 2.0f, 2.0f, 0.0f);
67 auto one =
f32x4(1.0f, 0.0f, 0.0f, 0.0f);
68 hilet col0 = one + addsub<0b0011>(z_mul.zwxy(), y_mul.yxwz()) * twos;
71 hilet col1 = one + addsub<0b0110>(x_mul.yxwz(), z_mul.wzyx()) * twos;
74 hilet col2 = one + addsub<0b0101>(y_mul.wzyx(), x_mul.zwxy()) * twos;
81 hilet rcp_length = rcp_hypot<0b0111>(_v);
82 hilet length = 1.0f / rcp_length;