TeiaCareSDK  v0.1.0
TeiaCareSDK is a collection of reusable C++ components
Loading...
Searching...
No Matches
tc::sdk::point< T > Class Template Reference

2D point specified by a pair of (x,y) coordinates. More...

#include <point.hpp>

Public Member Functions

constexpr point ()=default
 Default Constructor. Creates a default tc::sdk::point instance.
 
constexpr point (const point &)=default
 Copy Constructor. Copy a tc::sdk::point instance into another one.
 
constexpr point (point &&)=default
 Move Constructor. Copy a tc::sdk::point instance into another one.
 
constexpr point (T x, T y) noexcept
 Constructor. Creates tc::sdk::point instance with given X and Y coordinates.
 
pointoperator= (const point &)=default
 Assignment operator. Assign a tc::sdk::point instance to another one.
 
pointoperator= (point &&)=default
 Move assignment operator. Assign a tc::sdk::point instance to another one.
 
constexpr bool operator== (const point &other) const noexcept
 Equality operator.
 
constexpr bool operator!= (const point &other) const noexcept
 Inequality operator.
 
constexpr bool is_origin () const noexcept
 Check if the point is the origin.
 
constexprx () const noexcept
 X coordinate getter.
 
constexpry () const noexcept
 Y coordinate getter.
 
void set_x (T x) noexcept
 X coordinate setter. Set the X coordinate of the point.
 
void set_y (T y) noexcept
 Y coordinate setter. Set the Y coordinate of the point.
 
void add_delta (T delta_x, T delta_y) noexcept
 Increments point's coordinate of delta_x and delta_y values.
 
void sub_delta (T delta_x, T delta_y) noexcept
 Decrements point's coordinate of delta_x and delta_y values.
 
constexprdistance_from_origin () const noexcept
 Distance between the current point and the origin.
 
constexprdistance (point other) const noexcept
 Distance between the current point and another one.
 
constexpr point operator+ (point other) const noexcept
 Add two points.
 
pointoperator+= (point other) noexcept
 Add another point's coordinate to the current one.
 
constexpr point operator- (point other) const noexcept
 Subtract two points.
 
pointoperator-= (point other) noexcept
 Subtract another point's coordinate to the current one.
 
template<typename ScalarT >
pointoperator*= (ScalarT scalar) noexcept
 Multiply current point's coordinate by a scalar value.
 
template<typename ScalarT >
constexpr point operator* (ScalarT scalar) const noexcept
 Multiply a point by a given scalar value.
 
template<typename ScalarT >
pointoperator/= (ScalarT scalar)
 Divide current point's coordinate by a scalar value.
 
template<typename ScalarT >
constexpr point operator/ (ScalarT scalar) const
 Divide a point by a given scalar value.
 
constexpr std::string to_string () const
 Get the point string representation.
 

Friends

std::ostream & operator<< (std::ostream &stream, const point &p)
 Output stream operator.
 

Detailed Description

template<typename T>
class tc::sdk::point< T >

2D point specified by a pair of (x,y) coordinates.

Template Parameters
TCoordinates type

Definition at line 29 of file point.hpp.

Constructor & Destructor Documentation

◆ point()

template<typename T >
constexpr tc::sdk::point< T >::point ( x,
y 
)
inlineexplicitconstexprnoexcept

Constructor. Creates tc::sdk::point instance with given X and Y coordinates.

Parameters
xthe X coordinate of the point
ythe Y coordinate of the point

Definition at line 52 of file point.hpp.

Member Function Documentation

◆ operator==()

template<typename T >
constexpr bool tc::sdk::point< T >::operator== ( const point< T > &  other) const
inlineconstexprnoexcept

Equality operator.

Parameters
otherthe point to compare against.
Returns
true if the two points have the same coordinates.

Definition at line 73 of file point.hpp.

◆ operator!=()

template<typename T >
constexpr bool tc::sdk::point< T >::operator!= ( const point< T > &  other) const
inlineconstexprnoexcept

Inequality operator.

Parameters
otherthe point to compare against.
Returns
true if the two points have the different coordinates.

Definition at line 83 of file point.hpp.

◆ is_origin()

template<typename T >
constexpr bool tc::sdk::point< T >::is_origin ( ) const
inlineconstexprnoexcept

Check if the point is the origin.

Returns
true if the point has coordinates (0,0)

Definition at line 92 of file point.hpp.

◆ x()

template<typename T >
constexpr T tc::sdk::point< T >::x ( ) const
inlineconstexprnoexcept

X coordinate getter.

Returns
X coordinate of the point.

Definition at line 101 of file point.hpp.

◆ y()

template<typename T >
constexpr T tc::sdk::point< T >::y ( ) const
inlineconstexprnoexcept

Y coordinate getter.

Returns
Y coordinate of the point.

Definition at line 110 of file point.hpp.

