CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Public Attributes | List of all members
CartoTypeCore::Point2< T > Class Template Reference

#include <cartotype_base.h>

Public Member Functions

constexpr Point2 () noexcept
 
constexpr Point2 (T aX, T aY) noexcept
 
constexpr Point2 (const Point &aPoint) noexcept
 
bool operator== (const Point2< T > &aPoint) const noexcept
 
bool operator!= (const Point2< T > &aPoint) const noexcept
 
void operator+= (const Point2< T > &aPoint) noexcept
 
void operator-= (const Point2< T > &aPoint) noexcept
 
void operator*= (T aFactor) noexcept
 
bool operator< (const Point2< T > &aPoint) const noexcept
 
bool operator> (const Point2< T > &aPoint) const noexcept
 
VectorLength () const noexcept
 
DistanceFrom (const Point2< T > &aOther) const noexcept
 
CrossProduct (const Point2< T > &aOther) const noexcept
 
Point2 UnitVector () const noexcept
 
Point2 LeftUnitVector () const noexcept
 
Point2 RightUnitVector () const noexcept
 
bool LeftOfVector (const Point2< T > &aPoint) const noexcept
 
bool RightOfVector (const Point2< T > &aPoint) const noexcept
 
Point Rounded () const noexcept
 
Point Rounded64ths () const noexcept
 
void Rotate (double aAngle)
 

Public Attributes

X { 0 }
 
Y { 0 }
 

Detailed Description

template<class T>
class CartoTypeCore::Point2< T >

A templated 2D point or vector class. In the vector functions, left and right are defined using x increasing right and y increasing up.

Constructor & Destructor Documentation

◆ Point2() [1/3]

template<class T >
constexpr CartoTypeCore::Point2< T >::Point2 ( )
inlineconstexprnoexcept

Create a point with coordinates (0,0).

◆ Point2() [2/3]

template<class T >
constexpr CartoTypeCore::Point2< T >::Point2 ( aX,
aY 
)
inlineconstexprnoexcept

Create a point, specifying coordinates.

◆ Point2() [3/3]

template<class T >
constexpr CartoTypeCore::Point2< T >::Point2 ( const Point aPoint)
inlineconstexprnoexcept

Create a point from a Point object.

Member Function Documentation

◆ CrossProduct()

template<class T >
T CartoTypeCore::Point2< T >::CrossProduct ( const Point2< T > &  aOther) const
inlinenoexcept

Returns the cross product of two vectors. The cross product of two unit vectors is the sine of the angle swept out by going from this vector to the other vector in an anticlockwise direction, and may be positive or negative.

◆ DistanceFrom()

template<class T >
T CartoTypeCore::Point2< T >::DistanceFrom ( const Point2< T > &  aOther) const
inlinenoexcept

Returns the distance of this point from another point.

◆ LeftOfVector()

template<class T >
bool CartoTypeCore::Point2< T >::LeftOfVector ( const Point2< T > &  aPoint) const
inlinenoexcept

Returns true if aPoint is left of this vector.

◆ LeftUnitVector()

template<class T >
Point2 CartoTypeCore::Point2< T >::LeftUnitVector ( ) const
inlinenoexcept

Returns a unit vector pointing 90 degrees left of this vector.

◆ operator!=()

template<class T >
bool CartoTypeCore::Point2< T >::operator!= ( const Point2< T > &  aPoint) const
inlinenoexcept

The inequality operator.

◆ operator*=()

template<class T >
void CartoTypeCore::Point2< T >::operator*= ( aFactor)
inlinenoexcept

Scale a point by a factor.

◆ operator+=()

template<class T >
void CartoTypeCore::Point2< T >::operator+= ( const Point2< T > &  aPoint)
inlinenoexcept

Offset a point by another point, treated as a positive vector.

◆ operator-=()

template<class T >
void CartoTypeCore::Point2< T >::operator-= ( const Point2< T > &  aPoint)
inlinenoexcept

Offset a point by another point, treated as a negative vector.

◆ operator<()

template<class T >
bool CartoTypeCore::Point2< T >::operator< ( const Point2< T > &  aPoint) const
inlinenoexcept

The less-than operator, ordering points by x coordinate, then y coordinate.

◆ operator==()

template<class T >
bool CartoTypeCore::Point2< T >::operator== ( const Point2< T > &  aPoint) const
inlinenoexcept

The equality operator.

◆ operator>()

template<class T >
bool CartoTypeCore::Point2< T >::operator> ( const Point2< T > &  aPoint) const
inlinenoexcept

The greater-than operator, ordering points by x coordinate, then y coordinate.

◆ RightOfVector()

template<class T >
bool CartoTypeCore::Point2< T >::RightOfVector ( const Point2< T > &  aPoint) const
inlinenoexcept

Returns true if aPoint is right of this vector.

◆ RightUnitVector()

template<class T >
Point2 CartoTypeCore::Point2< T >::RightUnitVector ( ) const
inlinenoexcept

Returns a unit vector pointing 90 degrees right of this vector.

◆ Rotate()

template<class T >
void CartoTypeCore::Point2< T >::Rotate ( double  aAngle)
inline

Rotates the point about the origin by an angle given in radians.

◆ Rounded()

template<class T >
Point CartoTypeCore::Point2< T >::Rounded ( ) const
inlinenoexcept

Returns an integer point by rounding the coordinates to the nearest integer. Coordinates with a fractional part of 0.5 are rounded away from zero.

◆ Rounded64ths()

template<class T >
Point CartoTypeCore::Point2< T >::Rounded64ths ( ) const
inlinenoexcept

Returns an integer point in rounded 64ths of the values in this point.

◆ UnitVector()

template<class T >
Point2 CartoTypeCore::Point2< T >::UnitVector ( ) const
inlinenoexcept

Returns a unit vector pointing in the same direction as this point treated as a vector.

◆ VectorLength()

template<class T >
T CartoTypeCore::Point2< T >::VectorLength ( ) const
inlinenoexcept

Returns the length of the vector represented by this point: its distance from the origin (0,0).

Member Data Documentation

◆ X

template<class T >
T CartoTypeCore::Point2< T >::X { 0 }

The x coordinate.

◆ Y

template<class T >
T CartoTypeCore::Point2< T >::Y { 0 }

The y coordinate.


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