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

Two-dimensional line segment. More...

#include <piline.h>

Public Member Functions

 PILine ()
 Constructs empty segment.
 
 PILine (const PIPoint< Type > &p0_, const PIPoint< Type > &p1_)
 Constructs segment from two points.
 
 PILine (Type x0, Type y0, Type x1, Type y1)
 Constructs segment from endpoint coordinates.
 
PILine< Type > & set (const PIPoint< Type > &p0_, const PIPoint< Type > &p1_)
 Sets segment endpoints from two points.
 
PILine< Type > & set (Type x0, Type y0, Type x1, Type y1)
 Sets segment endpoints from coordinates.
 
bool isEmpty () const
 Returns true if segment endpoints are equal.
 
Type width () const
 Returns horizontal span between endpoints.
 
Type height () const
 Returns vertical span between endpoints.
 
PILine< Type > & translate (Type x, Type y)
 Shifts the segment by x and y.
 
PILine< Type > & translate (const PIPoint< Type > &p)
 Shifts the segment by a point offset.
 
PILine< Type > translated (Type x, Type y) const
 Returns translated copy of the segment.
 
PILine< Type > translated (const PIPoint< Type > &p) const
 Returns copy shifted by a point offset.
 
PILine< Type > & move (Type x, Type y)
 Same as translate().
 
PILine< Type > & move (const PIPoint< Type > &p)
 Same as translate().
 
PILine< Type > moved (Type x, Type y) const
 Same as translated().
 
PILine< Type > moved (const PIPoint< Type > &p) const
 Same as translated().
 
void operator+= (Type x)
 Shifts both coordinates by x.
 
void operator+= (const PIPoint< Type > &p)
 Shifts the segment by a point offset.
 
void operator-= (Type x)
 Shifts both coordinates by -x.
 
void operator-= (const PIPoint< Type > &p)
 Shifts the segment by the negated point offset.
 
PILine< Type > operator+ (const PIPoint< Type > &p)
 Returns segment shifted by a point offset.
 
PILine< Type > operator- (const PIPoint< Type > &p)
 Returns segment shifted by the negated point offset.
 
bool operator== (const PILine< Type > &r) const
 Checks whether segment endpoints are equal.
 
bool operator!= (const PILine< Type > &r) const
 Checks whether segments differ.
 

Public Attributes

PIPoint< Type > p0
 Segment start point.
 
PIPoint< Type > p1
 Segment end point.
 

Detailed Description

template<typename Type>
class PILine< Type >

Two-dimensional line segment.

Stores start and end points of a segment on a plane.