Unravel Engine C++ Reference
Loading...
Searching...
No Matches
rotate_path.hpp
Go to the documentation of this file.
1#ifndef GENERATOR_ROTATEPATH_HPP
2#define GENERATOR_ROTATEPATH_HPP
3
4#include "axis.hpp"
5#include "transform_path.hpp"
6
7namespace generator
8{
9
11template<typename path_t>
13{
14private:
16 impl_t transform_path_;
17
18public:
19 rotate_path_t(path_t path, const gml::dquat& rotation)
20 : transform_path_{std::move(path),
21 [rotation](path_vertex_t& value)
22 {
23 value.position = gml::transform(rotation, value.position);
24 value.normal = gml::transform(rotation, value.normal);
25 }}
26 {
27 }
28
29 rotate_path_t(path_t path, double angle, const gml::dvec3& axis)
30 : rotate_path_t{std::move(path), gml::qrotate(angle, axis)}
31 {
32 }
33
34 rotate_path_t(path_t path, double angle, axis_t axis)
35 : rotate_path_t{std::move(path),
36 gml::qrotate(angle,
37 axis == axis_t::X
38 ? gml::dvec3{1.0, 0.0, 0.0}
39 : (axis == axis_t::Y ? gml::dvec3{0.0, 1.0, 0.0} : gml::dvec3{0.0, 0.0, 1.0}))}
40 {
41 }
42
43 using edges_t = typename impl_t::edges_t;
44
45 edges_t edges() const noexcept
46 {
47 return transform_path_.edges();
48 }
49
51
52 vertices_t vertices() const noexcept
53 {
54 return transform_path_.vertices();
55 }
56};
57
58template<typename path_t>
59rotate_path_t<path_t> rotate_path(path_t path, const gml::dquat& rotation)
60{
61 return rotate_path_t<path_t>{std::move(path), rotation};
62}
63
64template<typename path_t>
65rotate_path_t<path_t> rotate_path(path_t path, double angle, const gml::dvec3& axis)
66{
67 return rotate_path_t<path_t>{std::move(path), angle, axis};
68}
69
70template<typename path_t>
71rotate_path_t<path_t> rotate_path(path_t path, double angle, axis_t axis)
72{
73 return rotate_path_t<path_t>{std::move(path), angle, axis};
74}
75} // namespace generator
76
77#endif
Rotates vertices, tangents and normals.
rotate_path_t(path_t path, double angle, axis_t axis)
typename impl_t::vertices_t vertices_t
rotate_path_t(path_t path, const gml::dquat &rotation)
rotate_path_t(path_t path, double angle, const gml::dvec3 &axis)
vertices_t vertices() const noexcept
typename impl_t::edges_t edges_t
edges_t edges() const noexcept
Apply a mutator function to each vertex.
typename impl_t::edges_t edges_t
rotate_path_t< path_t > rotate_path(path_t path, const gml::dquat &rotation)
Definition math.hpp:13
glm::tvec3< T > transform(const glm::tquat< T > &q, const glm::tvec3< T > &v)
Definition math.hpp:114