Recti 1.2.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
recti::Point< T1, T2 > Class Template Reference

Point. More...

#include <point.hpp>

Public Types

using value_type = T1
 

Public Member Functions

constexpr Point ()
 Default constructor.
 
constexpr Point (T1 xcoord, T2 ycoord) noexcept
 Construct a new Point object.
 
constexpr auto xcoord () const -> const T1 &
 Gets the x coordinate of this Point.
 
constexpr auto ycoord () const -> const T2 &
 Gets the y coordinate of this Point.
 
Comparison operators

definie ==, !=, <, >, <=, >=.

template<typename U1 , typename U2 >
constexpr auto operator== (const Point< U1, U2 > &rhs) const -> bool
 Compares this Point object with another Point object for equality.
 
template<typename U1 , typename U2 >
constexpr auto operator< (const Point< U1, U2 > &rhs) const -> bool
 Compares this Point object with another Point object to check if it is less than.
 
template<typename U1 , typename U2 >
constexpr auto operator!= (const Point< U1, U2 > &rhs) const -> bool
 Compares this Point object with another Point object for inequality.
 

Arithmetic operators

definie +, -, *, /, +=, -=, *=, /=, etc.

template<typename U1 , typename U2 >
CONSTEXPR14 auto operator+= (const Vector2< U1, U2 > &right_point) -> Self &
 Adds a vector (translation) to this Point.
 
template<typename U1 , typename U2 >
CONSTEXPR14 auto operator-= (const Vector2< U1, U2 > &right_point) -> Self &
 Subtracts a vector (translation) from this Point.
 
constexpr auto operator- (const Self &other_point) const
 Calculates the displacement vector between this point and another point.
 
constexpr auto measure () const
 measure (area, volume etc.)
 
constexpr auto flip_xy () const -> Point< T2, T1 >
 flip_xy according to xcoord-ycoord diagonal line
 
constexpr auto flip_y () const -> Point< T1, T2 >
 flip according to ycoord-axis
 
template<typename U1 , typename U2 >
constexpr auto overlaps (const Point< U1, U2 > &other_point) const -> bool
 
template<typename U1 , typename U2 >
constexpr auto intersect_with (const Point< U1, U2 > &other_point) const
 
template<typename U1 , typename U2 >
constexpr auto hull_with (const Point< U1, U2 > &other_point) const
 
template<typename U1 , typename U2 >
constexpr auto contains (const Point< U1, U2 > &other_point) const -> bool
 
template<typename U1 , typename U2 >
constexpr auto blocks (const Point< U1, U2 > &other_point) const -> bool
 
template<typename U1 , typename U2 >
constexpr auto min_dist_with (const Point< U1, U2 > &other_point) const
 minimum distance between this point and another point
 
template<typename U1 , typename U2 >
constexpr auto min_dist_change_with (Point< U1, U2 > &other_point)
 minimum distance between this point and another point
 
template<typename T >
constexpr auto enlarge_with (const T &value) const
 Enlarge the point by value
 
template<typename U1 , typename U2 >
constexpr auto nearest_to (const Point< U1, U2 > &other_point) const
 
constexpr auto rotates () const -> Point< T1, T2 >
 Rotate the point by 45 degrees (used for ManhattanArc).
 
constexpr auto inv_rotates () const -> Point< T1, T2 >
 Inverse rotate the point (used for ManhattanArc).
 
constexpr auto get_center () const
 Calculate the center of the point.
 
constexpr auto lower_corner () const
 Calculate the lower corner of the point.
 
constexpr auto upper_corner () const
 Calculate the upper corner of the point.
 
template<typename U1 , typename U2 >
constexpr auto operator+ (Point lhs, const Vector2< U1, U2 > &vector)
 Adds a vector (translation) to this Point.
 
template<typename U1 , typename U2 >
constexpr auto operator- (Point lhs, const Vector2< U1, U2 > &vector)
 
template<class Stream >
auto operator<< (Stream &output_stream, const Point &obj) -> Stream &
 
