HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
v1::point2 Class Reference

#include <hikogui/geometry/point2.hpp>

Public Types

using array_type = simd<float, 4>
using value_type = array_type::value_type

Public Member Functions

constexpr point2 (point2 const &) noexcept=default
constexpr point2 (point2 &&) noexcept=default
constexpr point2 & operator= (point2 const &) noexcept=default
constexpr point2 & operator= (point2 &&) noexcept=default
constexpr operator array_type () const noexcept
 Convert a point to its array_type-nummeric_array.
constexpr point2 (array_type const &other) noexcept
 Construct a point from a array_type-simd.
constexpr point2 () noexcept
 Construct a point at the origin of the coordinate system.
constexpr point2 (float x, float y) noexcept
 Construct a 3D point from x, y and z elements.
constexpr float & x () noexcept
 Access the x element from the point.
constexpr float & y () noexcept
 Access the y element from the point.
constexpr float x () const noexcept
 Access the x element from the point.
constexpr float y () const noexcept
 Access the y element from the point.
constexpr point2 & operator+= (vector2 const &rhs) noexcept
constexpr point2 & operator-= (vector2 const &rhs) noexcept
constexpr bool holds_invariant () const noexcept
 Check if the point is valid.

Friends

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

Detailed Description

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

◆ point2() [1/3]

v1::point2::point2 ( array_type const & other)
inlineexplicitnodiscardconstexprnoexcept

Construct a point from a array_type-simd.

◆ point2() [2/3]

v1::point2::point2 ( )
inlinenodiscardconstexprnoexcept

Construct a point at the origin of the coordinate system.

◆ point2() [3/3]

v1::point2::point2 ( float x,
float y )
inlinenodiscardconstexprnoexcept

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

Parameters
xThe x element.
yThe y element.

Member Function Documentation

◆ holds_invariant()

bool v1::point2::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()

v1::point2::operator array_type ( ) const
inlineexplicitnodiscardconstexprnoexcept

Convert a point to its array_type-nummeric_array.

◆ x() [1/2]

float v1::point2::x ( ) const
inlinenodiscardconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ x() [2/2]

float & v1::point2::x ( )
inlinenodiscardconstexprnoexcept

Access the x element from the point.

Returns
a reference to the x element.

◆ y() [1/2]

float v1::point2::y ( ) const
inlinenodiscardconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ y() [2/2]

float & v1::point2::y ( )
inlinenodiscardconstexprnoexcept

Access the y element from the point.

Returns
a reference to the y element.

◆ ceil [1/2]

point2 ceil ( point2 const & lhs,
extent2 rhs )
friend

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

◆ ceil [2/2]

point2 ceil ( point2 const & rhs)
friend

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

◆ floor [1/2]

point2 floor ( point2 const & lhs,
extent2 rhs )
friend

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

◆ floor [2/2]

point2 floor ( point2 const & rhs)
friend

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

◆ max

point2 max ( point2 const & lhs,
point2 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

point2 min ( point2 const & lhs,
point2 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]

friend point2 operator+ ( point2 const & lhs,
vector2 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]

friend point2 operator+ ( vector2 const & lhs,
point2 const & rhs )
friend

Move a point along a vector.

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

◆ operator- [1/2]

friend vector2 operator- ( point2 const & lhs,
point2 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]

friend point2 operator- ( point2 const & lhs,
vector2 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==

friend bool operator== ( point2 const & lhs,
point2 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.

◆ reflect

point2 reflect ( point2 const & lhs,
point2 const & rhs )
friend

Reflect a point.

Parameters
lhsThe point to be reflected
rhsThe anchor point.
Returns
The reflected point.

◆ round

point2 round ( point2 const & rhs)
friend

Round the coordinates of a point toward nearest integer.


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