31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.1 Points ( point )<br />

1. Definition<br />

An instance of the data type point is a point in the two-dimensional plane R 2 . We use<br />

(x, y) to denote a point with first (or x-) coordinate x and second (or y-) coordinate y.<br />

#include < <strong>LEDA</strong>/geo/point.h ><br />

2. Types<br />

point :: coord type<br />

point :: point type<br />

the coordinate type (double).<br />

the point type (point).<br />

3. Creation<br />

point p;<br />

introduces a variable p of type point initialized to the point<br />

(0, 0).<br />

point p(double x, double y);<br />

introduces a variable p of type point initialized to the point<br />

(x, y).<br />

point p(vector v);<br />

introduces a variable p of type point initialized to the point<br />

(v[0], v[1]).<br />

Precondition: : v.dim( ) = 2.<br />

point p(const point& p, int prec);<br />

introduces a variable p of type point initialized to the point<br />

with coordinates (⌊P ∗ x⌋/P, ⌊P ∗ x⌋/P ), where p = (x, y)<br />

and P = 2 prec . If prec is non-positive, the new point has<br />

coordinates x and y.<br />

4. Operations<br />

double p.xcoord( ) returns the first coordinate of p.<br />

double p.ycoord( ) returns the second coordinate of p.<br />

vector p.to vector( ) returns the vector ⃗xy.<br />

int p.orientation(const point& q, const point& r)<br />

returns orientation(p, q, r) (see below).<br />

double p.area(const point& q, const point& r)<br />

returns area(p, q, r) (see below).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!