CONSTEXPR14 auto get_xcoord () -> T1 &
 Returns a mutable reference to the x-coordinate of the point.
 
constexpr auto get_xcoord () const -> const T1 &
 Returns a const reference to the x-coordinate of the point.
 
CONSTEXPR14 auto get_ycoord () -> T2 &
 Returns a mutable reference to the y-coordinate of the point.
 
constexpr auto get_ycoord () const -> const T2 &
 Returns a const reference to the y-coordinate of the point.
 

Detailed Description

template<typename T1 = int, typename T2 = T1>
class recti::Point< T1, T2 >

Point.

The Point class is a template class that represents a point in a 2D coordinate system. It has two template parameters, T1 and T2, which can be either int, Interval, or another Point. The Point class provides various operations and functionalities for working with points, such as comparison operators, arithmetic operators, flipping, overlap checking, distance calculation, and more.

Template Parameters
T1int, Interval, or Point
T2int, Interval, or Point

Member Typedef Documentation

◆ value_type

template<typename T1 = int, typename T2 = T1>
using recti::Point< T1, T2 >::value_type = T1

Constructor & Destructor Documentation

◆ Point() [1/2]

template<typename T1 = int, typename T2 = T1>
constexpr recti::Point< T1, T2 >::Point ( )
inlineconstexpr

Default constructor.

◆ Point() [2/2]

template<typename T1 = int, typename T2 = T1>
constexpr recti::Point< T1, T2 >::Point ( T1  xcoord,
T2  ycoord 
)
inlineconstexprnoexcept

Construct a new Point object.

This is a constructor for the Point class. It takes two parameters, xcoord and ycoord, and constructs a new Point object with those values. The parameters are passed as rvalue references (T1&& and T2&&) to allow for efficient move semantics. The constructor is marked as constexpr to indicate that it can be evaluated at compile-time if the arguments are compile-time constants.

Parameters
[in]xcoord- x coordinate.
[in]ycoord- y coordinate.

Member Function Documentation

◆ blocks()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::blocks ( const Point< U1, U2 > &  other_point) const -> bool
inlineconstexpr

Checks if this point blocks another point.

Template Parameters
U1- The type of the x-coordinate for this point.
U2- The type of the y-coordinate for this point.
Parameters
other_point- The other point to check for containment.
Returns
true if the x and y coordinates contain, false otherwise.

◆ contains()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::contains ( const Point< U1, U2 > &  other_point) const -> bool
inlineconstexpr

Checks if this point contains another point.

Template Parameters
U1- The type of the x-coordinate for this point.
U2- The type of the y-coordinate for this point.
Parameters
other_point- The other point to check for containment.
Returns
true if the x and y coordinates contain, false otherwise.

◆ enlarge_with()

template<typename T1 = int, typename T2 = T1>
template<typename T >
constexpr auto recti::Point< T1, T2 >::enlarge_with ( const T &  value) const
inlineconstexpr

Enlarge the point by value

Parameters
[in]valueThe value to enlarge
Returns
A reference to the modified Interval object.

◆ flip_xy()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::flip_xy ( ) const -> Point<T2, T1>
inlineconstexpr

flip_xy according to xcoord-ycoord diagonal line

Returns
Point<T2, T1>

◆ flip_y()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::flip_y ( ) const -> Point<T1, T2>
inlineconstexpr

flip according to ycoord-axis

Returns
Point<T1, T2>

◆ get_center()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::get_center ( ) const
inlineconstexpr

Calculate the center of the point.

Returns
The center of the point.

◆ get_xcoord() [1/2]

template<typename T1 = int, typename T2 = T1>
CONSTEXPR14 auto recti::Point< T1, T2 >::get_xcoord ( ) -> T1&
inlineprotected

Returns a mutable reference to the x-coordinate of the point.

Returns
T1& A reference to the x-coordinate of the point.

◆ get_xcoord() [2/2]

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::get_xcoord ( ) const -> const T1&
inlineconstexprprotected

Returns a const reference to the x-coordinate of the point.

