PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PIPoint< Type > Class Template Reference

Two-dimensional point. More...

#include <pipoint.h>

Public Member Functions

 PIPoint ()
 Constructs point at the origin.
 
 PIPoint (Type x_, Type y_)
 Constructs point from coordinates.
 
PIPoint< Type > & set (Type x_, Type y_)
 Sets point coordinates.
 
PIPoint< Type > & set (const PIPoint< Type > &p)
 Copies coordinates from another point.
 
PIPoint< Type > & translate (Type x_, Type y_)
 Shifts the point by x_ and y_.
 
PIPoint< Type > & translate (const PIPoint< Type > &p)
 Shifts the point by another point.
 
PIPoint< Type > translated (Type x_, Type y_) const
 Returns translated copy of the point.
 
PIPoint< Type > translated (const PIPoint< Type > &p) const
 Returns copy shifted by another point.
 
PIPoint< Type > & move (Type x_, Type y_)
 Same as translate().
 
PIPoint< Type > & move (const PIPoint< Type > &p)
 Same as translate().
 
PIPoint< Type > moved (Type x_, Type y_) const
 Same as translated().
 
PIPoint< Type > moved (const PIPoint< Type > &p) const
 Same as translated().
 
double angleRad () const
 Returns polar angle in radians.
 
double angleDeg () const
 Returns polar angle in degrees.
 
PIPoint< Type > toPolar (bool isDeg=false) const
 Returns polar form with radius in x and angle in y.
 
PIPoint< Type > & operator+= (const PIPoint< Type > &p)
 Same as translate().
 
PIPoint< Type > & operator*= (Type v)
 Multiplies both coordinates by v.
 
PIPoint< Type > & operator/= (Type v)
 Divides both coordinates by v.
 
PIPoint< Type > operator+ (const PIPoint< Type > &p)
 Returns sum of two points.
 
PIPoint< Type > operator+ (const Type &p)
 Returns point with p added to both coordinates.
 
PIPoint< Type > operator- (const PIPoint< Type > &p)
 Returns difference between two points.
 
PIPoint< Type > operator- (const Type &p)
 Returns point with p subtracted from both coordinates.
 
PIPoint< Type > operator- ()
 Returns point with inverted coordinates.
 
PIPoint< Type > operator* (Type v)
 Returns point scaled by v.
 
PIPoint< Type > operator/ (Type v)
 Returns point divided by v.
 
bool operator== (const PIPoint< Type > &p) const
 Checks whether point coordinates are equal.
 
bool operator!= (const PIPoint< Type > &p) const
 Checks whether point coordinates differ.
 

Static Public Member Functions

static PIPoint< Type > fromPolar (const PIPoint< Type > &p)
 Builds Cartesian point from polar pair with angle in x and radius in y.
 

Public Attributes

Type x
 Horizontal coordinate.
 
Type y
 Vertical coordinate.
 

Detailed Description

template<typename Type>
class PIPoint< Type >

Two-dimensional point.

Stores point coordinates and provides basic translation and conversion helpers.