Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
Vec3.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** R-Type
4** File description:
5** Vec3.hpp, Vector of 3 class declaration
6*/
7
8/*
9** MIT License
10**
11** Copyright (c) 2025 Robin Toillon
12**
13** Permission is hereby granted, free of charge, to any person obtaining
14** a copy of this software and associated documentation files (the
15** "Software"), to deal in the Software without restriction, including
16** without limitation the rights to use, copy, modify, merge, publish,
17** distribute, sublicense, and/or sell copies of the Software, and to
18** permit persons to whom the Software is furnished to do so, subject to
19** the following conditions:
20**
21** The above copyright notice and this permission notice shall be
22** included in all copies or substantial portions of the Software.
23**
24** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31*/
32
39#ifndef RTYPE_VEC3_HPP_
40 #define RTYPE_VEC3_HPP_
41
42 #include "RType/Assert.hpp"
44
45namespace rtp
46{
52 template <Numeric T>
53 struct Vec3 : details::VecBase<T, 3> {
54 T x{};
55 T y{};
56 T z{};
59 constexpr Vec3(void) = default;
60
62 constexpr Vec3(T x, T y, T z) noexcept;
63
65 constexpr ~Vec3() = default;
66
68 [[nodiscard]]
69 constexpr bool operator==(const Vec3 &) const noexcept = default;
70
77 [[nodiscard]]
78 constexpr auto &operator[](this auto &self, size_t index) noexcept;
79
83 [[nodiscard]]
84 constexpr auto cross(const Vec3 &other) const noexcept
85 -> Vec3;
86 };
87
92}
93
94 #include "Vec3.tpp"
95
96#endif /* !RTYPE_VEC3_HPP_ */
Assertion and verification macros for runtime checks.
Declaration of the CRTP base vector class.
A 3-dimensional vector.
Definition Vec3.hpp:53
T x
X coordinate.
Definition Vec3.hpp:54
constexpr auto & operator[](this auto &self, size_t index) noexcept
Accesses the coordinate at the specified index.
constexpr Vec3(void)=default
Default constructor.
constexpr auto cross(const Vec3 &other) const noexcept -> Vec3
The cross product of two 3D vectors.
constexpr ~Vec3()=default
Default destructor.
constexpr bool operator==(const Vec3 &) const noexcept=default
Checks if two vectors are exactly equal.
T y
Y coordinate.
Definition Vec3.hpp:55
T z
Z coordinate.
Definition Vec3.hpp:56
constexpr Vec3(T x, T y, T z) noexcept
Parameterized constructor.
CRTP base class for vectors.
Definition VecBase.hpp:60