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
7#include "../macros.hpp"
8#include <hikocpu/hikocpu.hpp>
9#include <cmath>
10#include <exception>
11#include <compare>
12
13hi_export_module(hikogui.geometry : rotate2);
14
15hi_export namespace hi { inline namespace v1 {
16
17class rotate2 {
18public:
19 using array_type = simd<float, 4>;
20 using value_type = array_type::value_type;
21
22 constexpr rotate2(rotate2 const&) noexcept = default;
23 constexpr rotate2(rotate2&&) noexcept = default;
24 constexpr rotate2& operator=(rotate2 const&) noexcept = default;
25 constexpr rotate2& operator=(rotate2&&) noexcept = default;
26 constexpr rotate2() noexcept : _v(0.0f, 0.0f, 1.0f, 0.0f) {}
27
28 [[nodiscard]] rotate2(float angle) noexcept : _v()
29 {
30 auto const half_angle = angle * 0.5f;
31 auto const C = std::cos(half_angle);
32 auto const S = std::sin(half_angle);
33
34 _v = f32x4{0.0f, 0.0f, S, C};
35 }
36
37 [[nodiscard]] constexpr explicit operator array_type() const noexcept
38 {
39 return _v;
40 }
41
42 //std::pair<float, vector3> angle_and_axis() const noexcept
43 //{
44 // auto const rcp_length = rcp_hypot<0b0111>(_v);
45 // auto const length = 1.0f / rcp_length;
46 //
47 // return {2.0f * std::atan2(length), vector3{_v.xyz0() * rcp_length}};
48 //}
49
50private:
54 array_type _v;
55};
56
57}} // namespace hi::v1
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition simd_intf.hpp:18
Definition rotate2.hpp:17
T cos(T... args)
T sin(T... args)