CGAL 6.2 - Geometric Object Generators: CGAL::Random_points_on_segment_2< Point_2, Creator > Class Template Reference

CGAL 6.2 - Geometric Object Generators

Loading...
Searching...
No Matches
List of all members
CGAL::Random_points_on_segment_2< Point_2, Creator > Class Template Reference

`#include <CGAL/point_generators_2.h>`

## Definition

template<typename Point_2, typename Creator>
class CGAL::Random_points_on_segment_2< Point_2, Creator >

The class `Random_points_on_segment_2` is an input iterator creating points uniformly distributed on a segment.

The default `Creator` is `Creator_uniform_2<Kernel_traits<Point_2>::Kernel::RT,Point_2>`.

Is model of
  `InputIterator`
  `PointGenerator`

See also
  `CGAL::Points_on_segment_2<Point_2>`
  `CGAL::Random_points_in_disc_2<Point_2, Creator>`
  `CGAL::Random_points_in_square_2<Point_2, Creator>`
  `CGAL::Random_points_in_triangle_2<Point_2, Creator>`
  `CGAL::Random_points_on_circle_2<Point_2, Creator>`
  `CGAL::Random_points_on_square_2<Point_2, Creator>`

Examples
  Generator/random_segments1.cpp.

## Types
typedef std::input_iterator_tag | iterator_category
typedef Point_2 | value_type
typedef std::ptrdiff_t | difference_type
typedef const Point_2 * | pointer
typedef const Point_2 & | reference

## Function
| Random_points_on_segment_2 (const Point_2 &p, const Point_2 &q, Random &rnd=get_default_random())
| creates an input iterator `g` generating points of type `Point_2` uniformly distributed on the segment from \( p\) to \( q\) (excluding \( q\)), i.e. \( *g == (1-\lambda)\, p + \lambda q\) where \( 0 \le\lambda< 1\).

## Constructor & Destructor Documentation

## ◆ Random_points_on_segment_2()

template<typename Point_2 , typename Creator >

CGAL::Random_points_on_segment_2< Point_2, Creator >::Random_points_on_segment_2 | ( | const Point_2 & | p,
|  | const Point_2 & | q,
|  | Random & | rnd = `get_default_random()`
| ) |  |

creates an input iterator `g` generating points of type `Point_2` uniformly distributed on the segment from \( p\) to \( q\) (excluding \( q\)), i.e. \( *g == (1-\lambda)\, p + \lambda q\) where \( 0 \le\lambda< 1\).

A single random number is needed from `rnd` for each point. The expressions `to_double(p.x())` and `to_double(p.y())` must result in the respective `double` representation of the coordinates of \( p\), and similarly for \( q\).