re-updated manual changes

This commit is contained in:
Oren Salzman 2011-05-30 08:45:28 +00:00
parent a0a6a11438
commit 3b255863af
5 changed files with 42 additions and 2160 deletions

View File

@ -4,12 +4,13 @@
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/Algebraic_kernel_d_1.h> #include <CGAL/Arithmetic_kernel.h> //NT
#include <CGAL/Arr_rational_function_traits_2.h> #include <CGAL/Algebraic_kernel_d_1.h> //Algebraic Kernel
#include <CGAL/Arrangement_2.h> #include <CGAL/Arr_rational_function_traits_2.h> //Traits
#include <CGAL/Arrangement_2.h> //Arrangement
typedef CGAL::Gmpz Integer; typedef CGAL::CORE_arithmetic_kernel::Integer Number_type;
typedef CGAL::Algebraic_kernel_d_1<Integer> AK1; typedef CGAL::Algebraic_kernel_d_1<Number_type> AK1;
typedef CGAL::Arr_rational_function_traits_2<AK1> Traits_2; typedef CGAL::Arr_rational_function_traits_2<AK1> Traits_2;
typedef AK1::Polynomial_1 Polynomial_1; typedef AK1::Polynomial_1 Polynomial_1;
@ -33,24 +34,24 @@ int main ()
// Create an arc supported by the polynomial y = x^4 - 6x^2 + 8, // Create an arc supported by the polynomial y = x^4 - 6x^2 + 8,
// defined over the interval [-2, 2]: // defined over the interval [-2, 2]:
Polynomial_1 P1 = x*x*x*x - 6*x*x + 8; Polynomial_1 P1 = x*x*x*x - 6*x*x + 8;
arcs.push_back(construct_arc(P1, Alg_real_1(-2), Alg_real_1(2))); arcs.push_back(construct_arc(P1.begin(), P1.end(), Alg_real_1(-2), Alg_real_1(2)));
// Create an arc supported by the function y = x / (1 + x^2), // Create an arc supported by the function y = x / (1 + x^2),
// defined over the interval [-3, 3]: // defined over the interval [-3, 3]:
Polynomial_1 P2 = x; Polynomial_1 P2 = x;
Polynomial_1 Q2 = 1+x*x; Polynomial_1 Q2 = 1+x*x;
arcs.push_back(construct_arc(P2, Q2, Alg_real_1(-3), Alg_real_1(3))); arcs.push_back(construct_arc(P2.begin(), P2.end(), Q2.begin(), Q2.end(), Alg_real_1(-3), Alg_real_1(3)));
// Create an arc supported by the parbola y = 8 - x^2, // Create an arc supported by the parbola y = 8 - x^2,
// defined over the interval [-2, 3]: // defined over the interval [-2, 3]:
Polynomial_1 P3 = 8 - x*x; Polynomial_1 P3 = 8 - x*x;
arcs.push_back(construct_arc(P3, Alg_real_1(-2), Alg_real_1(3))); arcs.push_back(construct_arc(P3.begin(), P3.end(), Alg_real_1(-2), Alg_real_1(3)));
// Create an arc supported by the line y = -2x, // Create an arc supported by the line y = -2x,
// defined over the interval [-3, 0]: // defined over the interval [-3, 0]:
Polynomial_1 P4 = -2*x; Polynomial_1 P4 = -2*x;
arcs.push_back(construct_arc(P4, Alg_real_1(-3), Alg_real_1(0))); arcs.push_back(construct_arc(P4.begin(), P4.end(), Alg_real_1(-3), Alg_real_1(0)));
// Construct the arrangement of the four arcs. // Construct the arrangement of the four arcs.
Arrangement_2 arr; Arrangement_2 arr;

View File

