41template<
floating_po
int_number Real>
108 Real res =
x*v.
x +
y*v.
y +
z*v.
z;
118 [[nodiscard]]
constexpr std::size_t
size()
const {
return 3; }
136 res.
x = a.
y*b.
z - a.
z*b.
y;
137 res.
y = a.
z*b.
x - a.
x*b.
z;
138 res.
z = a.
x*b.
y - a.
y*b.
x;
164 Real
norm()
const {
return std::sqrt(this->
dot(*
this)); }
185 *
this= *
this/this->
norm();
192 os <<
"{" << obj.
x <<
',' << obj.
y <<
',' << obj.
z <<
'}';
286 lhs.
scale(
static_cast<Real
>(1.)/rhs);
311 template<
typename Index>
312 requires std::is_integral_v<Index>
319 default:std::cerr << idx <<
"is out of range for as vec3 index";
332 template<
typename Index>
333 requires std::is_integral_v<Index>
340 default:std::cerr << idx <<
"is out of range for as vec3 index";
Internal implementation of a 3D vector.
Definition vec3.hpp:43
constexpr std::size_t size() const
Always returns 3.
Definition vec3.hpp:118
vec3< Real > cross(vec3< Real > const &other) const
Calculate cross product with another vector.
Definition vec3.hpp:153
Real dot(vec3< Real > const &v) const
Calculate dot product with another vector.
Definition vec3.hpp:106
friend void operator/=(vec3< Real > &lhs, Real const &rhs)
Overloaded operator defined in terms of vec3::scale.
Definition vec3.hpp:285
vec3< Real > const & normalize()
Normalize the vector in place. And return a reference to the new normalized vector.
Definition vec3.hpp:184
friend vec3< Real > operator-(vec3< Real > lhs, vec3< Real > const &rhs)
Overloaded operator defined in terms of vec3::subtract.
Definition vec3.hpp:235
friend vec3< Real > operator*(vec3< Real > lhs, Real const &rhs)
Overloaded operator defined in terms of vec3::scale.
Definition vec3.hpp:272
Real z
The z component of the vector.
Definition vec3.hpp:48
void subtract(vec3< Real > const &v)
In place subtraction method.
Definition vec3.hpp:77
const Real & operator[](Index idx) const
element access operator for constant environments.
Definition vec3.hpp:334
Real norm() const
Returns the norm of the vector.
Definition vec3.hpp:164
friend void operator+=(vec3< Real > &lhs, vec3< Real > const &rhs)
Overloaded operator defined in terms of vec3::add.
Definition vec3.hpp:223
friend vec3< Real > operator/(vec3< Real > lhs, Real const &rhs)
Overloaded operator defined in terms of vec3::scale.
Definition vec3.hpp:297
Real norm_square() const
Returns the square of the norm of the vector.
Definition vec3.hpp:175
Real y
The y component of the vector.
Definition vec3.hpp:47
bool operator==(vec3< Real > const &other) const =default
default equality operator.
friend vec3< Real > operator*(Real const &lhs, vec3< Real > rhs)
Overloaded operator defined in terms of vec3::scale.
Definition vec3.hpp:259
void scale(Real s)
Scale the vector by a real number s.
Definition vec3.hpp:88
void add(vec3< Real > const &v)
In place addition method.
Definition vec3.hpp:60
friend vec3< Real > operator-(vec3< Real > v)
Unary minus operator.
Definition vec3.hpp:351
friend std::ostream & operator<<(std::ostream &os, const vec3< Real > &obj)
Streaming operator for easy printing of the vector.
Definition vec3.hpp:190
friend vec3< Real > operator+(vec3< Real > lhs, vec3< Real > const &rhs)
Overloaded operator defined in terms of vec2::add.
Definition vec3.hpp:211
Real & operator[](Index idx)
element access operator.
Definition vec3.hpp:313
Real x
The x component of the vector.
Definition vec3.hpp:46
static vec3< Real > cross(vec3< Real > const &a, vec3< Real > const &b)
Calculate cross product between two vectors.
Definition vec3.hpp:133
friend void operator-=(vec3< Real > &lhs, vec3< Real > const &rhs)
Overloaded operator defined in terms of vec3::subtract.
Definition vec3.hpp:247
This file contains the concepts that are costomly defined for the flippy class templates.
Definition custom_concepts.hpp:8