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.

int cmp signed dist(const rat point& a, const rat point& b, const rat point& c,<br />

const rat point& d)<br />

compares (signed) distances of c and d to the straight line<br />

passing through a and b (directed from a to b). Returns<br />

+1 (−1) if c has larger (smaller) distance than d and 0 if<br />

distances are equal.<br />

int orientation(const rat point& a, const rat point& b, const rat point& c)<br />

computes the orientation of points a, b, c as the sign of<br />

the determinant<br />

∣<br />

∣<br />

a x a y a ∣∣∣∣∣∣ w<br />

b x b y b w<br />

c x c y c w<br />

i.e., it returns +1 if point c lies left of the directed line<br />

through a and b, 0 if a,b, and c are collinear, and −1 otherwise.<br />

int cmp distances(const rat point& p1 , const rat point& p2 ,<br />

const rat point& p3 , const rat point& p4 )<br />

compares the distances (p1 , p2 ) and (p3 , p4 ). Returns +1<br />

(−1) if distance (p1 , p2 ) is larger (smaller) than distance<br />

(p3 , p4 ), otherwise 0.<br />

rat point midpoint(const rat point& a, const rat point& b)<br />

returns the midpoint of a and b.<br />

rational area(const rat point& a, const rat point& b, const rat point& c)<br />

computes the signed area of the triangle determined by<br />

a,b,c, positive if orientation(a, b, c) > 0 and negative otherwise.<br />

bool collinear(const rat point& a, const rat point& b, const rat point& c)<br />

returns true if points a, b, c are collinear, i.e.,<br />

orientation(a, b, c) = 0, and false otherwise.<br />

bool right turn(const rat point& a, const rat point& b, const rat point& c)<br />

returns true if points a, b, c form a righ turn, i.e.,<br />

orientation(a, b, c) < 0, and false otherwise.<br />

bool left turn(const rat point& a, const rat point& b, const rat point& c)<br />

returns true if points a, b, c form a left turn, i.e.,<br />

orientation(a, b, c) > 0, and false otherwise.

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

Saved successfully!

Ooh no, something went wrong!