40#ifndef Foam_Vector2D_H
41#define Foam_Vector2D_H
99 inline Vector2D(
const Cmpt& vx,
const Cmpt& vy);
125 inline scalar
mag()
const;
128 inline scalar
magSqr()
const;
154 const scalar tol = 1
e-10
184 template<
class Cmpt2>
185 std::enable_if_t<std::is_convertible_v<Cmpt2, Cmpt>,
void>
193 template<
class Cmpt2>
194 std::enable_if_t<std::is_convertible_v<Cmpt2, Cmpt>,
void>
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Cmpt & y() noexcept
Access to the vector y component.
std::enable_if_t< std::is_convertible_v< Cmpt2, Cmpt >, void > operator+=(const Vector2D< Cmpt2 > &b)
Add compatible 2D vector to this.
const Cmpt & x() const noexcept
Access to the vector x component.
scalar perp(const Vector2D< Cmpt > &b) const
Perp dot product (dot product with perpendicular vector).
components
Component labeling enumeration.
scalar dist(const Vector2D< Cmpt > &v2) const
The L2-norm distance from another vector. The mag() of the difference.
scalar distSqr(const Vector2D< Cmpt > &v2) const
The L2-norm distance squared from another vector. The magSqr() of the difference.
Vector2D(const Cmpt &vx, const Cmpt &vy)
Construct from two components.
Vector2D(Istream &is)
Construct from Istream.
Cmpt & x() noexcept
Access to the vector x component.
static bool less_yx(const Vector2D< Cmpt > &a, const Vector2D< Cmpt > &b)
Lexicographically compare a and b with order (y:x).
static constexpr direction rank
Vector2D & operator=(const Vector2D &)=default
Copy assignment.
bool isClose(const Vector2D< Cmpt > &b, const scalar tol=1e-10) const
Return true if vector is within tol.
scalar mag() const
The length (L2-norm) of the vector.
Vector2D()=default
Default construct.
Vector2D(const VectorSpace< Vector2D< Cmpt >, Cmpt, 2 > &vs)
Copy construct from VectorSpace of the same rank.
Vector2D(Foam::zero)
Construct initialized to zero.
Vector2D(const Vector2D &)=default
Copy construct.
const Cmpt & y() const noexcept
Access to the vector y component.
scalar magSqr() const
The length (L2-norm) squared of the vector.
Vector2D< Cmpt > & removeCollinear(const Vector2D< Cmpt > &unitVec)
Inplace removal of components that are collinear to the given unit vector.
static bool less_xy(const Vector2D< Cmpt > &a, const Vector2D< Cmpt > &b)
Lexicographically compare a and b with order (x:y).
Vector2D< label > labelType
std::enable_if_t< std::is_convertible_v< Cmpt2, Cmpt >, void > operator-=(const Vector2D< Cmpt2 > &b)
Subtract compatible 2D vector from this.
Vector2D< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Normalise the vector by its magnitude.
Cmpt v_[Ncmpts]
The components of this vector space.
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
A template class to specify if a data type is composed solely of Foam::label elements.
A template class to specify if a data type is composed solely of Foam::scalar elements.
A template class to specify that a data type can be considered as being contiguous in memory.