CartoType C++ API 7.8.2, 2022-03-25
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Public Attributes | List of all members
CartoType::TPoint2< T > Class Template Reference

#include <cartotype_base.h>

Public Member Functions

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

Public Attributes

iX { 0 }
 
iY { 0 }
 

Detailed Description

template<class T>
class CartoType::TPoint2< 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

◆ TPoint2() [1/3]

template<class T >
constexpr CartoType::TPoint2< T >::TPoint2 ( )
inlineconstexprnoexcept

Create a point with coordinates (0,0).

◆ TPoint2() [2/3]

template<class T >
constexpr CartoType::TPoint2< T >::TPoint2 ( aX,
aY 
)
inlineconstexprnoexcept

Create a point, specifying coordinates.

◆ TPoint2() [3/3]

template<class T >
constexpr CartoType::TPoint2< T >::TPoint2 ( const TPoint aPoint)
inlineconstexprnoexcept

Create a point from a TPoint object.

Member Function Documentation

◆ CrossProduct()

template<class T >
T CartoType::TPoint2< T >::CrossProduct ( const TPoint2< 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 CartoType::TPoint2< T >::DistanceFrom ( const TPoint2< T > &  aOther) const
inlinenoexcept

Returns the distance of this point from another point.

◆ LeftOfVector()

template<class T >
bool CartoType::TPoint2< T >::LeftOfVector ( const TPoint2< T > &  aPoint) const
inlinenoexcept

Returns true if aPoint is left of this vector.

◆ LeftUnitVector()

template<class T >
TPoint2 CartoType::TPoint2< T >::LeftUnitVector ( ) const
inlinenoexcept

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

◆ operator!=()

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

The inequality operator.

◆ operator*=()

template<class T >
void CartoType::TPoint2< T >::operator*= ( aFactor)
inlinenoexcept

Scale a point by a factor.

◆ operator+=()

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

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

◆ operator-=()

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

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

◆ operator<()

template<class T >
bool CartoType::TPoint2< T >::operator< ( const TPoint2< T > &  aPoint) const
inlinenoexcept

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

◆ operator==()

template<class T >
bool CartoType::TPoint2< T >::operator== ( const TPoint2< T > &  aPoint) const
inlinenoexcept

The equality operator.

◆ operator>()

template<class T >
bool CartoType::TPoint2< T >::operator> ( const TPoint2< T > &  aPoint) const
inlinenoexcept

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

◆ RightOfVector()

template<class T >
bool CartoType::TPoint2< T >::RightOfVector ( const TPoint2< T > &  aPoint) const
inlinenoexcept

Returns true if aPoint is right of this vector.

◆ RightUnitVector()

template<class T >
TPoint2 CartoType::TPoint2< T >::RightUnitVector ( ) const
inlinenoexcept

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

◆ Rotate()

template<class T >
void CartoType::TPoint2< T >::Rotate ( double  aAngle)
inline

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

◆ Rounded()

template<class T >
TPoint CartoType::TPoint2< 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 >
TPoint CartoType::TPoint2< T >::Rounded64ths ( ) const
inlinenoexcept

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

◆ UnitVector()

template<class T >
TPoint2 CartoType::TPoint2< 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 CartoType::TPoint2< T >::VectorLength ( ) const
inlinenoexcept

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

Member Data Documentation

◆ iX

template<class T >
T CartoType::TPoint2< T >::iX { 0 }

The x coordinate.

◆ iY

template<class T >
T CartoType::TPoint2< T >::iY { 0 }

The y coordinate.


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