CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
RotatePath.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Axis.hpp"
11#include "TransformPath.hpp"
12
14
16 template<typename Path> class RotatePath {
17 private:
20
21 public:
22 RotatePath(Path path, const Quaternion& rotation)
23 : mTransformPath{std::move(path), [rotation](PathVertex& value) {
24 value.position = Math::transform(rotation, value.position);
25 value.normal = Math::transform(rotation, value.normal);
26 }} {}
27
28 RotatePath(Path path, const double angle, const Vector3& axis) : RotatePath{std::move(path), qrotate(angle, axis)} {}
29
30 RotatePath(Path path, const double angle, const Axis axis)
31 : RotatePath{std::move(path),
32 qrotate(angle, axis == Axis::X ? Vector3{1.0, 0.0, 0.0} : (axis == Axis::Y ? Vector3{0.0, 1.0, 0.0} : Vector3{0.0, 0.0, 1.0}))} {}
33
34 using Edges = typename Impl::Edges;
35 [[nodiscard]] Edges edges() const noexcept { return mTransformPath.edges(); }
36
37 using Vertices = typename Impl::Vertices;
38 [[nodiscard]] Vertices vertices() const noexcept { return mTransformPath.vertices(); }
39 };
40
41 template<typename Path> RotatePath<Path> rotatePath(Path path, const Quaternion& rotation) { return RotatePath<Path>{std::move(path), rotation}; }
42
43 template<typename Path> RotatePath<Path> rotatePath(Path path, double angle, const Vector3& axis) { return RotatePath<Path>{std::move(path), angle, axis}; }
44
45 template<typename Path> RotatePath<Path> rotatePath(Path path, double angle, Axis axis) { return RotatePath<Path>{std::move(path), angle, axis}; }
46
47} // namespace CeresEngine::MeshGenerator
Definition PathVertex.hpp:14
Rotates vertices, tangents and normals.
Definition RotatePath.hpp:16
RotatePath(Path path, const double angle, const Vector3 &axis)
Definition RotatePath.hpp:28
Vertices vertices() const noexcept
Definition RotatePath.hpp:38
Impl mTransformPath
Definition RotatePath.hpp:19
typename Impl::Edges Edges
Definition RotatePath.hpp:34
Edges edges() const noexcept
Definition RotatePath.hpp:35
typename Impl::Vertices Vertices
Definition RotatePath.hpp:37
RotatePath(Path path, const double angle, const Axis axis)
Definition RotatePath.hpp:30
RotatePath(Path path, const Quaternion &rotation)
Definition RotatePath.hpp:22
Apply a mutator function to each vertex.
Definition TransformPath.hpp:18
typename Impl::Edges Edges
Definition TransformPath.hpp:52
Definition AnyGenerator.hpp:12
Axis
Definition Axis.hpp:12
RotatePath< Path > rotatePath(Path path, const Quaternion &rotation)
Definition RotatePath.hpp:41
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
Axis axis(const StringView &str) noexcept
Returns the Axis constant that is represented by str.
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
TVector3< T > transform(const TQuaternion< T > &q, const TVector3< T > &v)
Definition Math.hpp:694
Definition Span.hpp:668