HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Friends
v1::geo::point< D > Class Template Reference

#include <hikogui/geometry/point.hpp>

Public Member Functions

constexpr point (point const &) noexcept=default
 
constexpr point (point &&) noexcept=default
 
constexpr pointoperator= (point const &) noexcept=default
 
constexpr pointoperator= (point &&) noexcept=default
 
template<int E>
requires (E < D)
constexpr point (point< E > const &other) noexcept
 Construct a point from a lower dimension point.
 
constexpr point (point< 2 > const &other, float z) noexcept
 Construct a point from a lower dimension point.
 
template<int E>
requires (E > D)
constexpr point (point< E > const &other) noexcept
 Construct a point from a higher dimension point.
 
constexpr operator f32x4 () const noexcept
 Convert a point to its f32x4-nummeric_array.
 
constexpr point (f32x4 const &other) noexcept
 Construct a point from a f32x4-numeric_array.
 
constexpr point () noexcept
 Construct a point at the origin of the coordinate system.
 
constexpr point (float x, float y) noexcept
 Construct a 2D point from x and y elements.
 
constexpr point (float x, float y, float z=0.0) noexcept
 Construct a 3D point from x, y and z elements.
 
constexpr floatx () noexcept
 Access the x element from the point.
 
constexpr floaty () noexcept
 Access the y element from the point.
 
constexpr floatz () noexcept
 Access the z element from the point.
 
constexpr float constx () const noexcept
 Access the x element from the point.
 
constexpr float consty () const noexcept
 Access the y element from the point.
 
constexpr float constz () const noexcept
 Access the z element from the point.
 
template<int E>
requires (E <= D)
constexpr pointoperator+= (vector< E > const &rhs) noexcept
 
template<int E>
requires (E <= D)
constexpr pointoperator-= (vector< 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< E > const &rhs) noexcept
 Move a point along a vector.
 
template<int E>
constexpr friend auto operator+ (vector< E > const &rhs, point const &lhs) noexcept
 Move a point along a vector.
 
template<int E>
constexpr friend auto operator- (point const &lhs, vector< E > const &rhs) noexcept
 Move a point backward along the vector.
 
constexpr friend vector< 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< E > const &rhs) noexcept
 
template<int E>
constexpr auto reflect (point const &lhs, point< E > const &rhs) noexcept
 
template<int E>
constexpr auto min (point const &lhs, point< 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< E > const &rhs) noexcept
 Mix the two points and get the heighest 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, extent2 rhs) noexcept
 Round the coordinates of a point toward the top-right with the given granularity.
 
constexpr point floor (point const &lhs, extent2 rhs) noexcept
 Round the coordinates of a point toward the left-bottom with the given granularity.
 
constexpr float 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<int D>
class v1::geo::point< 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<int D>
template<int E>
requires (E < D)
constexpr v1::geo::point< D >::point ( point< E > const & other)
inlineconstexprnoexcept

Construct a point from a lower dimension point.

◆ point() [2/7]

template<int D>
constexpr v1::geo::point< D >::point ( point< 2 > const & other,
float z )
inlineconstexprnoexcept

Construct a point from a lower dimension point.

◆ point() [3/7]

template<int D>
template<int E>
requires (E > D)
constexpr v1::geo::point< D >::point ( point< E > const & other)
inlineexplicitconstexprnoexcept

Construct a point from a higher dimension point.

This will clear the values in the higher dimensions.

◆ point() [4/7]

template<int D>
constexpr v1::geo::point< D >::point ( f32x4 const & other)
inlineexplicitconstexprnoexcept

Construct a point from a f32x4-numeric_array.

◆ point() [5/7]

template<int D>
constexpr v1::geo::point< D >::point ( )
inlineconstexprnoexcept

Construct a point at the origin of the coordinate system.

◆ point() [6/7]

template<int D>
constexpr v1::geo::point< D >::point ( float x,
float y )
inlineconstexprnoexcept

Construct a 2D point from x and y elements.

Parameters
xThe x element.
yThe y element.

◆ point() [7/7]

template<int D>
constexpr v1::geo::point< D >::point ( float x,
float y,
float z = 0.0 )
inlineconstexprnoexcept

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<int D>
constexpr bool v1::geo::point< D >::holds_invariant ( ) const
inlineconstexprnoexcept

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 f32x4()

template<int D>
constexpr v1::geo::point< D >::operator f32x4 ( ) const
inlineexplicitconstexprnoexcept

Convert a point to its f32x4-nummeric_array.

◆ x() [1/2]

template<int D>
constexpr float const & v1::geo::point< D >::x ( ) const
inlineconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ x() [2/2]

template<int D>
constexpr float & v1::geo::point< D >::x ( )
inlineconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ y() [1/2]

template<int D>
constexpr float const & v1::geo::point< D >::y ( ) const
inlineconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ y() [2/2]

template<int D>
constexpr float & v1::geo::point< D >::y ( )
inlineconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ z() [1/2]

template<int D>
constexpr float const & v1::geo::point< D >::z ( ) const
inlineconstexprnoexcept

Access the z element from the point.

Returns
a reference to the z element.

◆ z() [2/2]

template<int D>
constexpr float & v1::geo::point< D >::z ( )
inlineconstexprnoexcept

Access the z element from the point.

Returns
a reference to the z element.

Friends And Related Symbol Documentation

◆ ceil [1/2]

template<int D>
constexpr point ceil ( point< D > const & lhs,
extent2 rhs )
friend

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

◆ ceil [2/2]

template<int D>
constexpr point ceil ( point< D > const & rhs)
friend

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

◆ floor [1/2]

template<int D>
constexpr point floor ( point< D > const & lhs,
extent2 rhs )
friend

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

◆ floor [2/2]

template<int D>
constexpr point floor ( point< D > const & rhs)
friend

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

◆ max

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

Mix the two points and get the heighest 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<int D>
template<int E>
constexpr auto min ( point< D > const & lhs,
point< 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<int D>
template<int E>
constexpr friend auto operator+ ( point< D > const & lhs,
vector< 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<int D>
template<int E>
constexpr friend auto operator+ ( vector< E > const & rhs,
point< 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<int D>
constexpr friend vector< D > operator- ( point< D > const & lhs,
point< 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<int D>
template<int E>
constexpr friend auto operator- ( point< D > const & lhs,
vector< 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<int D>
constexpr friend bool operator== ( point< D > const & lhs,
point< 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<int D>
constexpr point round ( point< D > const & rhs)
friend

Round the coordinates of a point toward nearest integer.


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