12 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_CONSTEXPR_VECTOR_H
13 #define INCLUDE_MOLASSEMBLER_TEMPLE_CONSTEXPR_VECTOR_H
21 namespace Molassembler {
28 std::array<double, 3> data;
33 constexpr
Vector() : data({{0, 0, 0}}) {}
34 constexpr Vector(std::array<double, 3> positions) : data(positions) {}
35 constexpr Vector(
double x,
double y,
double z) : data({{x, y, z}}) {}
44 PURITY_WEAK constexpr
double dot(
const Vector& other)
const noexcept {
46 this->data[0] * other.data[0]
47 + this->data[1] * other.data[1]
48 + this->data[2] * other.data[2]
56 PURITY_WEAK constexpr Vector cross(
const Vector& other)
const noexcept {
59 this -> data[1] * other.data[2] -
this -> data[2] * other.data[1],
60 this -> data[2] * other.data[0] -
this -> data[0] * other.data[2],
61 this -> data[0] * other.data[1] -
this -> data[1] * other.data[0]
72 this -> data[0] *
this -> data[0]
73 +
this -> data[1] *
this -> data[1]
74 +
this -> data[2] *
this -> data[2]
78 PURITY_WEAK constexpr Vector operator + (
const Vector& other)
const noexcept {
81 this->data[0] + other.data[0],
82 this->data[1] + other.data[1],
83 this->data[2] + other.data[2]
88 PURITY_WEAK constexpr Vector operator - (
const Vector& other)
const noexcept {
91 this->data[0] - other.data[0],
92 this->data[1] - other.data[1],
93 this->data[2] - other.data[2]
98 PURITY_WEAK constexpr Vector operator * (
const double constant)
const noexcept {
101 constant * this->data[0],
102 constant * this->data[1],
103 constant * this->data[2]
112 PURITY_WEAK constexpr Vector operator / (
const double constant)
const {
114 throw "Constexpr::Vector divided by zero!";
119 this->data[0] / constant,
120 this->data[1] / constant,
121 this->data[2] / constant
127 PURITY_WEAK constexpr Vector operator - ()
const noexcept {
constexpr math implementations
#define PURITY_WEAK
Definition: Preprocessor.h:36
Constexpr three-dimensional vector math class.
Definition: Vector.h:25
PURITY_WEAK constexpr double angle(const Vector &a, const Vector &b)
Constexpr binary angle in radians calculation.
Definition: Vector.h:143