◆ set_x()

template<typename T >
void tc::sdk::point< T >::set_x ( x)
inlinenoexcept

X coordinate setter. Set the X coordinate of the point.

Definition at line 118 of file point.hpp.

◆ set_y()

template<typename T >
void tc::sdk::point< T >::set_y ( y)
inlinenoexcept

Y coordinate setter. Set the Y coordinate of the point.

Definition at line 126 of file point.hpp.

◆ add_delta()

template<typename T >
void tc::sdk::point< T >::add_delta ( delta_x,
delta_y 
)
inlinenoexcept

Increments point's coordinate of delta_x and delta_y values.

Parameters
delta_xValue to be added to the current X coordinate.
delta_yValue to be added to the current Y coordinate.

Definition at line 136 of file point.hpp.

◆ sub_delta()

template<typename T >
void tc::sdk::point< T >::sub_delta ( delta_x,
delta_y 
)
inlinenoexcept

Decrements point's coordinate of delta_x and delta_y values.

Parameters
delta_xValue to be added to the current X coordinate.
delta_yValue to be added to the current Y coordinate.

Definition at line 147 of file point.hpp.

◆ distance_from_origin()

template<typename T >
constexpr T tc::sdk::point< T >::distance_from_origin ( ) const
inlineconstexprnoexcept

Distance between the current point and the origin.

Returns
The resulting distance.

Definition at line 157 of file point.hpp.

◆ distance()

template<typename T >
constexpr T tc::sdk::point< T >::distance ( point< T >  other) const
inlineconstexprnoexcept

Distance between the current point and another one.

Parameters
otherThe point to compute the distance from.
Returns
The resulting distance.

Definition at line 167 of file point.hpp.

◆ operator+()

template<typename T >
constexpr point tc::sdk::point< T >::operator+ ( point< T >  other) const
inlineconstexprnoexcept

Add two points.

Parameters
otherThe point to be added to the current one.
Returns
The resulting point.

Definition at line 179 of file point.hpp.

◆ operator+=()

template<typename T >
point & tc::sdk::point< T >::operator+= ( point< T >  other)
inlinenoexcept

Add another point's coordinate to the current one.

Parameters
otherThe point to be added to the current one.
Returns
The current point instance after the addition of the other.

Definition at line 189 of file point.hpp.

◆ operator-()

template<typename T >
constexpr point tc::sdk::point< T >::operator- ( point< T >  other) const
inlineconstexprnoexcept

Subtract two points.

Parameters
otherThe point to be subtracted to the current one.
Returns
The resulting point.

Definition at line 201 of file point.hpp.

◆ operator-=()

template<typename T >
point & tc::sdk::point< T >::operator-= ( point< T >  other)
inlinenoexcept

Subtract another point's coordinate to the current one.

Parameters
otherThe point to be subtracted to the current one.
Returns
The current point instance after the subtraction of the other.

Definition at line 211 of file point.hpp.

◆ operator*=()

template<typename T >
template<typename ScalarT >
point & tc::sdk::point< T >::operator*= ( ScalarT  scalar)
inlinenoexcept

Multiply current point's coordinate by a scalar value.

Parameters
scalarThe scalar value to multiply the current point with.
Returns
The current point instance after the scalar multiplication with the scalar value.

Definition at line 224 of file point.hpp.

◆ operator*()

template<typename T >
template<typename ScalarT >
constexpr point tc::sdk::point< T >::operator* ( ScalarT  scalar) const
inlineconstexprnoexcept

Multiply a point by a given scalar value.

Parameters
scalarThe scalar value to multiply the resulting point with.
Returns
The resulting point.

Definition at line 237 of file point.hpp.

◆ operator/=()

template<typename T >
template<typename ScalarT >
point & tc::sdk::point< T >::operator/= ( ScalarT  scalar)
inline

Divide current point's coordinate by a scalar value.

Parameters
scalarThe scalar value to multiply the current point with.
Returns
The current point instance after the scalar multiplication with the scalar value.

Definition at line 248 of file point.hpp.

◆ operator/()

template<typename T >
template<typename ScalarT >
constexpr point tc::sdk::point< T >::operator/ ( ScalarT  scalar) const
inlineconstexpr

Divide a point by a given scalar value.

Parameters
scalarThe scalar value to divide the resulting point with.
Returns
The resulting point.

Definition at line 261 of file point.hpp.

◆ to_string()

template<typename T >
constexpr std::string tc::sdk::point< T >::to_string ( ) const
inlineconstexpr

Get the point string representation.

Returns
String representation of the current point.

Definition at line 270 of file point.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  stream,
const point< T > &  p 
)
friend

Output stream operator.

Parameters
streamthe output stream to write into.
pthe point object to stream.
Returns
reference to the output stream operator, with the point string representation written into it.

Definition at line 281 of file point.hpp.


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