HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
v1::geo::point< T, D > Class Template Reference

#include <hikogui/geometry/point.hpp>

Public Types

using value_type = T
using array_type = simd<value_type, 4>

Public Member Functions

constexpr point (point const &) noexcept=default
constexpr point (point &&) noexcept=default
constexpr point & operator= (point const &) noexcept=default
constexpr point & operator= (point &&) noexcept=default
template<int E>
constexpr point (point< value_type, E > const &other) noexcept
 Construct a point from a lower dimension point.
constexpr point (point< value_type, 2 > const &other, value_type z) noexcept
 Construct a point from a lower dimension point.
template<int E>
constexpr point (point< value_type, E > const &other) noexcept
 Construct a point from a higher dimension point.
constexpr operator array_type () const noexcept
 Convert a point to its array_type-nummeric_array.
constexpr point (array_type const &other) noexcept
 Construct a point from a array_type-simd.
constexpr point () noexcept
 Construct a point at the origin of the coordinate system.
constexpr point (value_type x, value_type y) noexcept
 Construct a 2D point from x and y elements.
constexpr point (value_type x, value_type y, value_type z=value_type{0}) noexcept
 Construct a 3D point from x, y and z elements.
constexpr value_type & x () noexcept
 Access the x element from the point.
constexpr value_type & y () noexcept
 Access the y element from the point.
constexpr value_type & z () noexcept
 Access the z element from the point.
constexpr value_type x () const noexcept
 Access the x element from the point.
constexpr value_type y () const noexcept
 Access the y element from the point.
constexpr value_type z () const noexcept
 Access the z element from the point.
template<int E>
constexpr point & operator+= (vector< value_type, E > const &rhs) noexcept
template<int E>
constexpr point & operator-= (vector< value_type, E > const &rhs) noexcept
constexpr bool holds_invariant () const noexcept
 Check if the point is valid.

Friends

template<int E>
constexpr friend auto operator+ (point const &lhs, vector< value_type, E > const &rhs) noexcept
 Move a point along a vector.
template<int E>
constexpr friend auto operator+ (vector< value_type, E > const &rhs, point const &lhs) noexcept
 Move a point along a vector.
template<int E>
constexpr friend auto operator- (point const &lhs, vector< value_type, E > const &rhs) noexcept
 Move a point backward along the vector.
constexpr friend vector< value_type, D > operator- (point const &lhs, point const &rhs) noexcept
 Find the vector between two points.
constexpr friend bool operator== (point const &lhs, point const &rhs) noexcept
 Compare if two points are equal.
template<int E>
constexpr auto midpoint (point const &lhs, point< value_type, E > const &rhs) noexcept
template<int E>
constexpr auto reflect (point const &lhs, point< value_type, E > const &rhs) noexcept
template<int E>
constexpr auto min (point const &lhs, point< value_type, E > const &rhs) noexcept
 Mix the two points and get the lowest value of each element.
template<int E>
constexpr auto max (point const &lhs, point< value_type, E > const &rhs) noexcept
 Mix the two points and get the highest value of each element.
constexpr point round (point const &rhs) noexcept
 Round the coordinates of a point toward nearest integer.
constexpr point ceil (point const &rhs) noexcept
 Round the coordinates of a point toward the right-top.
constexpr point floor (point const &rhs) noexcept
 Round the coordinates of a point toward the left-bottom.
constexpr point ceil (point const &lhs, extent< value_type, D > rhs) noexcept
 Round the coordinates of a point toward the top-right with the given granularity.
constexpr point ceil (point const &lhs, extent< value_type, D > rhs) noexcept
 Round the coordinates of a point toward the top-right with the given granularity.
constexpr point floor (point const &lhs, extent< value_type, D > rhs) noexcept
 Round the coordinates of a point toward the left-bottom with the given granularity.
constexpr point floor (point const &lhs, extent< value_type, D > rhs) noexcept
 Round the coordinates of a point toward the left-bottom with the given granularity.
constexpr value_type distance (point const &lhs, point const &rhs) noexcept
std::string to_string (point const &rhs) noexcept
std::ostreamoperator<< (std::ostream &lhs, point const &rhs) noexcept

Detailed Description

template<typename T, int D>
class v1::geo::point< T, D >

A high-level geometric point Part of the high-level vec, point, mat and color types.

A point, for both 2D or 3D is internally represented as a 4D homogeneous vector. Which can be efficiently implemented as a __m128 SSE register.

Constructor & Destructor Documentation

◆ point() [1/7]

template<typename T, int D>
template<int E>
v1::geo::point< T, D >::point ( point< value_type, E > const & other)
inlinenodiscardconstexprnoexcept

Construct a point from a lower dimension point.

◆ point() [2/7]

template<typename T, int D>
v1::geo::point< T, D >::point ( point< value_type, 2 > const & other,
value_type z )
inlinenodiscardconstexprnoexcept

Construct a point from a lower dimension point.

◆ point() [3/7]

template<typename T, int D>
template<int E>
v1::geo::point< T, D >::point ( point< value_type, E > const & other)
inlineexplicitnodiscardconstexprnoexcept

Construct a point from a higher dimension point.

This will clear the values in the higher dimensions.

◆ point() [4/7]

template<typename T, int D>
v1::geo::point< T, D >::point ( array_type const & other)
inlineexplicitnodiscardconstexprnoexcept

Construct a point from a array_type-simd.

◆ point() [5/7]

