PIP 5.9.0
Platform-Independent Primitives
Loading...
Searching...
No Matches
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.
Type manhattanLength () const
 Returns |x| + |y|.
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 > &v)
 Multiplies by-coordinates by v.
PIPoint< Type > & operator/= (const PIPoint< Type > &v)
 Divides by-coordinates by v.
PIPoint< Type > operator+ (const PIPoint< Type > &p) const
 Returns sum of two points.
PIPoint< Type > operator+ (const Type &p) const
 Returns point with p added to both coordinates.
PIPoint< Type > operator- (const PIPoint< Type > &p) const
 Returns difference between two points.
PIPoint< Type > operator- (const Type &p) const
 Returns point with p subtracted from both coordinates.
PIPoint< Type > operator- () const
 Returns point with inverted coordinates.
PIPoint< Type > operator* (Type v) const
 Returns point scaled by v.
PIPoint< Type > operator/ (Type v) const
 Returns point divided by v.
PIPoint< Type > operator* (const PIPoint< Type > &v) const
 Returns point multiplied by v.
PIPoint< Type > operator/ (const PIPoint< Type > &v) const
 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.