-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector3d.h
More file actions
74 lines (51 loc) · 1.65 KB
/
Vector3d.h
File metadata and controls
74 lines (51 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Created by mtakagi on 2024/02/17.
//
#ifndef AOBENCH_VECTOR3D_H
#define AOBENCH_VECTOR3D_H
#include <array>
namespace aobench {
struct Vector3d {
public:
using Basis = std::array<Vector3d, 3>;
[[nodiscard]]
Vector3d() = default;
[[nodiscard]]
constexpr Vector3d(double x, double y, double z) noexcept : x_(x), y_(y), z_(z) {
};
[[nodiscard]]
double x() const noexcept;
[[nodiscard]]
double y() const noexcept;
[[nodiscard]]
double z() const noexcept;
void set(double x, double y, double z) noexcept;
[[nodiscard]]
double dot(const Vector3d&) const noexcept;
[[nodiscard]]
Vector3d cross(const Vector3d&) const noexcept;
[[nodiscard]]
double length() const noexcept;
[[nodiscard]]
Vector3d normalize() const noexcept;
[[nodiscard]]
Basis orthoBasis() const;
private:
double x_, y_, z_;
};
[[nodiscard]]
Vector3d operator-(const Vector3d& lhs, const Vector3d& rhs) noexcept;
[[nodiscard]]
Vector3d operator-(const Vector3d& lhs, double rhs) noexcept;
[[nodiscard]]
Vector3d operator+(const Vector3d& lhs, const Vector3d& rhs) noexcept;
[[nodiscard]]
Vector3d operator+(const Vector3d& lhs, double rhs) noexcept;
[[nodiscard]]
Vector3d operator*(const Vector3d& lhs, const Vector3d& rhs) noexcept;
[[nodiscard]]
Vector3d operator*(const Vector3d& lhs, double rhs) noexcept;
[[nodiscard]]
bool operator==(const Vector3d& lhs, const Vector3d& rhs) noexcept;
} // aobench
#endif //AOBENCH_VECTOR3D_H