Returns
const T1& A const reference to the x-coordinate of the point.

◆ get_ycoord() [1/2]

template<typename T1 = int, typename T2 = T1>
CONSTEXPR14 auto recti::Point< T1, T2 >::get_ycoord ( ) -> T2&
inlineprotected

Returns a mutable reference to the y-coordinate of the point.

Returns
T2& A reference to the y-coordinate of the point.

◆ get_ycoord() [2/2]

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::get_ycoord ( ) const -> const T2&
inlineconstexprprotected

Returns a const reference to the y-coordinate of the point.

Returns
const T2& A const reference to the y-coordinate of the point.

◆ hull_with()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::hull_with ( const Point< U1, U2 > &  other_point) const
inlineconstexpr

Return the hull (bounding box) of this point and another point.

Template Parameters
U1- The x-coordinate type of the other point.
U2- The y-coordinate type of the other point.
Parameters
other_point- The other point to check for hull.
Returns
The hull "point".

◆ intersect_with()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::intersect_with ( const Point< U1, U2 > &  other_point) const
inlineconstexpr

Checks if this point intersects with another point.

Template Parameters
U1- The x-coordinate type of the other point.
U2- The y-coordinate type of the other point.
Parameters
other_point- The other point to check for intersection.
Returns
The intersection point if the points intersect.

◆ inv_rotates()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::inv_rotates ( ) const -> Point<T1, T2>
inlineconstexpr

Inverse rotate the point (used for ManhattanArc).

Returns
A new inversely rotated Point.

◆ lower_corner()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::lower_corner ( ) const
inlineconstexpr

Calculate the lower corner of the point.

Returns
The lower corner of the point.

◆ measure()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::measure ( ) const
inlineconstexpr

measure (area, volume etc.)

The function returns the measure (area, volume etc.).

◆ min_dist_change_with()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::min_dist_change_with ( Point< U1, U2 > &  other_point)
inlineconstexpr

minimum distance between this point and another point

Template Parameters
U1- The x-coordinate type of the other point.
U2- The y-coordinate type of the other point.
Parameters
other_point- The other point to calculate the minimum distance from.
Returns
The minimum distance between this point and the other point.

◆ min_dist_with()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::min_dist_with ( const Point< U1, U2 > &  other_point) const
inlineconstexpr

minimum distance between this point and another point

Template Parameters
U1- The x-coordinate type of the other point.
U2- The y-coordinate type of the other point.
Parameters
other_point- The other point to calculate the minimum distance from.
Returns
The minimum distance between this point and the other point.

◆ nearest_to()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::nearest_to ( const Point< U1, U2 > &  other_point) const
inlineconstexpr

Return the point in this object that is nearest to the given point.

Parameters
other_point- The other point.
Returns
The nearest "point".

◆ operator!=()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::operator!= ( const Point< U1, U2 > &  rhs) const -> bool
inlineconstexpr

Compares this Point object with another Point object for inequality.

This operator checks if the x and y coordinates of this Point are not equal to the x and y coordinates of the given Point object. It allows Points to be compared for inequality in a generic way.

Template Parameters
U1- The type of x coordinate for this Point.
U2- The type of y coordinate for this Point.
Parameters
[in]rhs- The other Point object to compare against.
Returns
false if the two Point objects have equal x and y coordinates, true otherwise.

◆ operator+=()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
CONSTEXPR14 auto recti::Point< T1, T2 >::operator+= ( const Vector2< U1, U2 > &  right_point) -> Self&
inline

Adds a vector (translation) to this Point.

Translates this Point by the given vector's x and y components.

Template Parameters
U1- The x coordinate type of the vector.
U2- The y coordinate type of the vector.
Parameters
[in]right_point- The vector to translate this Point by.
Returns
Reference to this Point after translation.

◆ operator-()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::operator- ( const Self &  other_point) const
inlineconstexpr

Calculates the displacement vector between this point and another point.

Parameters
[in]other_pointThe other point to calculate the displacement from
Returns
The displacement vector from other_point to this point

◆ operator-=()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
CONSTEXPR14 auto recti::Point< T1, T2 >::operator-= ( const Vector2< U1, U2 > &  right_point) -> Self&
inline

Subtracts a vector (translation) from this Point.

Translates this Point by the given vector's x and y components.

Template Parameters
U1- The x coordinate type of the vector.
U2- The y coordinate type of the vector.
Parameters
[in]right_point- The vector to translate this Point by.
Returns
Reference to this Point after translation.

◆ operator<()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::operator< ( const Point< U1, U2 > &  rhs) const -> bool
inlineconstexpr

Compares this Point object with another Point object to check if it is less than.

This operator checks if this Point is less than the given Point by comparing their x and y coordinates. It allows Points to be compared in a generic way.

Template Parameters
U1- The type of x coordinate for this Point.
U2- The type of y coordinate for this Point.
Parameters
[in]rhs- The other Point to compare against.
Returns
True if this Point is less than rhs, false otherwise.

◆ operator==()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::operator== ( const Point< U1, U2 > &  rhs) const -> bool
inlineconstexpr

Compares this Point object with another Point object for equality.

This operator checks if the x and y coordinates of this Point are equal to the x and y coordinates of the given Point object. It allows Points to be compared for equality in a generic way.

Template Parameters
U1- The type of x coordinate for this Point.
U2- The type of y coordinate for this Point.
Parameters
[in]rhs- The other Point object to compare against.
Returns
True if the two Point objects have equal x and y coordinates, false otherwise.

◆ overlaps()

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto recti::Point< T1, T2 >::overlaps ( const Point< U1, U2 > &  other_point) const -> bool
inlineconstexpr

Checks if this point overlaps with another point.

Template Parameters
U1- The type of the x-coordinate for this point.
U2- The type of the y-coordinate for this point.
Parameters
other_point- The other point to check for overlap.
Returns
true if the x and y coordinates overlap, false otherwise.

◆ rotates()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::rotates ( ) const -> Point<T1, T2>
inlineconstexpr

Rotate the point by 45 degrees (used for ManhattanArc).

Returns
A new rotated Point.

◆ upper_corner()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::upper_corner ( ) const
inlineconstexpr

Calculate the upper corner of the point.

Returns
The upper corner of the point.

◆ xcoord()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::xcoord ( ) const -> const T1&
inlineconstexpr

Gets the x coordinate of this Point.

Returns
Const reference to the x coordinate.

◆ ycoord()

template<typename T1 = int, typename T2 = T1>
constexpr auto recti::Point< T1, T2 >::ycoord ( ) const -> const T2&
inlineconstexpr

Gets the y coordinate of this Point.

Returns
Const reference to the y coordinate.

Friends And Related Symbol Documentation

◆ operator+

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto operator+ ( Point< T1, T2 >  lhs,
const Vector2< U1, U2 > &  vector 
)
friend

Adds a vector (translation) to this Point.

Translates this Point by the given vector's x and y components.

Template Parameters
U1- The x coordinate type of the vector.
U2- The y coordinate type of the vector.
Parameters
[in]vector- The vector to translate this Point by.
Returns
A new Point after translation.

◆ operator-

template<typename T1 = int, typename T2 = T1>
template<typename U1 , typename U2 >
constexpr auto operator- ( Point< T1, T2 >  lhs,
const Vector2< U1, U2 > &  vector 
)
friend

Subtracts a vector (translation) from this Point.

Translates this Point by the given vector's x and y components.

Template Parameters
U1- The x coordinate type of this Point.
U2- The y coordinate type of this Point.
Parameters
[in]vector- The vector to translate this Point by.
Returns
A new Point after translation.

◆ operator<<

template<typename T1 = int, typename T2 = T1>
template<class Stream >
auto operator<< ( Stream &  output_stream,
const Point< T1, T2 > &  obj 
) -> Stream&
friend

Outputs the point object to the given output stream.

Parameters
[out]output_streamThe output stream to write the point to.
[in]objThe point object to output.
Returns
The output stream after writing the point.

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