Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
fishnet::geometry::Vec2D< T > Class Template Reference

Implementation of a two-dimensional vector. More...

#include <Vec2D.hpp>

Inheritance diagram for fishnet::geometry::Vec2D< T >:

Public Types

using numeric_type = T
 

Public Member Functions

constexpr Vec2D (T x, T y)
 
template<fishnet::math::Number U, fishnet::math::Number R, typename = std::enable_if_t<(!std::is_same_v<U,T> || ! std::is_same_v<R,T>)&& std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
constexpr Vec2D (U x, R y)
 Constructor for heterogenous types Converts to the default numeric type.
 
constexpr Vec2D ()
 Default construction to (0,0)
 
template<fishnet::math::Number U>
constexpr operator Vec2D< U > () const noexcept
 Cast operator from Vec2D<T> to Vec2D
 
constexpr T getX () const noexcept
 
constexpr T getY () const noexcept
 
constexpr Vec2D< T > operator- () const
 Negation operator e.g.: -Vec(2,1) => Vec(-2,-1)
 
constexpr auto operator+ (const IPoint auto &other) const noexcept
 
constexpr auto operator- (const IPoint auto &other) const noexcept
 
template<fishnet::math::Number U>
constexpr auto operator* (U scalar) const noexcept
 
constexpr auto operator/ (fishnet::math::DEFAULT_NUMERIC scalar) const noexcept
 
template<fishnet::math::Number U>
constexpr bool operator== (const Vec2D< U > &other) const noexcept
 
constexpr auto dot (const IPoint auto &other) const noexcept
 
constexpr auto cross (const IPoint auto &other) const noexcept
 
constexpr bool isParallel (const IPoint auto &other) const noexcept
 
constexpr bool isOrthogonal (const IPoint auto &other) const noexcept
 
constexpr fishnet::math::DEFAULT_FLOATING_POINT length () const
 
constexpr fishnet::math::DEFAULT_FLOATING_POINT distance (const IPoint auto &other) const
 
constexpr Vec2D< T > orthogonal () const noexcept
 
constexpr Vec2D< fishnet::math::DEFAULT_NUMERIC > normalize () const
 
fishnet::math::Radians angle (const IPoint auto &reference) const
 
fishnet::math::Radians angle (const IPoint auto &reference, fishnet::math::Radians angleRotate) const
 
constexpr size_t hash () const noexcept
 
constexpr std::string toString () const noexcept
 

Static Public Member Functions

template<fishnet::math::Number U, fishnet::math::Number V>
static constexpr auto construct (U x, V y) noexcept
 Helper factory method to construct the correct type of vector depending on the numeric types.
 

Public Attributes

T x
 
T y
 

Static Public Attributes

static constexpr GeometryType type = GeometryType::POINT
 

Detailed Description

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
class fishnet::geometry::Vec2D< T >

Implementation of a two-dimensional vector.

Template Parameters
Tnumeric type used for computations

Member Typedef Documentation

◆ numeric_type

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
using fishnet::geometry::Vec2D< T >::numeric_type = T

Constructor & Destructor Documentation

◆ Vec2D() [1/3]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr fishnet::geometry::Vec2D< T >::Vec2D ( T  x,
T  y 
)
inlineconstexpr

◆ Vec2D() [2/3]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
template<fishnet::math::Number U, fishnet::math::Number R, typename = std::enable_if_t<(!std::is_same_v<U,T> || ! std::is_same_v<R,T>)&& std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
constexpr fishnet::geometry::Vec2D< T >::Vec2D ( U  x,
R  y 
)
inlineconstexpr

Constructor for heterogenous types Converts to the default numeric type.

Template Parameters
Unumeric type of x
Rnumeric type of y
typename_ enable if -> only allow if T is the default numeric type and if either U or R is not the same type as T to prevent ambiguities
std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>

◆ Vec2D() [3/3]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr fishnet::geometry::Vec2D< T >::Vec2D ( )
inlineconstexpr

Default construction to (0,0)

Member Function Documentation

◆ angle() [1/2]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
fishnet::math::Radians fishnet::geometry::Vec2D< T >::angle ( const IPoint auto &  reference) const
inline

