#include <recti/point.hpp>
template<typename T1 = int, typename T2 = T1>
Point class
Template parameters | |
---|---|
T1 | int, Interval, or Point |
T2 | int, Interval, or 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.
Constructors, destructors, conversion operators
Public functions
Arithmetic operators
definie +, -, *, /, +=, -=, *=, /=, etc.
-
template<typename U1, typename U2>auto operator+(Point lhs, const Vector2<U1, U2>& vec2) -> auto constexpr
-
template<typename U1, typename U2>auto operator-(Point lhs, const Vector2<U1, U2>& vec2) -> auto constexpr
-
template<class Stream>auto operator<<(Stream& out, const Point& obj) -> Stream & -> auto
-
template<typename U1, typename U2>auto operator+=(const Vector2<U1, U2>& rhs) -> Self & -> CONSTEXPR14 auto
-
template<typename U1, typename U2>auto operator-=(const Vector2<U1, U2>& rhs) -> Self & -> CONSTEXPR14 auto
- auto operator-(const Self& other) const -> auto constexpr
- Calculates the displacement vector between this point and another point.
- auto flip_xy() const -> Point< T2, T1 > -> auto constexpr
- flip_xcoordy according to xcoord-ycoord diagonal line
- auto flip_y() const -> Point< T1, T2 > -> auto constexpr
- flip according to ycoord-axis
-
template<typename U1, typename U2>auto overlaps(const Point<U1, U2>& other) const -> bool -> auto constexpr
-
template<typename U1, typename U2>auto intersection_with(const Point<U1, U2>& other) const -> auto constexpr
-
template<typename U1, typename U2>auto contains(const Point<U1, U2>& other) const -> bool -> auto constexpr
-
template<typename U1, typename U2>auto min_dist_with(const Point<U1, U2>& other) const -> auto constexpr
- minimum distance between this point and another point
-
template<typename U1, typename U2>auto min_dist_change_with(Point<U1, U2>& other) -> auto constexpr
- minimum distance between this point and another point
- auto get_xcoord() -> T1 & -> CONSTEXPR14 auto protected
- auto get_ycoord() -> T2 & -> CONSTEXPR14 auto protected
Comparison operators
definie ==, !=, <, >, <=, >=.
-
template<typename U1, typename U2>auto operator==(const Point<U1, U2>& rhs) const -> bool -> auto constexpr
-
template<typename U1, typename U2>auto operator<(const Point<U1, U2>& rhs) const -> bool -> auto constexpr
-
template<typename U1, typename U2>auto operator!=(const Point<U1, U2>& rhs) const -> bool -> auto constexpr
Function documentation
template<typename T1, typename T2>
recti:: Point<T1, T2>:: Point(T1&& xcoord,
T2&& ycoord) constexpr noexcept
Construct a new Point object.
Parameters | |
---|---|
xcoord in | |
ycoord in |
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. The noexcept
specifier indicates that the constructor does not throw any exceptions.
template<typename T1, typename T2>
recti:: Point<T1, T2>:: Point(const T1& xcoord,
const T2& ycoord) constexpr
Parameters | |
---|---|
xcoord in | - x coordinate to copy. |
ycoord in | - y coordinate to copy. |
Copy constructor for Point class. Constructs a new Point by copying the x and y coordinates from an existing Point object.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: operator+(Point lhs,
const Vector2<U1, U2>& vec2) constexpr
Template parameters | |
---|---|
U1 | - The x coordinate type of this Point. |
U2 | - The y coordinate type of this Point. |
Returns | A new Point after translation. |
Adds a vector (translation) to this Point.
Translates this Point by the given vector's x and y components.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: operator-(Point lhs,
const Vector2<U1, U2>& vec2) constexpr
Template parameters | |
---|---|
U1 | - The x coordinate type of this Point. |
U2 | - The y coordinate type of this Point. |
Returns | A new Point after translation. |
Subtracts a vector (translation) from this Point.
Translates this Point by the given vector's x and y components.
template<typename T1, typename T2>
template<class Stream>
auto recti:: Point<T1, T2>:: operator<<(Stream& out,
const Point& obj) -> Stream &
Parameters | |
---|---|
out out | The output stream. |
obj in | The point to output. |
Returns | The output stream. |
Outputs the point obj to the output stream out.
template<typename T1, typename T2>
template<typename U1, typename U2>
CONSTEXPR14 auto recti:: Point<T1, T2>:: operator+=(const Vector2<U1, U2>& rhs) -> Self &
Template parameters | |
---|---|
U1 | - The x coordinate type of this Point. |
U2 | - The y coordinate type of this Point. |
Parameters | |
rhs in | - The vector to translate this Point by. |
Returns | Reference to this Point after translation. |
Adds a vector (translation) to this Point.
Translates this Point by the given vector's x and y components.
template<typename T1, typename T2>
template<typename U1, typename U2>
CONSTEXPR14 auto recti:: Point<T1, T2>:: operator-=(const Vector2<U1, U2>& rhs) -> Self &
Template parameters | |
---|---|
U1 | - The x coordinate type of this Point. |
U2 | - The y coordinate type of this Point. |
Parameters | |
rhs in | - The vector to translate this Point by. |
Returns | Reference to this Point after translation. |
Subtracts a vector (translation) from this Point.
Translates this Point by the given vector's x and y components.
template<typename T1, typename T2>
auto recti:: Point<T1, T2>:: operator-(const Self& other) const constexpr
Calculates the displacement vector between this point and another point.
Parameters | |
---|---|
other in | The other point to calculate the displacement from |
Returns | The displacement vector from other to this point |
template<typename T1, typename T2>
auto recti:: Point<T1, T2>:: flip_xy() const -> Point< T2, T1 > constexpr
flip_xcoordy according to xcoord-ycoord diagonal line
Returns | Point<T2, T1> |
---|
template<typename T1, typename T2>
auto recti:: Point<T1, T2>:: flip_y() const -> Point< T1, T2 > constexpr
flip according to ycoord-axis
Returns | Point<T2, T1> |
---|
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: overlaps(const Point<U1, U2>& other) const -> bool constexpr
Template parameters | |
---|---|
U1 | - The type of the x-coordinate for this point. |
U2 | - The type of the y-coordinate for this point. |
Parameters | |
other | - The other point to check for overlap. |
Returns | true if the x and y coordinates overlap, false otherwise. |
Checks if this point overlaps with another point.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: intersection_with(const Point<U1, U2>& other) const constexpr
Template parameters | |
---|---|
U1 | - The x-coordinate type of the other point. |
U2 | - The y-coordinate type of the other point. |
Parameters | |
other | - The other point to check for intersection. |
Returns | The intersection point if the points intersect. |
Checks if this point intersects with another point.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: contains(const Point<U1, U2>& other) const -> bool constexpr
Template parameters | |
---|---|
U1 | - The type of the x-coordinate for this point. |
U2 | - The type of the y-coordinate for this point. |
Parameters | |
other | - The other point to check for containment. |
Returns | true if the x and y coordinates contain, false otherwise. |
Checks if this point contains another point.
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: min_dist_with(const Point<U1, U2>& other) const constexpr
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 | - The other point to calculate the minimum distance from. |
Returns | The minimum distance between this point and the other point. |
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: min_dist_change_with(Point<U1, U2>& other) constexpr
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 | - The other point to calculate the minimum distance from. |
Returns | The minimum distance between this point and the other point. |
template<typename T1, typename T2>
CONSTEXPR14 auto recti:: Point<T1, T2>:: get_xcoord() -> T1 & protected
Returns | const T1& |
---|
template<typename T1, typename T2>
CONSTEXPR14 auto recti:: Point<T1, T2>:: get_ycoord() -> T2 & protected
Returns | const T2& |
---|
template<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: operator==(const Point<U1, U2>& rhs) const -> bool constexpr
Template parameters | |
---|---|
U1 | - The type of x coordinate for this Point. |
U2 | - The type of y coordinate for this Point. |
Parameters | |
rhs in | - The other Point object to compare against. |
Returns | True if the two Point objects have equal x and y coordinates, false otherwise. |
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<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: operator<(const Point<U1, U2>& rhs) const -> bool constexpr
Template parameters | |
---|---|
U1 | - The type of x coordinate for this Point. |
U2 | - The type of y coordinate for this Point. |
Parameters | |
rhs in | - The other Point to compare against. |
Returns | True if this Point is less than rhs, false otherwise. |
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<typename T1, typename T2>
template<typename U1, typename U2>
auto recti:: Point<T1, T2>:: operator!=(const Point<U1, U2>& rhs) const -> bool constexpr
Template parameters | |
---|---|
U1 | - The type of x coordinate for this Point. |
U2 | - The type of y coordinate for this Point. |
Parameters | |
rhs in | - The other Point object to compare against. |
Returns | False if the two Point objects have equal x and y coordinates, true otherwise. |
Compares this Point object with another Point object for equality.
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 equality in a generic way.