mirror of https://github.com/CGAL/cgal
PCA: the test suit works fine on Windows
This commit is contained in:
parent
bb5f479966
commit
dd79ec1fdf
|
|
@ -35,74 +35,58 @@
|
|||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template < typename InputIterator,
|
||||
typename K , typename tag>
|
||||
typename Kernel,
|
||||
typename Tag>
|
||||
inline
|
||||
typename K::FT
|
||||
typename Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
typename K::Line_2& line,
|
||||
typename K::Point_2& centroid,
|
||||
const K& k,
|
||||
const tag& t)
|
||||
typename Kernel::Line_2& line,
|
||||
typename Kernel::Point_2& centroid,
|
||||
const Tag& tag,
|
||||
const Kernel& kernel)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||
return CGALi::linear_least_squares_fitting_2(first, beyond, line,
|
||||
centroid, k, (Value_type*) NULL, t);
|
||||
}
|
||||
|
||||
template < typename InputIterator,
|
||||
typename K, typename tag >
|
||||
inline
|
||||
typename K::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
typename K::Line_2& line,
|
||||
const K& k,
|
||||
const tag& t)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||
// BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
|
||||
typename K::Point_2 centroid;
|
||||
return CGALi::linear_least_squares_fitting_2(first, beyond, line,
|
||||
centroid, k,(Value_type*) NULL, t);
|
||||
centroid,(Value_type*)NULL,kernel,tag);
|
||||
}
|
||||
|
||||
// deduces the kernel from the points in container.
|
||||
template < typename InputIterator,
|
||||
typename Line,
|
||||
typename tag>
|
||||
typename Point,
|
||||
typename Tag>
|
||||
inline
|
||||
typename Kernel_traits<Line>::Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
Line& line,
|
||||
typename Kernel_traits<Line>::Kernel::Point_2& centroid,
|
||||
const tag& t)
|
||||
Point& centroid,
|
||||
const Tag& tag)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||
typedef typename Kernel_traits<Value_type>::Kernel K;
|
||||
return CGAL::linear_least_squares_fitting_2(first,beyond,line,centroid,K(), t);
|
||||
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
|
||||
return CGAL::linear_least_squares_fitting_2(first,beyond,line,centroid,tag,Kernel());
|
||||
}
|
||||
|
||||
// does not return the centroid and deduces the kernel as well.
|
||||
|
||||
template < typename InputIterator,
|
||||
typename Line,
|
||||
typename tag >
|
||||
typename Tag >
|
||||
inline
|
||||
typename Kernel_traits<Line>::Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
Line& line,
|
||||
const tag& t)
|
||||
const Tag& tag)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||
typedef typename Kernel_traits<Value_type>::Kernel K;
|
||||
return CGAL::linear_least_squares_fitting_2(first,beyond,line,K(), t);
|
||||
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
|
||||
typename Kernel::Point_2 centroid; // unused
|
||||
return CGAL::linear_least_squares_fitting_2(first,beyond,line,centroid,tag,Kernel());
|
||||
}
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
// BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
|
||||
|
||||
|
||||
#endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_2_H
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Circle_2*,// used for indirection
|
||||
const CGAL::PCA_dimension_2_tag& tag)
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_2_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::FT FT;
|
||||
|
|
@ -155,9 +155,9 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Circle_2*,// used for indirection
|
||||
const CGAL::PCA_dimension_1_tag& tag)
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_1_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::FT FT;
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Point_2*,// used for indirection
|
||||
const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag())
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_0_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::FT FT;
|
||||
|
|
@ -59,7 +59,7 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
CGAL_precondition(first != beyond);
|
||||
|
||||
// compute centroid
|
||||
c = centroid(first,beyond,K(),t);
|
||||
c = centroid(first,beyond,K(),tag);
|
||||
|
||||
// assemble covariance matrix as a semi-definite matrix.
|
||||
// Matrix numbering:
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Iso_rectangle_2*,// used for indirection
|
||||
const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag())
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_2_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::FT FT;
|
||||
|
|
@ -158,8 +158,8 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Iso_rectangle_2*,// used for indirection
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_1_tag& tag)
|
||||
{
|
||||
// types
|
||||
|
|
@ -194,8 +194,8 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Iso_rectangle_2*,// used for indirection
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_0_tag& tag)
|
||||
{
|
||||
// types
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Segment_2*,// used for indirection
|
||||
const K&, // kernel
|
||||
const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag())
|
||||
{
|
||||
// types
|
||||
|
|
@ -145,8 +145,8 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K& k, // kernel
|
||||
const typename K::Segment_2*,// used for indirection
|
||||
const K& k, // kernel
|
||||
const CGAL::PCA_dimension_0_tag& tag)
|
||||
{
|
||||
// types
|
||||
|
|
|
|||
|
|
@ -41,31 +41,31 @@ namespace CGALi {
|
|||
// 0 is worst (isotropic case, returns a line with horizontal
|
||||
// direction by default)
|
||||
|
||||
template < typename InputIterator, typename K >
|
||||
typename K::FT
|
||||
template < typename InputIterator,
|
||||
typename Kernel >
|
||||
typename Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Triangle_2*,// used for indirection
|
||||
const CGAL::PCA_dimension_2_tag& tag)
|
||||
typename Kernel::Line_2& line, // best fit line
|
||||
typename Kernel::Point_2& c, // centroid
|
||||
const typename Kernel::Triangle_2*,// used for indirection
|
||||
const Kernel&, // kernel
|
||||
const CGAL::PCA_dimension_2_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::FT FT;
|
||||
typedef typename K::Line_2 Line;
|
||||
typedef typename K::Point_2 Point;
|
||||
typedef typename K::Vector_2 Vector;
|
||||
typedef typename K::Triangle_2 Triangle;
|
||||
typedef typename Kernel::FT FT;
|
||||
typedef typename Kernel::Line_2 Line;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
typedef typename Kernel::Vector_2 Vector;
|
||||
typedef typename Kernel::Triangle_2 Triangle;
|
||||
typedef typename CGAL::Linear_algebraCd<FT> LA;
|
||||
typedef typename LA::Matrix Matrix;
|
||||
typedef typename K::Segment_2 Segment_2;
|
||||
|
||||
// precondition: at least one element in the container.
|
||||
CGAL_precondition(first != beyond);
|
||||
|
||||
// compute centroid
|
||||
c = centroid(first,beyond,K(),tag);
|
||||
c = centroid(first,beyond,Kernel(),tag);
|
||||
|
||||
// assemble covariance matrix as a semi-definite matrix.
|
||||
// Matrix numbering:
|
||||
|
|
@ -79,7 +79,7 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
FT temp[4] = {1/12.0, 1/24.0,
|
||||
1/24.0, 1/12.0};
|
||||
|
||||
Matrix moment = init_matrix<K>(2,temp);
|
||||
Matrix moment = init_matrix<Kernel>(2,temp);
|
||||
|
||||
for(InputIterator it = first;
|
||||
it != beyond;
|
||||
|
|
@ -95,7 +95,7 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
FT delta[4] = {t[1].x() - x0, t[2].x() - x0,
|
||||
t[1].y() - y0, t[2].y() - y0};
|
||||
|
||||
Matrix transformation = init_matrix<K>(2,delta);
|
||||
Matrix transformation = init_matrix<Kernel>(2,delta);
|
||||
FT area = 0.5 * std::abs(LA::determinant(transformation));
|
||||
CGAL_assertion(area!=0);
|
||||
|
||||
|
|
@ -151,19 +151,20 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
}
|
||||
} // end linear_least_squares_fitting_2 for triangle set with 2D tag
|
||||
|
||||
template < typename InputIterator, typename K >
|
||||
typename K::FT
|
||||
template < typename InputIterator,
|
||||
typename Kernel >
|
||||
typename Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Triangle_2*,// used for indirection
|
||||
typename Kernel::Line_2& line, // best fit line
|
||||
typename Kernel::Point_2& c, // centroid
|
||||
const typename Kernel::Triangle_2*,// used for indirection
|
||||
const Kernel&, // kernel
|
||||
const CGAL::PCA_dimension_1_tag& tag)
|
||||
{
|
||||
// types
|
||||
typedef typename K::Triangle_2 Triangle;
|
||||
typedef typename K::Segment_2 Segment_2;
|
||||
typedef typename Kernel::Triangle_2 Triangle;
|
||||
typedef typename Kernel::Segment_2 Segment;
|
||||
|
||||
// precondition: at least one element in the container.
|
||||
CGAL_precondition(first != beyond);
|
||||
|
|
@ -174,29 +175,30 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
it++)
|
||||
{
|
||||
const Triangle& t = *it;
|
||||
segments.push_back(Segment_2(t[0],t[1]));
|
||||
segments.push_back(Segment_2(t[1],t[2]));
|
||||
segments.push_back(Segment_2(t[2],t[0]));
|
||||
segments.push_back(Segment(t[0],t[1]));
|
||||
segments.push_back(Segment(t[1],t[2]));
|
||||
segments.push_back(Segment(t[2],t[0]));
|
||||
}
|
||||
|
||||
return linear_least_squares_fitting_2(segments.begin(),segments.end(),line,c,K(),tag);
|
||||
return linear_least_squares_fitting_2(segments.begin(),segments.end(),line,c,tag,Kernel());
|
||||
|
||||
} // end linear_least_squares_fitting_2 for triangle set with 1D tag
|
||||
|
||||
template < typename InputIterator, typename K >
|
||||
typename K::FT
|
||||
template < typename InputIterator,
|
||||
typename Kernel >
|
||||
typename Kernel::FT
|
||||
linear_least_squares_fitting_2(InputIterator first,
|
||||
InputIterator beyond,
|
||||
typename K::Line_2& line, // best fit line
|
||||
typename K::Point_2& c, // centroid
|
||||
const K&, // kernel
|
||||
const typename K::Triangle_2*,// used for indirection
|
||||
typename Kernel::Line_2& line, // best fit line
|
||||
typename Kernel::Point_2& c, // centroid
|
||||
const typename Kernel::Triangle_2*,// used for indirection
|
||||
const Kernel&, // kernel
|
||||
const CGAL::PCA_dimension_0_tag& tag)
|
||||
{
|
||||
// types
|
||||
|
||||
typedef typename K::Triangle_2 Triangle;
|
||||
typedef typename K::Point_2 Point_2;
|
||||
typedef typename Kernel::Triangle_2 Triangle;
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
|
||||
// precondition: at least one element in the container.
|
||||
CGAL_precondition(first != beyond);
|
||||
|
|
@ -207,12 +209,12 @@ linear_least_squares_fitting_2(InputIterator first,
|
|||
it++)
|
||||
{
|
||||
const Triangle& t = *it;
|
||||
points.push_back(Point_2(t[0]));
|
||||
points.push_back(Point_2(t[1]));
|
||||
points.push_back(Point_2(t[2]));
|
||||
points.push_back(Point(t[0]));
|
||||
points.push_back(Point(t[1]));
|
||||
points.push_back(Point(t[2]));
|
||||
}
|
||||
|
||||
return linear_least_squares_fitting_2(points.begin(),points.end(),line,c,K(),tag);
|
||||
return linear_least_squares_fitting_2(points.begin(),points.end(),line,c,tag,Kernel());
|
||||
|
||||
} // end linear_least_squares_fitting_2 for triangle set with 0D tag
|
||||
|
||||
|
|
|
|||
|
|
@ -7,32 +7,25 @@
|
|||
|
||||
typedef double FT;
|
||||
typedef CGAL::Cartesian<FT> K;
|
||||
typedef K::Line_2 Line_2;
|
||||
typedef K::Point_2 Point_2;
|
||||
typedef K::Circle_2 Circle_2;
|
||||
typedef K::Line_2 Line;
|
||||
typedef K::Point_2 Point;
|
||||
typedef K::Circle_2 Circle;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::list<Circle_2> circles;
|
||||
circles.push_back(Circle_2(Point_2(0.0,0.0),9));
|
||||
circles.push_back(Circle_2(Point_2(0.0,10.0),49));
|
||||
circles.push_back(Circle_2(Point_2(10.0,0.0),49));
|
||||
std::list<Circle> circles;
|
||||
circles.push_back(Circle(Point(0.0, 0.0),9.0));
|
||||
circles.push_back(Circle(Point(0.0,10.0),49.0));
|
||||
circles.push_back(Circle(Point(10.0,0.0),49.0));
|
||||
|
||||
Line_2 line;
|
||||
Point_2 c;
|
||||
K k;
|
||||
Line line;
|
||||
Point centroid;
|
||||
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,CGAL::PCA_dimension_1_tag());
|
||||
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,c,CGAL::PCA_dimension_2_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,c,CGAL::PCA_dimension_1_tag());
|
||||
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,k,CGAL::PCA_dimension_2_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,k,CGAL::PCA_dimension_1_tag());
|
||||
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,c,k,CGAL::PCA_dimension_2_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,c,k,CGAL::PCA_dimension_1_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
linear_least_squares_fitting_2(circles.begin(),circles.end(),line,centroid,CGAL::PCA_dimension_1_tag());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void test_2D()
|
|||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,k,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,CGAL::PCA_dimension_0_tag(),k);
|
||||
std::cout << "done (quality: " << quality << ")" << std::endl;
|
||||
|
||||
if(!line.is_horizontal())
|
||||
|
|
@ -71,7 +71,7 @@ void test_2D_point_set(const unsigned int nb_points)
|
|||
Kernel k;
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,k,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,CGAL::PCA_dimension_0_tag(),k);
|
||||
|
||||
std::cout << "done (quality: " << quality << ")" << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ void test_1()
|
|||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,k,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality << ") Line: " << line<<std::endl;
|
||||
|
||||
|
||||
|
|
@ -70,7 +69,6 @@ void test_2()
|
|||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,k,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality << ") Line: " << line<<" centroid: "<<centroid<<std::endl;
|
||||
|
||||
|
||||
|
|
@ -86,7 +84,6 @@ void test_2()
|
|||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,centroid1,k1,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality1 << ") Line: " << line1<<" centroid: "<<centroid1<<std::endl;
|
||||
|
||||
|
||||
|
|
@ -115,7 +112,6 @@ void test_3()
|
|||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,k,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality << ") Line: " << line<<" centroid: "<<centroid<<std::endl;
|
||||
|
||||
|
||||
|
|
@ -131,7 +127,6 @@ void test_3()
|
|||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Iso_rectangles1.begin(),Iso_rectangles1.end(),line1,centroid1,k1,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality1 << ") Line: " << line1<<" centroid: "<<centroid1<<std::endl;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,11 @@ void test_1()
|
|||
// call all versions of the function
|
||||
std::cout<<"Test 1"<<std::endl;
|
||||
std::cout << "fit 2D line...";
|
||||
Kernel k;
|
||||
Line_2 line;
|
||||
Point_2 centroid;
|
||||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,k,CGAL::PCA_dimension_1_tag());
|
||||
std::cout << "done (quality: " << quality << ")" << std::endl;
|
||||
|
||||
if(!(std::abs(-1.0*line.a()/line.b() - 1) <= THRESHOLD && std::abs(line.c()/line.b()) <= THRESHOLD && 1 - quality <= THRESHOLD))
|
||||
|
|
@ -61,13 +59,11 @@ void test_2()
|
|||
// fit a line
|
||||
// call all versions of the function
|
||||
std::cout << "fit 2D line...";
|
||||
Kernel k;
|
||||
Line_2 line;
|
||||
Point_2 centroid;
|
||||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,k,CGAL::PCA_dimension_1_tag());
|
||||
std::cout << "done (quality: " << quality << ")" << std::endl;
|
||||
|
||||
if(!(std::abs(-1.0*line.a()/line.b() - 1) <= THRESHOLD && std::abs(line.c()/line.b()) <= THRESHOLD && 1 - quality <= THRESHOLD))
|
||||
|
|
@ -92,13 +88,11 @@ void test_3()
|
|||
// fit a line
|
||||
// call all versions of the function
|
||||
std::cout << "fit 2D line...";
|
||||
Kernel k;
|
||||
Line_2 line;
|
||||
Point_2 centroid;
|
||||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,k,CGAL::PCA_dimension_1_tag());
|
||||
std::cout << "done (quality: " << quality << ")" << std::endl;
|
||||
|
||||
if(!(std::abs(-1.0*line.a()/line.b() - 1) <= THRESHOLD && std::abs(line.c()/line.b()) <= THRESHOLD && 1 - quality <= THRESHOLD))
|
||||
|
|
@ -128,7 +122,7 @@ void test_4()
|
|||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,k,CGAL::PCA_dimension_1_tag());
|
||||
quality = linear_least_squares_fitting_2(segments.begin(),segments.end(),line,centroid,CGAL::PCA_dimension_1_tag(),k);
|
||||
std::cout << "done (quality: " << quality << ")" <<" line: "<<line<< std::endl;
|
||||
|
||||
std::list<Point_2> points;
|
||||
|
|
@ -144,7 +138,6 @@ void test_4()
|
|||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(points.begin(),points.end(),line1,CGAL::PCA_dimension_0_tag());
|
||||
quality1 = linear_least_squares_fitting_2(points.begin(),points.end(),line1,centroid1,CGAL::PCA_dimension_0_tag());
|
||||
quality1 = linear_least_squares_fitting_2(points.begin(),points.end(),line1,centroid1,k1,CGAL::PCA_dimension_0_tag());
|
||||
std::cout << "done (quality: " << quality1 << ")" <<" line: "<<line1<<std::endl;
|
||||
|
||||
if(!(std::abs(-1.0*line.a()/line.b() - -1.0*line1.a()/line1.b()) <= THRESHOLD && std::abs(line.c()/line.b() - line1.c()/line1.b()) <= THRESHOLD && std::abs(quality1 - quality) <= THRESHOLD))
|
||||
|
|
@ -180,7 +173,6 @@ void test_5(const unsigned int nb_points)
|
|||
Kernel k;
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,CGAL::PCA_dimension_0_tag());
|
||||
quality = linear_least_squares_fitting_2(points.begin(),points.end(),line,centroid,k,CGAL::PCA_dimension_0_tag());
|
||||
|
||||
std::cout << "done (quality: " << quality << ")" <<" line: "<<line<< std::endl;
|
||||
|
||||
|
|
@ -197,7 +189,6 @@ void test_5(const unsigned int nb_points)
|
|||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(segments.begin(),segments.end(),line1,CGAL::PCA_dimension_1_tag());
|
||||
quality1 = linear_least_squares_fitting_2(segments.begin(),segments.end(),line1,centroid1,CGAL::PCA_dimension_1_tag());
|
||||
quality1 = linear_least_squares_fitting_2(segments.begin(),segments.end(),line1,centroid1,k1,CGAL::PCA_dimension_1_tag());
|
||||
std::cout << "done (quality: " << quality1 << ")" <<" line: "<<line1<< std::endl;
|
||||
|
||||
if(!(std::abs(-1.0*line.a()/line.b() - -1.0*line1.a()/line1.b()) <= THRESHOLD && std::abs(line.c()/line.b() - line1.c()/line1.b()) <= THRESHOLD && std::abs(quality1 - quality) <= THRESHOLD))
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ typedef Kernel::Vector_2 Vector_2;
|
|||
void test_1()
|
||||
{
|
||||
std::cout<<"Test 1"<<std::endl;
|
||||
std::list<Iso_rectangle_2> Iso_rectangles;
|
||||
Iso_rectangles.push_back(Iso_rectangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2)));
|
||||
std::list<Iso_rectangle_2> iso_rectangles;
|
||||
iso_rectangles.push_back(Iso_rectangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2)));
|
||||
|
||||
// fit a line
|
||||
// call all versions of the function
|
||||
|
|
@ -37,15 +37,14 @@ void test_1()
|
|||
Line_2 line;
|
||||
Point_2 centroid;
|
||||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,k,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(iso_rectangles.begin(),iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(iso_rectangles.begin(),iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality << ") Line: " << line<<" centroid: "<<centroid<<std::endl;
|
||||
|
||||
|
||||
std::list<Triangle_2> Triangles1;
|
||||
Triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(1.6,19.2),Point_2(11.6,19.2)));
|
||||
Triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2),Point_2(11.6,15.2)));
|
||||
std::list<Triangle_2> triangles1;
|
||||
triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(1.6,19.2),Point_2(11.6,19.2)));
|
||||
triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2),Point_2(11.6,15.2)));
|
||||
|
||||
// fit a line
|
||||
// call all versions of the function
|
||||
|
|
@ -54,9 +53,8 @@ void test_1()
|
|||
Line_2 line1;
|
||||
Point_2 centroid1;
|
||||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,centroid1,k1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(triangles1.begin(),triangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(triangles1.begin(),triangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality1 << ") Line: " << line1<<" centroid: "<<centroid1<<std::endl;
|
||||
|
||||
|
||||
|
|
@ -72,8 +70,8 @@ void test_1()
|
|||
void test_2()
|
||||
{
|
||||
std::cout<<"Test 2"<<std::endl;
|
||||
std::list<Iso_rectangle_2> Iso_rectangles;
|
||||
Iso_rectangles.push_back(Iso_rectangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2)));
|
||||
std::list<Iso_rectangle_2> iso_rectangles;
|
||||
iso_rectangles.push_back(Iso_rectangle_2(Point_2(1.6,15.2),Point_2(11.6,19.2)));
|
||||
|
||||
// fit a line
|
||||
// call all versions of the function
|
||||
|
|
@ -82,17 +80,15 @@ void test_2()
|
|||
Line_2 line;
|
||||
Point_2 centroid;
|
||||
FT quality;
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(Iso_rectangles.begin(),Iso_rectangles.end(),line,centroid,k,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(iso_rectangles.begin(),iso_rectangles.end(),line,CGAL::PCA_dimension_2_tag());
|
||||
quality = linear_least_squares_fitting_2(iso_rectangles.begin(),iso_rectangles.end(),line,centroid,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality << ") Line: " << line<<" centroid: "<<centroid<<std::endl;
|
||||
|
||||
|
||||
std::list<Triangle_2> Triangles1;
|
||||
Triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(1.6,19.2),Point_2(6.6,17.2)));
|
||||
Triangles1.push_back(Triangle_2(Point_2(11.6,19.2),Point_2(11.6,15.2),Point_2(6.6,17.2)));
|
||||
Triangles1.push_back(Triangle_2(Point_2(1.6,19.2),Point_2(11.6,19.2),Point_2(6.6,17.2)));
|
||||
Triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(11.6,15.2),Point_2(6.6,17.2)));
|
||||
std::list<Triangle_2> triangles1;
|
||||
triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(1.6,19.2),Point_2(6.6,17.2)));
|
||||
triangles1.push_back(Triangle_2(Point_2(11.6,19.2),Point_2(11.6,15.2),Point_2(6.6,17.2)));
|
||||
triangles1.push_back(Triangle_2(Point_2(1.6,19.2),Point_2(11.6,19.2),Point_2(6.6,17.2)));
|
||||
triangles1.push_back(Triangle_2(Point_2(1.6,15.2),Point_2(11.6,15.2),Point_2(6.6,17.2)));
|
||||
|
||||
// fit a line
|
||||
// call all versions of the function
|
||||
|
|
@ -101,9 +97,8 @@ void test_2()
|
|||
Line_2 line1;
|
||||
Point_2 centroid1;
|
||||
FT quality1;
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(Triangles1.begin(),Triangles1.end(),line1,centroid1,k1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(triangles1.begin(),triangles1.end(),line1,CGAL::PCA_dimension_2_tag());
|
||||
quality1 = linear_least_squares_fitting_2(triangles1.begin(),triangles1.end(),line1,centroid1,CGAL::PCA_dimension_2_tag());
|
||||
std::cout << "done (quality: " << quality1 << ") Line: " << line1<<" centroid: "<<centroid1<<std::endl;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue