\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0.2 - dD Geometry Kernel
CGAL::Segment_d< Kernel > Class Template Reference

#include <CGAL/Kernel_d/Segment_d.h>

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.

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())\).

Related Functions

(Note that these are not member functions.)

bool weak_equality (const Segment_d< Kernel > &s1, const Segment_d< Kernel > &s2)
 Test for equality as unoriented segments. More...
 
bool parallel (const Segment_d< Kernel > &s1, const Segment_d< Kernel > &s2)
 return true if one of the segments is degenerate or if the unoriented supporting lines are parallel. More...
 
bool common_endpoint (const Segment_d< Kernel > &s1, const Segment_d< Kernel > &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. More...
 

Types

typedef unspecified_type LA
 the linear algebra layer.
 

Creation

 Segment_d ()
 introduces a variable s of type Segment_d<Kernel>.
 
 Segment_d (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)\). More...
 
 Segment_d (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). More...
 

Operations

int dimension ()
 returns the dimension of the ambient space.
 
Point_d< Kernelsource ()
 returns the source point of segment s.
 
Point_d< Kerneltarget ()
 returns the target point of segment s.
 
Point_d< Kernelvertex (int i)
 returns source or target of s: vertex(0) returns the source, vertex(1) returns the target. More...
 
Point_d< Kernelpoint (int i)
 returns vertex(i).
 
Point_d< Kerneloperator[] (int i)
 returns vertex(i).
 
Point_d< Kernelmin ()
 returns the lexicographically smaller vertex.
 
Point_d< Kernelmax ()
 returns the lexicographically larger vertex.
 
Segment_d< Kernelopposite ()
 returns the segment (target(),source()).
 
Direction_d< Kerneldirection ()
 returns the direction from source to target. More...
 
Vector_d< Kernelvector ()
 returns the vector from source to target.
 
FT squared_length ()
 returns the square of the length of s.
 
bool has_on (const Point_d< Kernel > &p)
 returns true if \( p\) lies on s and false otherwise. More...
 
Line_d< Kernelsupporting_line ()
 returns the supporting line of s. More...
 
Segment_d< Kerneltransform (const Aff_transformation_d< Kernel > &t)
 returns \( t(s)\). More...
 
Segment_d< Kerneloperator+ (const Vector_d< Kernel > &v)
 returns \( s+v\), i.e., s translated by vector \( v\). More...
 
bool is_degenerate ()
 returns true if s is degenerate i.e. s.source()=s.target().
 

Constructor & Destructor Documentation

◆ Segment_d() [1/2]

template<typename Kernel >
CGAL::Segment_d< Kernel >::Segment_d ( 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() [2/2]

template<typename Kernel >
CGAL::Segment_d< Kernel >::Segment_d ( 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().

Member Function Documentation

◆ direction()

template<typename Kernel >
Direction_d<Kernel> CGAL::Segment_d< Kernel >::direction ( )

returns the direction from source to target.

Precondition
s is non-degenerate.

◆ has_on()

template<typename Kernel >
bool CGAL::Segment_d< Kernel >::has_on ( const Point_d< Kernel > &  p)

returns true if \( p\) lies on s and false otherwise.

Precondition
s.dimension()==p.dimension().

◆ operator+()

template<typename Kernel >
Segment_d<Kernel> CGAL::Segment_d< Kernel >::operator+ ( const Vector_d< Kernel > &  v)

returns \( s+v\), i.e., s translated by vector \( v\).

Precondition
s.dimension()==v.dimension().

◆ supporting_line()

template<typename Kernel >
Line_d<Kernel> CGAL::Segment_d< Kernel >::supporting_line ( )

returns the supporting line of s.

Precondition
s is non-degenerate.

◆ transform()

template<typename Kernel >
Segment_d<Kernel> CGAL::Segment_d< Kernel >::transform ( const Aff_transformation_d< Kernel > &  t)

returns \( t(s)\).

Precondition
s.dimension()==t.dimension().

◆ vertex()

template<typename Kernel >
Point_d<Kernel> CGAL::Segment_d< Kernel >::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 \geq0\).

Friends And Related Function Documentation

◆ common_endpoint()

template<typename Kernel >
bool common_endpoint ( const Segment_d< Kernel > &  s1,
const Segment_d< Kernel > &  s2,
Point_d< Kernel > &  common 
)
related

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().

◆ parallel()

template<typename Kernel >
bool parallel ( const Segment_d< Kernel > &  s1,
const Segment_d< Kernel > &  s2 
)
related

return true if one of the segments is degenerate or if the unoriented supporting lines are parallel.

Precondition
s1.dimension()==s2.dimension().

◆ weak_equality()

template<typename Kernel >
bool weak_equality ( const Segment_d< Kernel > &  s1,
const Segment_d< Kernel > &  s2 
)
related

Test for equality as unoriented segments.

Precondition
s1.dimension()==s2.dimension().