template<typename T, int D>
v1::geo::point< T, D >::point ( )
inlinenodiscardconstexprnoexcept

Construct a point at the origin of the coordinate system.

◆ point() [6/7]

template<typename T, int D>
v1::geo::point< T, D >::point ( value_type x,
value_type y )
inlinenodiscardconstexprnoexcept

Construct a 2D point from x and y elements.

Parameters
xThe x element.
yThe y element.

◆ point() [7/7]

template<typename T, int D>
v1::geo::point< T, D >::point ( value_type x,
value_type y,
value_type z = value_type{0} )
inlinenodiscardconstexprnoexcept

Construct a 3D point from x, y and z elements.

Parameters
xThe x element.
yThe y element.
zThe z element.

Member Function Documentation

◆ holds_invariant()

template<typename T, int D>
bool v1::geo::point< T, D >::holds_invariant ( ) const
inlinenodiscardconstexprnoexcept

Check if the point is valid.

This function will check if w is not zero, and with a 2D point is z is zero.

◆ operator array_type()

template<typename T, int D>
v1::geo::point< T, D >::operator array_type ( ) const
inlineexplicitnodiscardconstexprnoexcept

Convert a point to its array_type-nummeric_array.

◆ x() [1/2]

template<typename T, int D>
value_type v1::geo::point< T, D >::x ( ) const
inlinenodiscardconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ x() [2/2]

template<typename T, int D>
value_type & v1::geo::point< T, D >::x ( )
inlinenodiscardconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ y() [1/2]

template<typename T, int D>
value_type v1::geo::point< T, D >::y ( ) const
inlinenodiscardconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ y() [2/2]

template<typename T, int D>
value_type & v1::geo::point< T, D >::y ( )
inlinenodiscardconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ z() [1/2]

template<typename T, int D>
value_type v1::geo::point< T, D >::z ( ) const
inlinenodiscardconstexprnoexcept

Access the z element from the point.

Returns
a reference to the z element.

◆ z() [2/2]

template<typename T, int D>
value_type & v1::geo::point< T, D >::z ( )
inlinenodiscardconstexprnoexcept

Access the z element from the point.

Returns
a reference to the z element.

◆ ceil [1/3]

template<typename T, int D>
point ceil ( point< T, D > const & lhs,
extent< value_type, D > rhs )
friend

Round the coordinates of a point toward the top-right with the given granularity.

◆ ceil [2/3]

template<typename T, int D>
point ceil ( point< T, D > const & lhs,
extent< value_type, D > rhs )
friend

Round the coordinates of a point toward the top-right with the given granularity.

◆ ceil [3/3]

template<typename T, int D>
point ceil ( point< T, D > const & rhs)
friend

Round the coordinates of a point toward the right-top.

◆ floor [1/3]

template<typename T, int D>
point floor ( point< T, D > const & lhs,
extent< value_type, D > rhs )
friend

Round the coordinates of a point toward the left-bottom with the given granularity.

◆ floor [2/3]

template<typename T, int D>
point floor ( point< T, D > const & lhs,
extent< value_type, D > rhs )
friend

Round the coordinates of a point toward the left-bottom with the given granularity.

◆ floor [3/3]

template<typename T, int D>
point floor ( point< T, D > const & rhs)
friend

Round the coordinates of a point toward the left-bottom.

◆ max

template<typename T, int D>
template<int E>
auto max ( point< T, D > const & lhs,
point< value_type, E > const & rhs )
friend

Mix the two points and get the highest value of each element.

Parameters
lhsThe first point.
rhsThe first point.
Returns
A point that is the most right of both points, and most top of both points.

◆ min

template<typename T, int D>
template<int E>
auto min ( point< T, D > const & lhs,
point< value_type, E > const & rhs )
friend

Mix the two points and get the lowest value of each element.

Parameters
lhsThe first point.
rhsThe first point.
Returns
A point that is the most left of both points, and most bottom of both points.

◆ operator+ [1/2]

template<typename T, int D>
template<int E>
friend auto operator+ ( point< T, D > const & lhs,
vector< value_type, E > const & rhs )
friend

Move a point along a vector.

Parameters
lhsThe point to move.
rhsThe vector to move along.
Returns
The moved point.

◆ operator+ [2/2]

template<typename T, int D>
template<int E>
friend auto operator+ ( vector< value_type, E > const & rhs,
point< T, D > const & lhs )
friend

Move a point along a vector.

Parameters
lhsThe vector to move along.
rhsThe point to move.
Returns
The moved point.

◆ operator- [1/2]

template<typename T, int D>
friend vector< value_type, D > operator- ( point< T, D > const & lhs,
point< T, D > const & rhs )
friend

Find the vector between two points.

Parameters
lhsThe first point.
rhsThe second point.
Returns
The vector from the second to first point.

◆ operator- [2/2]

template<typename T, int D>
template<int E>
friend auto operator- ( point< T, D > const & lhs,
vector< value_type, E > const & rhs )
friend

Move a point backward along the vector.

Parameters
lhsThe point to move.
rhsThe vector to move backward.
Returns
The moved point.

◆ operator==

template<typename T, int D>
friend bool operator== ( point< T, D > const & lhs,
point< T, D > const & rhs )
friend

Compare if two points are equal.

Parameters
lhsThe first point.
rhsThe second point.
Returns
True if both point are completely equal to each other.

◆ round

template<typename T, int D>
point round ( point< T, D > const & rhs)
friend

Round the coordinates of a point toward nearest integer.


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