Source: http://www.algorithmic-solutions.info/leda_manual/rat_vector.html
Timestamp: 2019-04-19 18:13:25+00:00

Document:
An instance of data type rat_vector is a vector of rational numbers. A d -dimensional vector r = (r0,..., rd-1) is represented in homogeneous coordinates (h0,..., hd) , where ri = hi/hd and the hi 's are of type integer. We call the ri 's the cartesian coordinates of the vector. The homogenizing coordinate hd is positive.
This data type is meant for use in computational geometry. It realizes free vectors as opposed to position vectors (type rat_point). The main difference between position vectors and free vectors is their behavior under affine transformations, e.g., free vectors are invariant under translations.
rat_vector is an item type.
rat_vector v(int d=2) introduces a variable v of type rat_vector initialized to the zero vector of dimension d .
introduces a variable v of type rat_vector initialized to the two-dimensional vector with homogeneous representation (a, b, D) if D is positive and representation (- a, - b, - D) if D is negative.
rat_vector v(rational x, rational y) introduces a variable v of type rat_vector initialized to the two-dimensional vector with homogeneous representation (a, b, D) , where x = a/D and y = b/D .
introduces a variable v of type rat_vector initialized to the three-dimensional vector with homogeneous representation (a, b, c, D) if D is positive and representation (- a, - b, - c, - D) if D is negative.
introduces a variable v of type rat_vector initialized to the three-dimensional vector with homogeneous representation (a, b, c, D) , where x = a/D , y = b/D and z = c/D .
introduces a variable v of type rat_vector initialized to the d-dimensional vector with homogeneous coordinates ( c0,..., cd-1, D) , where d = A.size() and A[i] = ci/D , for i = 0,..., d - 1 .
rat_vector v(integer a, integer b) introduces a variable v of type rat_vector initialized to the two-dimensional vector with homogeneous representation (a, b, 1) .
introduces a variable v of type rat_vector initialized to the vector with homogeneous coordinates ( c0,..., cd-1, D) , where d is the dimension of c and the sign chosen is the sign of D .
introduces a variable v of type rat_vector initialized to the direction with homogeneous coordinate vector c , where the sign chosen is the sign of the last component of c .
Precondition The last component of c is non-zero.
introduces a variable v of type rat_vector initialized to ( P*w0 ,..., P*wd-1 , P) , where d is the dimension of w and P = 2prec .
returns a rat_vector of dimension 2 initialized to a vector with homogeneous representation (a, b, D) if D is positive and representation (- a, - b, - D) if D is negative.
returns a rat_vector of dimension 3 initialized to a vector with homogeneous representation (a, b, c, D) if D is positive and representation (- a, - b, - c, - D) if D is negative.
returns a rat_vector of dimension d initialized to the i -th unit vector.
Precondition 0 < = i < d .
rat_vector rat_vector::zero(int d=2) returns the zero vector in d-dimensional space.
integer v.hcoord(int i) returns the i -th homogeneous coordinate of v.
rational v.coord(int i) returns the i -th cartesian coordinate of v.
rational v[int i] returns the i -th cartesian coordinate of v.
rational v.sqr_length() returns the square of the length of v.
rational v.xcoord() returns the zero-th cartesian coordinate of v.
rational v.ycoord() returns the first cartesian coordinate of v.
rational v.zcoord() returns the second cartesian coordinate of v.
integer v.X() returns the zero-th homogeneous coordinate of v.
integer v.Y() returns the first homogeneous coordinate of v.
integer v.Z() returns the second homogeneous coordinate of v.
integer v.W() returns the homogenizing coordinate of v.
rat_vector v.rotate90(int i=1) returns v by an angle of i x 90 degrees. If i > 0 the rotation is counter-clockwise otherwise it is clockwise. Precondition v.dim() == 2.
bool v == const rat_vector& w Test for equality.
bool v != const rat_vector& w Test for inequality.
multiplies all cartesian coordinates by n.
multiplies all cartesian coordinates by r.
rat_vector& v *= integer n multiplies all cartesian coordinates by n.
rat_vector& v *= rational r multiplies all cartesian coordinates by r.
divides all cartesian coordinates by n .
divides all cartesian coordinates by r .
rat_vector& v /= integer n divides all cartesian coordinates by n.
rat_vector& v /= rational r divides all cartesian coordinates by r.
scalar product, i.e., viwi , where vi and wi are the cartesian coordinates of v and w respectively.
rat_vector& v += const rat_vector& w addition plus assignment.
rat_vector& v -= const rat_vector& w subtraction plus assignment.
writes v 's homogeneous coordinates componentwise to the output stream O .
reads v 's homogeneous coordinates componentwise from the input stream I . The operator uses the current dimension of v.
determines whether x is contained in the linear hull of the vectors in A .
computes the linear rank of the vectors in A .
decides whether the vectors in A are linearly independent.
computes a basis of the linear space spanned by the vectors in A .
Vectors are implemented by arrays of integers as an item type. All operations like creation, initialization, tests, vector arithmetic, input and output on an vector v take time O(v.dim()) . dim(), coordinate access and conversions take constant time. The operations for linear hull, rank and independence have the cubic costs of the used matrix operations. The space requirement is O(v.dim()) .

References: v.

 v.

 v.

 v.

 v.

 v.

 v.

 v.

 v.

 v.

 v.

 v.