@ -1,15 +1,17 @@
#include "stdafx.h"
//! \file examples/Arrangement_2/unbounded_rational_functions.cpp //! \file examples/Arrangement_2/unbounded_rational_functions.cpp
// Constructing an arrangement of unbounded portions of rational functions. // Constructing an arrangement of unbounded portions of rational functions.
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/Algebraic_kernel_d_1.h> #include <CGAL/Arithmetic_kernel.h> //NT
#include <CGAL/Arr_rational_function_traits_2.h> #include <CGAL/Algebraic_kernel_d_1.h> //Algebraic Kernel
#include <CGAL/Arrangement_2.h> #include <CGAL/Arr_rational_function_traits_2.h> //Traits
#include <CGAL/Arrangement_2.h> //Arrangement
typedef CGAL::Gmpz Integer; typedef CGAL::CORE_arithmetic_kernel::Integer Number_type;
typedef CGAL::Algebraic_kernel_d_1<Integer> AK1; typedef CGAL::Algebraic_kernel_d_1<Number_type> AK1;
typedef CGAL::Arr_rational_function_traits_2<AK1> Traits_2; typedef CGAL::Arr_rational_function_traits_2<AK1> Traits_2;
typedef AK1::Polynomial_1 Polynomial_1; typedef AK1::Polynomial_1 Polynomial_1;
typedef AK1::Algebraic_real_1 Alg_real_1; typedef AK1::Algebraic_real_1 Alg_real_1;
@ -22,7 +24,7 @@ int main ()
AK1 ak1; AK1 ak1;
// Traits class object // Traits class object
Traits_2 traits(ak1); Traits_2 traits;
// constructor for rational functions // constructor for rational functions
Traits_2::Construct_curve_2 construct Traits_2::Construct_curve_2 construct
@ -37,24 +39,27 @@ int main ()
// Create the rational functions (y = 1 / x), and (y = -1 / x). // Create the rational functions (y = 1 / x), and (y = -1 / x).
Polynomial_1 P1(1); Polynomial_1 P1(1);
Polynomial_1 minusP1(-P1);
Polynomial_1 Q1 = x; Polynomial_1 Q1 = x;
arcs.push_back(construct( P1, Q1)); arcs.push_back(construct( P1.begin(), P1.end(), Q1.begin(),Q1.end()));
arcs.push_back(construct(-P1, Q1)); arcs.push_back(construct(minusP1.begin(),minusP1.end(), Q1.begin(),Q1.end()));
// Create a bounded segments of the parabolas (y = -4*x^2 + 3) and // Create a bounded segments of the parabolas (y = -4*x^2 + 3) and
// (y = 4*x^2 - 3), defined over [-sqrt(3)/2, sqrt(3)/2]. // (y = 4*x^2 - 3), defined over [-sqrt(3)/2, sqrt(3)/2].
Polynomial_1 P2 = -4*x*x+3; Polynomial_1 P2 = -4*x*x+3;
std::vector<Alg_real_1> roots; Polynomial_1 minusP2 = -P2;
std::vector<std::pair<Alg_real_1,int> > roots;
ak1.solve_1_object()(P2,std::back_inserter(roots));// [-sqrt(3)/2, sqrt(3)/2] ak1.solve_1_object()(P2,std::back_inserter(roots));// [-sqrt(3)/2, sqrt(3)/2]
arcs.push_back(construct( P2, roots[0], roots[1])); arcs.push_back(construct(P2.begin(), P2.end(), roots[0].first, roots[1].first));
arcs.push_back(construct(-P2, roots[0], roots[1])); arcs.push_back(construct(minusP2.begin(),minusP2.end(), roots[0].first, roots[1].first));
// Create the rational function (y = 1 / 2*x) for x > 0, and the // Create the rational function (y = 1 / 2*x) for x > 0, and the
// rational function (y = -1 / 2*x) for x < 0. // rational function (y = -1 / 2*x) for x < 0.
Polynomial_1 P3(1); Polynomial_1 P3(1);
Polynomial_1 minusP3(-P3);
Polynomial_1 Q3 = 2*x; Polynomial_1 Q3 = 2*x;
arcs.push_back(construct( P3, Q3, Algebraic(0), true )); arcs.push_back(construct( P3.begin(), P3.end(), Q3.begin(), Q3.end(), Alg_real_1(0), true ));
arcs.push_back(construct(-P3, Q3, Algebraic(0), false)); arcs.push_back(construct(minusP3.begin(),minusP3.end(), Q3.begin(), Q3.end(), Alg_real_1(0), false));
// Construct the arrangement of the six arcs. // Construct the arrangement of the six arcs.
Arrangement_2 arr; Arrangement_2 arr;
@ -72,5 +77,3 @@ int main ()
return 0; return 0;
} }
#endif

