9#ifndef DRYPHYS_INCLUDE_DRYPHYS_VECTOR3D_HPP
10#define DRYPHYS_INCLUDE_DRYPHYS_VECTOR3D_HPP
16#include <common-utils/utilities.hpp>
27 class Vector3D :
private DryChem::EqualityComparable<Vector3D>
34#ifdef phys_four_word_alignment
36 [[maybe_unused]] real pad;
41 DRYPHYS_CONSTEXPR
Vector3D() noexcept = default;
42 DRYPHYS_CONSTEXPR
Vector3D(const real
x, const real
y, const real
z) noexcept :
x {
x},
y {
y},
z {
z} {}
47 return lhs_.
x == rhs_.
x && lhs_.
y == rhs_.
y && lhs_.
z == rhs_.
z;
52 return lhs_.
x < rhs_.
x && lhs_.
y < rhs_.
y && lhs_.
z < rhs_.
z;
57 return lhs_.
x > rhs_.
x && lhs_.
y > rhs_.
y && lhs_.
z > rhs_.
z;
62 return lhs_.
x <= rhs_.
x && lhs_.
y <= rhs_.
y && lhs_.
z <= rhs_.
z;
67 return lhs_.
x >= rhs_.
x && lhs_.
y >= rhs_.
y && lhs_.
z >= rhs_.
z;
71 DRYPHYS_CONSTEXPR real&
operator[](
unsigned i) {
return ((&
x)[i]); }
72 DRYPHYS_CONSTEXPR
const real&
operator[](
unsigned i)
const {
return ((&
x)[i]); }
104 rhs =
static_cast<real
>(1) / rhs;
113 rhs =
static_cast<real
>(1) / rhs;
131 DRYPHYS_CONSTEXPR real
dot(
const Vector3D& rhs)
const {
return x * rhs.
x +
y * rhs.
y +
z * rhs.
z; }
166 if (real length =
magnitude(); length > 0)
167 (*
this) *=
static_cast<real
>(1) / length;
174 template<std::
size_t Index>
177 static_assert(Index < 3,
"Index must be within 0 and 2, inclusive.");
179 if constexpr (Index == 0)
181 else if constexpr (Index == 1)
190 template<std::
size_t Index>
193 static_assert(Index < 3,
"Index must be within 0 and 2, inclusive.");
195 if constexpr (Index == 0)
197 else if constexpr (Index == 1)
206 template<std::
size_t Index>
209 static_assert(Index < 3,
"Index must be within 0 and 2, inclusive.");
211 if constexpr (Index == 0)
212 return std::move(vec[0]);
213 else if constexpr (Index == 1)
214 return std::move(vec[1]);
216 return std::move(vec[2]);
227template<std::
size_t Index>
228struct std::tuple_element<Index,
DryPhys::Vector3D>
Definition vector3d.hpp:28
DRYPHYS_CONSTEXPR Vector3D operator/(real rhs) const
Definition vector3d.hpp:111
DRYPHYS_CONSTEXPR Vector3D operator*(real rhs) const
Definition vector3d.hpp:100
real z
Definition vector3d.hpp:32
DRYPHYS_CONSTEXPR void operator/=(real rhs)
Definition vector3d.hpp:102
DRYPHYS_CONSTEXPR Vector3D operator+(const Vector3D &rhs) const
Definition vector3d.hpp:82
DRYPHYS_CONSTEXPR const real & operator[](unsigned i) const
Definition vector3d.hpp:72
DRYPHYS_CONSTEXPR real & operator[](unsigned i)
Element access.
Definition vector3d.hpp:71
real y
Definition vector3d.hpp:31
real x
Definition vector3d.hpp:30
DRYPHYS_CONSTEXPR friend bool operator<=(const Vector3D &lhs_, const Vector3D &rhs_)
Definition vector3d.hpp:60
DRYPHYS_CONSTEXPR Vector3D operator-(const Vector3D &rhs) const
Definition vector3d.hpp:91
DRYPHYS_CONSTEXPR void operator+=(const Vector3D &rhs)
Arithmetic Operators.
Definition vector3d.hpp:75
real magnitude() const
Definition vector3d.hpp:159
DRYPHYS_CONSTEXPR friend bool operator>=(const Vector3D &lhs_, const Vector3D &rhs_)
Definition vector3d.hpp:65
DRYPHYS_CONSTEXPR real dot(const Vector3D &rhs) const
Definition vector3d.hpp:131
DRYPHYS_CONSTEXPR real magnitudeSquared() const
Definition vector3d.hpp:154
DRYPHYS_CONSTEXPR Vector3D operator*(const Vector3D &rhs) const
We use operator* for the component product.
Definition vector3d.hpp:126
DRYPHYS_CONSTEXPR void operator*=(real rhs)
Definition vector3d.hpp:93
DRYPHYS_CONSTEXPR friend bool operator>(const Vector3D &lhs_, const Vector3D &rhs_)
Definition vector3d.hpp:55
void normalize()
Definition vector3d.hpp:164
DRYPHYS_CONSTEXPR friend bool operator<(const Vector3D &lhs_, const Vector3D &rhs_)
Definition vector3d.hpp:50
DRYPHYS_CONSTEXPR friend bool operator==(const Vector3D &lhs_, const Vector3D &rhs_)
Comparison operators - only the equality operator is symmetric.
Definition vector3d.hpp:45
DRYPHYS_CONSTEXPR void operator*=(const Vector3D &rhs)
We use operator*= for the component product.
Definition vector3d.hpp:118
DRYPHYS_CONSTEXPR void invert()
Definition vector3d.hpp:144
DRYPHYS_CONSTEXPR void operator-=(const Vector3D &rhs)
Definition vector3d.hpp:84
DRYPHYS_CONSTEXPR Vector3D cross(const Vector3D &rhs) const
Definition vector3d.hpp:136
DRYPHYS_CONSTEXPR Vector3D() noexcept=default
Constructors.
Definition vector3d.hpp:19
decltype(auto) get(Vector3D &vec)
Definition vector3d.hpp:175
DryPhys::real type
Definition vector3d.hpp:230
static constexpr int value
Definition vector3d.hpp:224