Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::IntPoint Class Reference

Two-dimensional point with integer coordinates. More...

#include <int-point.h>

Inheritance diagram for Geom::IntPoint:

Classes

struct  LexGreater
 Lexicographical ordering functor. More...
 
struct  LexGreater< X >
 
struct  LexGreater< Y >
 
struct  LexGreaterRt
 Lexicographical ordering functor with runtime dimension. More...
 
struct  LexLess
 Lexicographical ordering functor. More...
 
struct  LexLess< X >
 
struct  LexLess< Y >
 
struct  LexLessRt
 Lexicographical ordering functor with runtime dimension. More...
 

Public Member Functions

Create integer points
constexpr IntPoint ()=default
 Construct a point at the origin.
 
constexpr IntPoint (IntCoord x, IntCoord y)
 Construct a point from its coordinates.
 
Access the coordinates of a point
IntCoord operator[] (unsigned i) const
 
IntCoordoperator[] (unsigned i)
 
constexpr IntCoord operator[] (Dim2 d) const
 
constexpr IntCoordoperator[] (Dim2 d)
 
constexpr IntCoord x () const noexcept
 
constexpr IntCoordx () noexcept
 
constexpr IntCoord y () const noexcept
 
constexpr IntCoordy () noexcept
 
template<size_t I>
constexpr IntCoord get () const
 
template<size_t I>
constexpr IntCoordget ()
 
Vector-like operations
constexpr IntCoord lengthSq () const
 
constexpr IntPoint ccw () const
 Return a point like this point but rotated -90 degrees.
 
constexpr IntPoint cw () const
 Return a point like this point but rotated +90 degrees.
 
Vector-like arithmetic operations
constexpr IntPoint operator- () const
 
constexpr IntPointoperator+= (IntPoint const &o)
 
constexpr IntPointoperator-= (IntPoint const &o)
 
constexpr IntPointoperator*= (IntPoint const &o)
 
constexpr IntPointoperator*= (IntCoord o)
 
constexpr IntPointoperator/= (IntPoint const &o)
 
constexpr IntPointoperator/= (IntCoord o)
 
Various utilities
constexpr bool operator== (IntPoint const &p) const
 Equality operator.
 
constexpr bool operator< (IntPoint const &p) const
 Lexicographical ordering for points.
 

Private Attributes

IntCoord _pt [2] = { 0, 0 }
 

Detailed Description

Two-dimensional point with integer coordinates.

This class is an exact equivalent of Point, except it stores integer coordinates. Integer points are useful in contexts related to rasterized graphics, for example for bounding boxes when rendering SVG.

See also
Point

Definition at line 51 of file int-point.h.

Constructor & Destructor Documentation

◆ IntPoint() [1/2]

constexpr Geom::IntPoint::IntPoint ( )
constexprdefault

Construct a point at the origin.

Referenced by ccw(), cw(), and operator-().

◆ IntPoint() [2/2]

constexpr Geom::IntPoint::IntPoint ( IntCoord  x,
IntCoord  y 
)
inlineconstexpr

Construct a point from its coordinates.

Definition at line 65 of file int-point.h.

Member Function Documentation

◆ ccw()

constexpr IntPoint Geom::IntPoint::ccw ( ) const
inlineconstexpr

Return a point like this point but rotated -90 degrees.

If the y axis grows downwards and the x axis grows to the right, then this is 90 degrees counter-clockwise.

Definition at line 93 of file int-point.h.

References _pt, IntPoint(), Geom::X, and Geom::Y.

◆ cw()

constexpr IntPoint Geom::IntPoint::cw ( ) const
inlineconstexpr

Return a point like this point but rotated +90 degrees.

If the y axis grows downwards and the x axis grows to the right, then this is 90 degrees clockwise.

Definition at line 99 of file int-point.h.

References _pt, IntPoint(), Geom::X, and Geom::Y.

◆ get() [1/2]

template<size_t I>
constexpr IntCoord & Geom::IntPoint::get ( )
inlineconstexpr

Definition at line 84 of file int-point.h.

References _pt.

◆ get() [2/2]

template<size_t I>
constexpr IntCoord Geom::IntPoint::get ( ) const
inlineconstexpr

Definition at line 83 of file int-point.h.

References _pt.

◆ lengthSq()

constexpr IntCoord Geom::IntPoint::lengthSq ( ) const
inlineconstexpr

Definition at line 89 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator*=() [1/2]

constexpr IntPoint & Geom::IntPoint::operator*= ( IntCoord  o)
inlineconstexpr

Definition at line 124 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator*=() [2/2]

constexpr IntPoint & Geom::IntPoint::operator*= ( IntPoint const o)
inlineconstexpr

Definition at line 119 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator+=()

constexpr IntPoint & Geom::IntPoint::operator+= ( IntPoint const o)
inlineconstexpr

Definition at line 109 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator-()

constexpr IntPoint Geom::IntPoint::operator- ( ) const
inlineconstexpr

Definition at line 106 of file int-point.h.

References _pt, IntPoint(), Geom::X, and Geom::Y.

◆ operator-=()

constexpr IntPoint & Geom::IntPoint::operator-= ( IntPoint const o)
inlineconstexpr

Definition at line 114 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator/=() [1/2]

constexpr IntPoint & Geom::IntPoint::operator/= ( IntCoord  o)
inlineconstexpr

Definition at line 134 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator/=() [2/2]

constexpr IntPoint & Geom::IntPoint::operator/= ( IntPoint const o)
inlineconstexpr

Definition at line 129 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator<()

constexpr bool Geom::IntPoint::operator< ( IntPoint const p) const
inlineconstexpr

Lexicographical ordering for points.

Y coordinate is regarded as more significant. When sorting according to this ordering, the points will be sorted according to the Y coordinate, and within points with the same Y coordinate according to the X coordinate.

Definition at line 151 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator==()

constexpr bool Geom::IntPoint::operator== ( IntPoint const p) const
inlineconstexpr

Equality operator.

Definition at line 144 of file int-point.h.

References _pt, Geom::X, and Geom::Y.

◆ operator[]() [1/4]

constexpr IntCoord & Geom::IntPoint::operator[] ( Dim2  d)
inlineconstexpr

Definition at line 75 of file int-point.h.

References _pt.

◆ operator[]() [2/4]

constexpr IntCoord Geom::IntPoint::operator[] ( Dim2  d) const
inlineconstexpr

Definition at line 74 of file int-point.h.

References _pt.

◆ operator[]() [3/4]

IntCoord & Geom::IntPoint::operator[] ( unsigned  i)
inline

Definition at line 73 of file int-point.h.

References _pt, and x().

◆ operator[]() [4/4]

IntCoord Geom::IntPoint::operator[] ( unsigned  i) const
inline

Definition at line 72 of file int-point.h.

References _pt, and x().

◆ x() [1/2]

◆ x() [2/2]

constexpr IntCoord & Geom::IntPoint::x ( )
inlineconstexprnoexcept

Definition at line 78 of file int-point.h.

References _pt, and Geom::X.

◆ y() [1/2]

◆ y() [2/2]

constexpr IntCoord & Geom::IntPoint::y ( )
inlineconstexprnoexcept

Definition at line 80 of file int-point.h.

References _pt, and Geom::Y.

Member Data Documentation

◆ _pt


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