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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.14 Rational Vectors ( rat vector )<br />

1. Definition<br />

An instance of data type rat vector is a vector of rational numbers. A d-dimensional<br />

vector r = (r 0 , . . . , r d−1 ) is represented in homogeneous coordinates (h 0 , . . . , h d ), where<br />

r i = h i /h d and the h i ’s are of type integer. We call the r i ’s the cartesian coordinates of<br />

the vector. <strong>The</strong> homogenizing coordinate h d is positive.<br />

This data type is meant for use in computational geometry. It realizes free vectors as<br />

opposed to position vectors (type rat point). <strong>The</strong> main difference between position vectors<br />

and free vectors is their behavior under affine transformations, e.g., free vectors are<br />

invariant under translations.<br />

rat vector is an item type.<br />

#include < <strong>LEDA</strong>/numbers/rat vector.h ><br />

2. Creation<br />

rat vector v(int d = 2); introduces a variable v of type rat vector initialized to<br />

the zero vector of dimension d.<br />

rat vector<br />

v(integer a, integer b, integer D);<br />

introduces a variable v of type rat vector initialized to<br />

the two-dimensional vector with homogeneous representation<br />

(a, b, D) if D is positive and representation<br />

(−a, −b, −D) if D is negative.<br />

Precondition: D is non-zero.<br />

rat vector<br />

rat vector<br />

rat vector<br />

v(rational x, rational y);<br />

introduces a variable v of type rat vector initialized to<br />

the two-dimensional vector with homogeneous representation<br />

(a, b, D), where x = a/D and y = b/D.<br />

v(integer a, integer b, integer c, integer D);<br />

v(rational x, rational y, rational z);<br />

introduces a variable v of type rat vector initialized to<br />

the three-dimensional vector with homogeneous representation<br />

(a, b, c, D) if D is positive and representation<br />

(−a, −b, −c, −D) if D is negative.<br />

Precondition: D is non-zero.<br />

introduces a variable v of type rat vector initialized to<br />

the three-dimensional vector with homogeneous representation<br />

(a, b, c, D), where x = a/D, y = b/D and<br />

z = c/D.

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

Saved successfully!

Ooh no, something went wrong!