mirror of https://github.com/CGAL/cgal
Add examples that use the point traits
This commit is contained in:
parent
e22d0369ac
commit
a571606269
|
|
@ -4,11 +4,13 @@
|
||||||
\example Min_annulus_d/min_annulus_d.cpp
|
\example Min_annulus_d/min_annulus_d.cpp
|
||||||
\example Min_annulus_d/min_annulus_d_fast_exact.cpp
|
\example Min_annulus_d/min_annulus_d_fast_exact.cpp
|
||||||
\example Min_circle_2/min_circle_2.cpp
|
\example Min_circle_2/min_circle_2.cpp
|
||||||
|
\example Min_circle_2/min_circle_homogeneous_2.cpp
|
||||||
\example Min_ellipse_2/min_ellipse_2.cpp
|
\example Min_ellipse_2/min_ellipse_2.cpp
|
||||||
\example Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp
|
\example Min_quadrilateral_2/minimum_enclosing_parallelogram_2.cpp
|
||||||
\example Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp
|
\example Min_quadrilateral_2/minimum_enclosing_rectangle_2.cpp
|
||||||
\example Min_quadrilateral_2/minimum_enclosing_strip_2.cpp
|
\example Min_quadrilateral_2/minimum_enclosing_strip_2.cpp
|
||||||
\example Min_sphere_d/min_sphere_d.cpp
|
\example Min_sphere_d/min_sphere_d.cpp
|
||||||
|
\example Min_sphere_d/min_sphere_homogeneous_d.cpp
|
||||||
\example Min_sphere_of_spheres_d/benchmark.cpp
|
\example Min_sphere_of_spheres_d/benchmark.cpp
|
||||||
\example Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp
|
\example Min_sphere_of_spheres_d/min_sphere_of_spheres_d_2.cpp
|
||||||
\example Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp
|
\example Min_sphere_of_spheres_d/min_sphere_of_spheres_d_3.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
#include <CGAL/Simple_cartesian.h>
|
||||||
#include <CGAL/Min_circle_2.h>
|
#include <CGAL/Min_sphere_of_spheres_d.h>
|
||||||
#include <CGAL/Min_circle_2_traits_2.h>
|
#include <CGAL/Min_sphere_of_points_d_traits_2.h.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// typedefs
|
// typedefs
|
||||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
typedef CGAL::Simple_cartesian<double> K;
|
||||||
typedef CGAL::Min_circle_2_traits_2<K> Traits;
|
typedef CGAL::Min_sphere_of_points_d_traits_2<K> Traits;
|
||||||
typedef CGAL::Min_circle_2<Traits> Min_circle;
|
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_circle;
|
||||||
|
|
||||||
typedef K::Point_2 Point;
|
typedef K::Point_2 Point;
|
||||||
|
|
||||||
|
|
@ -16,15 +17,15 @@ main( int, char**)
|
||||||
const int n = 100;
|
const int n = 100;
|
||||||
Point P[n];
|
Point P[n];
|
||||||
|
|
||||||
for ( int i = 0; i < n; ++i)
|
for ( int i = 0; i < n; ++i){
|
||||||
P[ i] = Point( (i%2 == 0 ? i : -i), 0);
|
P[ i] = Point( (i%2 == 0 ? i : -i), 0, 1);
|
||||||
// (0,0), (-1,0), (2,0), (-3,0), ...
|
// (0,0), (-1,0), (2,0), (-3,0), ...
|
||||||
|
}
|
||||||
|
|
||||||
Min_circle mc1( P, P+n, false); // very slow
|
Min_circle mc( P, P+n);
|
||||||
Min_circle mc2( P, P+n, true); // fast
|
|
||||||
|
|
||||||
CGAL::set_pretty_mode( std::cout);
|
CGAL::set_pretty_mode( std::cout);
|
||||||
std::cout << mc2;
|
std::cout << mc;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include <CGAL/Exact_integer.h>
|
||||||
|
#include <CGAL/Simple_homogeneous.h>
|
||||||
|
#include <CGAL/Min_circle_2.h>
|
||||||
|
#include <CGAL/Min_circle_2_traits_2.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// typedefs
|
||||||
|
typedef CGAL::Exact_integer RT;
|
||||||
|
typedef CGAL::Simple_homogenous<RT> K;
|
||||||
|
typedef CGAL::Min_circle_2_traits_2<K> Traits;
|
||||||
|
typedef CGAL::Min_circle_2<Traits> Min_circle;
|
||||||
|
|
||||||
|
typedef K::Point_2 Point;
|
||||||
|
|
||||||
|
int
|
||||||
|
main( int, char**)
|
||||||
|
{
|
||||||
|
const int n = 100;
|
||||||
|
Point P[n];
|
||||||
|
|
||||||
|
for ( int i = 0; i < n; ++i){
|
||||||
|
P[ i] = Point( (i%2 == 0 ? i : -i), 0, 1);
|
||||||
|
// (0,0), (-1,0), (2,0), (-3,0), ...
|
||||||
|
}
|
||||||
|
|
||||||
|
Min_circle mc1( P, P+n, false); // very slow
|
||||||
|
Min_circle mc2( P, P+n, true); // fast
|
||||||
|
|
||||||
|
CGAL::set_pretty_mode( std::cout);
|
||||||
|
std::cout << mc2;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <CGAL/Random.h>
|
||||||
|
#include <CGAL/Min_sphere_of_points_d_traits_3.h>
|
||||||
|
#include <CGAL/Min_sphere_of_spheres_d.h>
|
||||||
|
|
||||||
|
typedef CGAL::Simple_cartesian<double> K;
|
||||||
|
typedef CGAL::Min_sphere_of_points_d_traits_3<K> Traits;
|
||||||
|
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_sphere;
|
||||||
|
typedef K::Point_3 Point;
|
||||||
|
|
||||||
|
const int n = 10; // number of points
|
||||||
|
const int d = 3; // dimension of points
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
Point P[n]; // n points
|
||||||
|
double coord[d]; // d coordinates
|
||||||
|
CGAL::Random r; // random number generator
|
||||||
|
|
||||||
|
for (int i=0; i<n; ++i) {
|
||||||
|
for (int j=0; j<d; ++j)
|
||||||
|
coord[j] = r.get_double();
|
||||||
|
P[i] = Point(d, coord, coord+d); // random point
|
||||||
|
}
|
||||||
|
|
||||||
|
Min_sphere ms (P, P+n); // smallest enclosing sphere
|
||||||
|
|
||||||
|
CGAL::set_pretty_mode (std::cout);
|
||||||
|
std::cout << ms; // output the sphere
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue