CGAL::Segment_d<Kernel>

Definition

An instance s of the data type Segment_d is a directed straight line segment in d-dimensional Euclidean space connecting two points p and q. p is called the source point and q is called the target point of s, both points are called endpoints of s. A segment whose endpoints are equal is called degenerate.

Types

Segment_d<Kernel>::R
the representation type.


Segment_d<Kernel>::RT
the ring type.


Segment_d<Kernel>::FT
the field type.


Segment_d<Kernel>::LA
the linear algebra layer.

Creation

Segment_d<Kernel> s;
introduces a variable s of type Segment_d<Kernel>.


Segment_d<Kernel> s ( Point_d<Kernel> p, Point_d<Kernel> q);
introduces a variable s of type Segment_d<Kernel> which is initialized to the segment (p,q).
Precondition: p.dimension()==q.dimension().


Segment_d<Kernel> s ( Point_d<Kernel> p, Vector_d<Kernel> v);
introduces a variable s of type Segment_d<Kernel> which is initialized to the segment (p,p+v).
Precondition: p.dimension()==v.dimension().

Operations

int s.dimension () returns the dimension of the ambient space.

Point_d<Kernel> s.source () returns the source point of segment s.

Point_d<Kernel> s.target () returns the target point of segment s.

Point_d<Kernel> s.vertex ( int i) returns source or target of s: vertex(0) returns the source, vertex(1) returns the target. The parameter i is taken modulo 2, which gives easy access to the other vertex.
Precondition: i 0.

Point_d<Kernel> s.point ( int i) returns vertex(i).

Point_d<Kernel> s [ int i] returns vertex(i).

Point_d<Kernel> s.min () returns the lexicographically smaller vertex.

Point_d<Kernel> s.max () returns the lexicographically larger vertex.

Segment_d<Kernel> s.opposite () returns the segment (target(),source()).

Direction_d<Kernel>
s.direction () returns the direction from source to target.
Precondition: s is non-degenerate.

Vector_d<Kernel> s.vector () returns the vector from source to target.

FT s.squared_length ()
returns the square of the length of s.

bool s.has_on ( Point_d<Kernel> p)
returns true if p lies on s and false otherwise.
Precondition: s.dimension()==p.dimension().

Line_d<Kernel> s.supporting_line ()
returns the supporting line of s.
Precondition: s is non-degenerate.

Segment_d<Kernel> s.transform ( Aff_transformation_d<Kernel> t)
returns t(s).
Precondition: s.dimension()==t.dimension().

Segment_d<Kernel> s + Vector_d<Kernel> v
returns s+v, i.e., s translated by vector v.
Precondition: s.dimension()==v.dimension().

bool s.is_degenerate () returns true if s is degenerate i.e. s.source()=s.target().

Non-Member Functions

bool weak_equality ( s1, s2)
Test for equality as unoriented segments.
Precondition: s1.dimension()==s2.dimension().

bool parallel ( s1, s2)
return true if one of the segments is degenerate or if the unoriented supporting lines are parallel.
Precondition: s1.dimension()==s2.dimension().

bool common_endpoint ( s1, s2, Point_d<Kernel>& common)
if s1 and s2 touch in a common end point, this point is assigned to common and the result is true, otherwise the result is false. If s1==s2 then one of the endpoints is returned.
Precondition: s1.dimension()==s2.dimension().

Implementation

Segments are implemented by a pair of points as an item type. All operations like creation, initialization, tests, the calculation of the direction and source - target vector, input and output on a segment s take time O(s.dimension()). dimension(), coordinate and end point access, and identity test take constant time. The operations for intersection calculation also take time O(s.dimension()). The space requirement is O(s.dimension()).