HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
rotate2.hpp
1// Copyright Take Vos 2021-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7namespace hi { inline namespace v1 {
8
9class rotate2 {
10public:
11 using array_type = simd<float, 4>;
12 using value_type = array_type::value_type;
13
14 constexpr rotate2(rotate2 const&) noexcept = default;
15 constexpr rotate2(rotate2&&) noexcept = default;
16 constexpr rotate2& operator=(rotate2 const&) noexcept = default;
17 constexpr rotate2& operator=(rotate2&&) noexcept = default;
18 constexpr rotate2() noexcept : _v(0.0f, 0.0f, 1.0f, 0.0f) {}
19
20 [[nodiscard]] rotate2(float angle) noexcept : _v()
21 {
22 hilet half_angle = angle * 0.5f;
23 hilet C = std::cos(half_angle);
24 hilet S = std::sin(half_angle);
25
26 _v = f32x4{0.0f, 0.0f, 1.0f, 0.0f} * S;
27 _v.w() = C;
28 }
29
30 [[nodiscard]] constexpr explicit operator array_type() const noexcept
31 {
32 return _v;
33 }
34
35 //std::pair<float, vector3> angle_and_axis() const noexcept
36 //{
37 // hilet rcp_length = rcp_hypot<0b0111>(_v);
38 // hilet length = 1.0f / rcp_length;
39 //
40 // return {2.0f * std::atan2(length), vector3{_v.xyz0() * rcp_length}};
41 //}
42
43private:
47 array_type _v;
48};
49
50}} // namespace hi::v1
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Definition rotate2.hpp:9
T cos(T... args)
T sin(T... args)