|
flippy
a c++20 package for dynamically triangulated membrane simulations.
|
Internal implementation of a 3D vector. More...
#include <vec3.hpp>

Public Member Functions | |
| void | add (vec3< Real > const &v) |
| In place addition method. | |
| void | subtract (vec3< Real > const &v) |
| In place subtraction method. | |
| void | scale (Real s) |
| Scale the vector by a real number s. | |
| Real | dot (vec3< Real > const &v) const |
| Calculate dot product with another vector. | |
| constexpr std::size_t | size () const |
| Always returns 3. | |
| vec3< Real > | cross (vec3< Real > const &other) const |
| Calculate cross product with another vector. | |
| Real | norm () const |
| Returns the norm of the vector. | |
| Real | norm_square () const |
| Returns the square of the norm of the vector. | |
| vec3< Real > const & | normalize () |
| Normalize the vector in place. And return a reference to the new normalized vector. | |
| bool | operator== (vec3< Real > const &other) const =default |
| default equality operator. | |
| template<typename Index > requires std::is_integral_v<Index> | |
| Real & | operator[] (Index idx) |
| element access operator. | |
| template<typename Index > requires std::is_integral_v<Index> | |
| const Real & | operator[] (Index idx) const |
| element access operator for constant environments. | |
Static Public Member Functions | |
| static vec3< Real > | cross (vec3< Real > const &a, vec3< Real > const &b) |
| Calculate cross product between two vectors. | |
Public Attributes | |
| Real | x |
| The x component of the vector. | |
| Real | y |
| The y component of the vector. | |
| Real | z |
| The z component of the vector. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const vec3< Real > &obj) |
| Streaming operator for easy printing of the vector. | |
| vec3< Real > | operator+ (vec3< Real > lhs, vec3< Real > const &rhs) |
| Overloaded operator defined in terms of vec2::add. | |
| void | operator+= (vec3< Real > &lhs, vec3< Real > const &rhs) |
| Overloaded operator defined in terms of vec3::add. | |
| vec3< Real > | operator- (vec3< Real > lhs, vec3< Real > const &rhs) |
| Overloaded operator defined in terms of vec3::subtract. | |
| void | operator-= (vec3< Real > &lhs, vec3< Real > const &rhs) |
| Overloaded operator defined in terms of vec3::subtract. | |
| vec3< Real > | operator* (Real const &lhs, vec3< Real > rhs) |
| Overloaded operator defined in terms of vec3::scale. | |
| vec3< Real > | operator* (vec3< Real > lhs, Real const &rhs) |
| Overloaded operator defined in terms of vec3::scale. | |
| void | operator/= (vec3< Real > &lhs, Real const &rhs) |
| Overloaded operator defined in terms of vec3::scale. | |
| vec3< Real > | operator/ (vec3< Real > lhs, Real const &rhs) |
| Overloaded operator defined in terms of vec3::scale. | |
| vec3< Real > | operator- (vec3< Real > v) |
| Unary minus operator. | |
Internal implementation of a 3D vector.
!!! vec3 does not throw !!! This means that if you ask vec3 to divide a vector by 0 or more realistically if you normalize a zero length vector vec3 will not check for the division by zero and will return a nan result! Since vec3 is used everywhere in flippy, including in very expensive calculations, I decided to omit the security check for the sake of speed.
To keep the external dependencies low, flippy implements it's own 3D vector class with basic functionality like dot product and cross product
Example:
| Real | type that will be used for all floating point numbers inside this class/struct. Any data type that satisfies the floating_point_number concept is allowed, for example, float. |
In place addition method.
Example:
| v | add this vector elementwise to the vector that is calling the add method. |
|
inline |
In place subtraction method.
Example:
| v | subtract this vector elementwise from the vector that is calling the subtract method. |
|
inline |
Scale the vector by a real number s.
This function scales the vector in-place by the provided number s.
| s | multiplicative prefactor. |
|
inline |
Calculate dot product with another vector.
Example:
| v | the other vec3 vector |
v. 
|
inlinenodiscardconstexpr |
|
inlinestatic |
Calculate cross product between two vectors.
A static method to calculate cross product between two vectors. Example:
| a | first vector of the cross product |
| b | second vector of the cross product |
v. 
|
inline |
Calculate cross product with another vector.
Example:
| other | the other vec3 vector. |
other. 

|
inline |
Returns the norm of the vector.
Example:


|
inline |
Returns the square of the norm of the vector.
Example:


Normalize the vector in place. And return a reference to the new normalized vector.

|
default |
default equality operator.
| other | vec3 on the right hand side of the comparison operator. |
true if all elements of the compared vectors are equal and to false otherwise.
|
inline |
element access operator.
| Index | automatically deduced type of the index. |
| idx | can only be 0 1 or 2. Any other number will cause the program to exit with an error. |
|
inline |
element access operator for constant environments.
| Index | automatically deduced type of the index. |
| idx | can only be 0 1 or 2. Any other number will cause the program to exit with an error. |
|
friend |
Overloaded operator defined in terms of vec2::add.
| lhs | left hand side of the + operator |
| rhs | right hand side oif the + operator |
lhs.add(rhs).
|
friend |
Overloaded operator defined in terms of vec3::add.
Equivalent to lhs.add(rhs).
| lhs | left hand side of the += operator |
| rhs | right hand side oif the += operator |
|
friend |
Overloaded operator defined in terms of vec3::subtract.
| lhs | left hand side of the - operator |
| rhs | right hand side oif the - operator |
lhs.subtract(rhs).
|
friend |
Overloaded operator defined in terms of vec3::subtract.
Equivalent to lhs.subtract(rhs).
| lhs | left hand side of the -= operator |
| rhs | right hand side oif the -= operator |
|
friend |
Overloaded operator defined in terms of vec3::scale.
Left multiplication by a scalar s*v.
| lhs | left hand side of the * operator |
| rhs | right hand side oif the * operator |
rhs.scale(lhs).
|
friend |
Overloaded operator defined in terms of vec3::scale.
Right multiplication by a scalar v*s.
| lhs | left hand side of the * operator |
| rhs | right hand side oif the * operator |
lhs.scale(rhs).
|
friend |
Overloaded operator defined in terms of vec3::scale.
In place division by a scalar v/s, equivalent to lhs.scale(1/rhs).
| lhs | left hand side of the /= operator |
| rhs | right hand side oif the /= operator |
|
friend |
Overloaded operator defined in terms of vec3::scale.
Division by a scalar v/s.
| lhs | left hand side of the / operator |
| rhs | right hand side oif the / operator |
lhs.scale(1/rhs). Unary minus operator.
| v | original vector. |