CGAL 6.1.2 - dD Geometry Kernel: CGAL::Segment_d< Kernel > Class Template Reference

CGAL 6.1.2 - dD Geometry Kernel

Loading...
Searching...
No Matches
List of all members | Related Functions
CGAL::Segment_d< Kernel > Class Template Reference
Reference Manual » Kernel Objects

`#include <CGAL/Kernel_d/Segment_d.h>`

## Definition

template<typename Kernel>
class CGAL::Segment_d< Kernel >

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.
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.
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`.

## 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)\).
| 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)`.

## Operations
int | dimension ()
| returns the dimension of the ambient space.
Point_d< Kernel > | source ()
| returns the source point of segment `s`.
Point_d< Kernel > | target ()
| returns the target point of segment `s`.
Point_d< Kernel > | vertex (int i)
| returns source or target of `s`: `vertex(0)` returns the source, `vertex(1)` returns the target.
Point_d< Kernel > | point (int i)
| returns `vertex(i)`.
Point_d< Kernel > | operator[] (int i)
| returns `vertex(i)`.
Point_d< Kernel > | min ()
| returns the lexicographically smaller vertex.
Point_d< Kernel > | max ()
| returns the lexicographically larger vertex.
Segment_d< Kernel > | opposite ()
| returns the segment `(target(),source())`.
Direction_d< Kernel > | direction ()
| returns the direction from source to target.
Vector_d< Kernel > | vector ()
| 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.
Line_d< Kernel > | supporting_line ()
| returns the supporting line of `s`.
Segment_d< Kernel > | transform (const Aff_transformation_d< Kernel > &t)
| returns \( t(s)\).
Segment_d< Kernel > | operator+ (const Vector_d< Kernel > &v)
| returns \( s+v\), i.e., `s` translated by vector \( v\).
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()`.