MLIB
Loading...
Searching...
No Matches
mlib::Point< T > Class Template Reference

Generic 2D point. More...

#include <point.h>

Public Types

typedef point_traits< T > traits
 

Public Member Functions

 Point (T a, T b)
 Build a Point from a pair of T's.
 
 Point ()
 Default constructor.
 
double azimuth (const Point< T > &P2) const
 Return azimuth from North of line this-P2.
 
double angle (const Point< T > &P1, const Point< T > &P2) const
 Return inside angle P1-this-P2.
 
Point< T > operator+ (const Point< T > &p) const
 
Point< T > operator- (const Point< T > &p) const
 
Point< T > operator* (double scalar) const
 
Point< T > operator/ (double scalar) const
 
Point< T > operator- () const
 unary minus operator
 
operator* (const Point< T > &p) const
 dot product operator
 
Point< T > & operator+= (const Point< T > &other)
 
Point< T > & operator-= (const Point< T > &other)
 
Point< T > & operator*= (double scalar)
 
Point< T > & operator/= (double scalar)
 
double distance (const Point< T > &P2) const
 Return distance between this and P2.
 
double magnitude () const
 
int operator== (const Point< T > &p) const
 Return TRUE if p and this are closer than tolerance.
 
int operator!= (const Point< T > &p) const
 Return TRUE if p and this apart by more than tolerance.
 
bool leftof (const Point< T > &a, const Point< T > &b) const
 Return true if this is left of the line (a,b)
 
bool collinear (const Point< T > &a, const Point< T > &b) const
 Return true if points a, this, b are collinear.
 
void rotate (double angle)
 

Data Fields

x
 
y
 

Detailed Description

template<typename T>
class mlib::Point< T >

Generic 2D point.

Template class which builds a 2D point from a pair of coordinates.

It has functions to compute distance between two points, azimuth from north, as well as basic operators (comparison, I/O).

Member Function Documentation

◆ angle()

template<class T >
double mlib::Point< T >::angle ( const Point< T > &  P1,
const Point< T > &  P2 
) const

Return inside angle P1-this-P2.

0 <= angle < M_PI degenerated angles (p1 == this or p2 == this) are 0

◆ azimuth()

template<class T >
double mlib::Point< T >::azimuth ( const Point< T > &  P2) const

Return azimuth from North of line this-P2.

0<= azimuth < 2*M_PI


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