View File

@ -45,22 +45,20 @@ namespace CGAL {
* rational and algebraic types. * rational and algebraic types.
*/ */
template < class Kernel_, template < class Algebraic_kernel_ >
class Algebraic_kernel_ = Algebraic_kernel_d_1 <typename Fraction_traits <typename Kernel_::FT>::Numerator_type> > class Arr_rational_function_traits_2
class Arr_rational_arc_traits_d_1
{ {
public: public:
typedef Kernel_ Kernel;
typedef Algebraic_kernel_ Algebraic_kernel; typedef Algebraic_kernel_ Algebraic_kernel;
typedef Arr_rational_arc_traits_d_1<Kernel, Algebraic_kernel> Self; typedef Arr_rational_function_traits_2<Algebraic_kernel> Self;
typedef Arr_rational_arc::Base_rational_arc_ds_1<Kernel, Algebraic_kernel> Base_rational_arc_ds_1; typedef Arr_rational_arc::Base_rational_arc_ds_1<Algebraic_kernel> Base_rational_arc_ds_1;
// Traits objects: // Traits objects:
typedef Arr_rational_arc::Base_rational_arc_d_1<Kernel, Algebraic_kernel> Base_curve_2; typedef Arr_rational_arc::Base_rational_arc_d_1<Algebraic_kernel> Base_curve_2;
typedef Arr_rational_arc::Continuous_rational_arc_d_1<Kernel, Algebraic_kernel> X_monotone_curve_2; typedef Arr_rational_arc::Continuous_rational_arc_d_1<Algebraic_kernel> X_monotone_curve_2;
typedef Arr_rational_arc::Rational_arc_d_1<Kernel, Algebraic_kernel> Curve_2; typedef Arr_rational_arc::Rational_arc_d_1<Algebraic_kernel> Curve_2;
typedef Arr_rational_arc::Algebraic_point_2<Kernel, Algebraic_kernel> Point_2; typedef Arr_rational_arc::Algebraic_point_2<Algebraic_kernel> Point_2;
typedef typename Base_rational_arc_ds_1::Algebraic_real_1 Algebraic_real_1; typedef typename Base_rational_arc_ds_1::Algebraic_real_1 Algebraic_real_1;
typedef typename Base_rational_arc_ds_1::Multiplicity Multiplicity; typedef typename Base_rational_arc_ds_1::Multiplicity Multiplicity;
@ -77,10 +75,10 @@ public:
typedef typename Algebraic_kernel::Bound Bound; typedef typename Algebraic_kernel::Bound Bound;
typedef Bound Approximate_number_type; typedef Bound Approximate_number_type;
typedef CGAL::Arr_rational_arc::Rational_function<Kernel_,Algebraic_kernel_> Rational_function; typedef CGAL::Arr_rational_arc::Rational_function<Algebraic_kernel_> Rational_function;
typedef CGAL::Arr_rational_arc::Cache<Kernel_,Algebraic_kernel_> Cache; typedef CGAL::Arr_rational_arc::Cache<Algebraic_kernel_> Cache;
typedef typename Arr_rational_arc::Vertical_segment_d_1 <Kernel,Algebraic_kernel> Vertical_segment; typedef typename Arr_rational_arc::Vertical_segment_d_1 <Algebraic_kernel> Vertical_segment;
//Category tags: //Category tags:
typedef Tag_true Has_left_category; typedef Tag_true Has_left_category;
@ -103,7 +101,7 @@ public:
//--------------------- //---------------------
// Default constructor. // Default constructor.
Arr_rational_arc_traits_d_1 () Arr_rational_function_traits_2 ()
{} {}
class Construct_x_monotone_curve_2 class Construct_x_monotone_curve_2
@ -1053,7 +1051,7 @@ public:
{ {
_cache.clear(); _cache.clear();
} }
}; }; //Arr_rational_function_traits_2
} //namespace CGAL { } //namespace CGAL {