Navigation: Up, Table of Contents, Bibliography, Index, Title Page

2D Direction (CGAL_Direction_2)

Definition

An object of the class CGAL_Direction_2 is a vector in the two-dimensional vector space R2 where we forget about its length. They can be viewed as unit vectors, although there is no normalization internally, since this is error prone. Directions are used whenever the length of a vector does not matter. They also characterize a set of parallel oriented lines that have the same orientations. For example, you can ask for the direction orthogonal to an oriented plane, or the direction of an oriented line. Further, they can be used to indicate angles. The slope of a direction is dy()/dx().

#include <CGAL/Direction_2.h>

Creation

CGAL_Direction_2<R> d ( CGAL_Vector_2<R> v);
introduces the direction d of vector v.

CGAL_Direction_2<R> d ( R::RT x, R::RT y);
introduces a direction d passing through the point at (x, y).

Operations

R::RT d.delta ( int i) returns the i'th value of the slope of d.
Precondition: : 0 <=i <=1.
R::RT d.dx () returns the dx value of the slope of d.
R::RT d.dy () returns the dy value of the slope of d.

There is a total order on directions. We compare the angles between the positive x-axis and the directions in counterclockwise order.

bool d == e Test for equality.
bool d != e Test for inequality.
bool d < e
bool d > e
bool d <= e
bool d >= e
bool d.counterclockwise_in_between ( d1, d2)
CGAL_Direction_2<R>
- d The direction opposite to d.

Miscellaneous

CGAL_Vector_2<R> d.vector () returns a vector that has the same direction as d.
CGAL_Direction_2<R>
d.transform ( CGAL_Aff_transformation_2<R> t)
returns the direction obtained by applying t on d.


Return to chapter: 2D Point, Vector and Direction
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. Wed, January 20, 1999.