Computes the angle (counterclockwise) for the direction vector with reference at reference point, starting rotation on x-axis

Parameters
referencefor the angle
Returns

◆ angle() [2/2]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
fishnet::math::Radians fishnet::geometry::Vec2D< T >::angle ( const IPoint auto &  reference,
fishnet::math::Radians  angleRotate 
) const
inline

Calculates the angle with the previous method (starting from x-axis and performing a counterclockwise rotation) then rotates the angle by angleRotate

Parameters
reference
angleRotate
Returns

◆ construct()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
static constexpr auto fishnet::geometry::Vec2D< T >::construct ( U  x,
V  y 
)
inlinestaticconstexprnoexcept

Helper factory method to construct the correct type of vector depending on the numeric types.

Template Parameters
Unumeric type for x
Vnumeric type for y
Parameters
x
y
Returns
vector of a common numeric type that avoid narrowing conversions

◆ cross()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr auto fishnet::geometry::Vec2D< T >::cross ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ distance()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr fishnet::math::DEFAULT_FLOATING_POINT fishnet::geometry::Vec2D< T >::distance ( const IPoint auto &  other) const
inlineconstexpr

◆ dot()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr auto fishnet::geometry::Vec2D< T >::dot ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ getX()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr T fishnet::geometry::Vec2D< T >::getX ( ) const
inlineconstexprnoexcept

◆ getY()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr T fishnet::geometry::Vec2D< T >::getY ( ) const
inlineconstexprnoexcept

◆ hash()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr size_t fishnet::geometry::Vec2D< T >::hash ( ) const
inlineconstexprnoexcept

◆ isOrthogonal()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr bool fishnet::geometry::Vec2D< T >::isOrthogonal ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ isParallel()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr bool fishnet::geometry::Vec2D< T >::isParallel ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ length()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr fishnet::math::DEFAULT_FLOATING_POINT fishnet::geometry::Vec2D< T >::length ( ) const
inlineconstexpr

◆ normalize()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr Vec2D< fishnet::math::DEFAULT_NUMERIC > fishnet::geometry::Vec2D< T >::normalize ( ) const
inlineconstexpr

◆ operator Vec2D< U >()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
template<fishnet::math::Number U>
constexpr fishnet::geometry::Vec2D< T >::operator Vec2D< U > ( ) const
inlineconstexprnoexcept

Cast operator from Vec2D<T> to Vec2D

Template Parameters
Unumeric type of resulting vector
Returns
Vec2D

◆ operator*()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
template<fishnet::math::Number U>
constexpr auto fishnet::geometry::Vec2D< T >::operator* ( U  scalar) const
inlineconstexprnoexcept

◆ operator+()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr auto fishnet::geometry::Vec2D< T >::operator+ ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ operator-() [1/2]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr Vec2D< T > fishnet::geometry::Vec2D< T >::operator- ( ) const
inlineconstexpr

Negation operator e.g.: -Vec(2,1) => Vec(-2,-1)

Returns
constexpr Vec2D<T>

◆ operator-() [2/2]

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr auto fishnet::geometry::Vec2D< T >::operator- ( const IPoint auto &  other) const
inlineconstexprnoexcept

◆ operator/()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr auto fishnet::geometry::Vec2D< T >::operator/ ( fishnet::math::DEFAULT_NUMERIC  scalar) const
inlineconstexprnoexcept

◆ operator==()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
template<fishnet::math::Number U>
constexpr bool fishnet::geometry::Vec2D< T >::operator== ( const Vec2D< U > &  other) const
inlineconstexprnoexcept

◆ orthogonal()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr Vec2D< T > fishnet::geometry::Vec2D< T >::orthogonal ( ) const
inlineconstexprnoexcept

◆ toString()

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr std::string fishnet::geometry::Vec2D< T >::toString ( ) const
inlineconstexprnoexcept

Member Data Documentation

◆ type

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
constexpr GeometryType fishnet::geometry::Vec2D< T >::type = GeometryType::POINT
staticconstexpr

◆ x

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
T fishnet::geometry::Vec2D< T >::x

◆ y

template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
T fishnet::geometry::Vec2D< T >::y

The documentation for this class was generated from the following file: