PCA: massaging of the templates in order to provide default tag - does not compile yet.

This commit is contained in:
Pierre Alliez 2007-11-07 13:07:02 +00:00
parent 76084f2ec9
commit d1925200a0
12 changed files with 117 additions and 61 deletions

View File

@ -42,6 +42,30 @@ struct PCA_dimension_1_tag {};
// For the vertices of objects. // For the vertices of objects.
struct PCA_dimension_0_tag {}; struct PCA_dimension_0_tag {};
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Struct to denote dimension compile time decisions
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
template <class Value_type /* type of fitted objects */,
class K>
struct PCA_default_dimension{};
template < typename K >
struct PCA_default_dimension<typename K::Point_3> {
typedef CGAL::PCA_dimension_0_tag Tag;
};
template < typename K >
struct PCA_default_dimension<typename K::Segment_3> {
typedef CGAL::PCA_dimension_1_tag Tag;
};
template < typename K >
struct PCA_default_dimension<typename K::Triangle_3> {
typedef CGAL::PCA_dimension_2_tag Tag;
};
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_TAGS_H #endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_TAGS_H

View File

@ -43,10 +43,9 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Line_2& line, typename K::Line_2& line,
typename K::Point_2& centroid, typename K::Point_2& centroid,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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));
return CGALi::linear_least_squares_fitting_2(first, beyond, line, return CGALi::linear_least_squares_fitting_2(first, beyond, line,
centroid, k, (Value_type*) NULL, t); centroid, k, (Value_type*) NULL, t);
} }
@ -59,7 +58,7 @@ linear_least_squares_fitting_2(InputIterator first,
InputIterator beyond, InputIterator beyond,
typename K::Line_2& line, typename K::Line_2& line,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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)); // BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
@ -71,37 +70,39 @@ linear_least_squares_fitting_2(InputIterator first,
// deduces the kernel from the points in container. // deduces the kernel from the points in container.
template < typename InputIterator, template < typename InputIterator,
typename Line, typename Line,
typename tag> typename tag>
inline inline
typename Kernel_traits<Line>::Kernel::FT typename Kernel_traits<Line>::Kernel::FT
linear_least_squares_fitting_2(InputIterator first, linear_least_squares_fitting_2(InputIterator first,
InputIterator beyond, InputIterator beyond,
Line& line, Line& line,
typename Kernel_traits<Line>::Kernel::Point_2& centroid, typename Kernel_traits<Line>::Kernel::Point_2& centroid,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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));
typedef typename Kernel_traits<Value_type>::Kernel K; typedef typename Kernel_traits<Value_type>::Kernel K;
return CGAL::linear_least_squares_fitting_2(first,beyond,line,centroid,K(), t); return CGAL::linear_least_squares_fitting_2(first,beyond,line,centroid,K(), t);
} }
// does not return the centroid and deduces the kernel as well. // does not return the centroid and deduces the kernel as well.
template < typename InputIterator, template < typename InputIterator,
typename Line, typename tag > typename Line,
typename tag >
inline inline
typename Kernel_traits<Line>::Kernel::FT typename Kernel_traits<Line>::Kernel::FT
linear_least_squares_fitting_2(InputIterator first, linear_least_squares_fitting_2(InputIterator first,
InputIterator beyond, InputIterator beyond,
Line& line, Line& line,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
typedef typename Kernel_traits<Value_type>::Kernel K; typedef typename Kernel_traits<Value_type>::Kernel K;
// BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
return CGAL::linear_least_squares_fitting_2(first,beyond,line,K(), t); return CGAL::linear_least_squares_fitting_2(first,beyond,line,K(), t);
} }
CGAL_END_NAMESPACE 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 #endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_2_H

View File

@ -46,10 +46,9 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Plane_3& plane, typename K::Plane_3& plane,
typename K::Point_3& centroid, typename K::Point_3& centroid,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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));
return CGALi::linear_least_squares_fitting_3(first, beyond, plane, return CGALi::linear_least_squares_fitting_3(first, beyond, plane,
centroid, k, (Value_type*) NULL, t); centroid, k, (Value_type*) NULL, t);
} }
@ -63,7 +62,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Line_3& line, typename K::Line_3& line,
typename K::Point_3& centroid, typename K::Point_3& centroid,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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)); // BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
@ -79,7 +78,7 @@ linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond, InputIterator beyond,
typename K::Plane_3& plane, typename K::Plane_3& plane,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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)); // BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
@ -96,16 +95,15 @@ linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond, InputIterator beyond,
typename K::Line_3& line, typename K::Line_3& line,
const K& k, const K& k,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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_3 centroid; typename K::Point_3 centroid;
return CGALi::linear_least_squares_fitting_3(first, beyond, line, return CGALi::linear_least_squares_fitting_3(first, beyond, line,
centroid, k,(Value_type*) NULL, t); centroid, k,(Value_type*) NULL, t);
} }
// deduces the kernel from the points in container. // deduces kernel
template < typename InputIterator, template < typename InputIterator,
typename Object, typename Object,
typename tag> typename tag>
@ -115,14 +113,14 @@ linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond, InputIterator beyond,
Object& object, Object& object,
typename Kernel_traits<Object>::Kernel::Point_3& centroid, typename Kernel_traits<Object>::Kernel::Point_3& centroid,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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));
typedef typename Kernel_traits<Value_type>::Kernel K; typedef typename Kernel_traits<Value_type>::Kernel K;
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,K(), t); return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,K(), t);
} }
/*
// does not return the centroid and deduces the kernel as well. // does not return the centroid and deduces the kernel as well.
template < typename InputIterator, template < typename InputIterator,
typename Object, typename tag > typename Object, typename tag >
@ -131,7 +129,7 @@ typename Kernel_traits<Object>::Kernel::FT
linear_least_squares_fitting_3(InputIterator first, linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond, InputIterator beyond,
Object& object, Object& object,
const tag& t) const tag& t)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type Value_type; 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)); // BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
@ -139,6 +137,40 @@ linear_least_squares_fitting_3(InputIterator first,
return CGAL::linear_least_squares_fitting_3(first,beyond,object,K(), t); return CGAL::linear_least_squares_fitting_3(first,beyond,object,K(), t);
} }
// default tag
template < typename InputIterator,
typename Object >
inline
typename Kernel_traits<Object>::Kernel::FT
linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond,
Object& object)
{
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
typedef typename Kernel_traits<Value_type>::Kernel K;
return CGAL::linear_least_squares_fitting_3(first,beyond,object,K());
}
*/
// does not return the centroid and deduces the kernel as well.
template < typename InputIterator,
typename Object,
typename tag = typename PCA_default_dimension< typename std::iterator_traits<InputIterator>::value_type >::Tag>
inline
typename Kernel_traits<Object>::Kernel::FT
linear_least_squares_fitting_3(InputIterator first,
InputIterator beyond,
Object& object,
const tag& t = 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_3(first,beyond,object,K(), t);
}
// BOOST_STATIC_ASSERT((boost::is_same<typename CGAL::Algebraic_structure_traits<Value_type>::Algebraic_category,CGAL::Field_with_sqrt_tag>::value));
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_3_H #endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_3_H

View File

@ -41,7 +41,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -72,7 +72,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -103,7 +103,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -147,7 +147,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -183,7 +183,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -213,7 +213,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -244,7 +244,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;
@ -288,7 +288,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Iso_cuboid_3*, // used for indirection const typename K::Iso_cuboid_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Iso_cuboid_3 Iso_cuboid; typedef typename K::Iso_cuboid_3 Iso_cuboid;

View File

@ -45,7 +45,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K&, // kernel const K&, // kernel
const typename K::Point_2*,// used for indirection const typename K::Point_2*,// used for indirection
const CGAL::PCA_dimension_0_tag& t) const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag())
{ {
// types // types
typedef typename K::FT FT; typedef typename K::FT FT;

View File

@ -43,7 +43,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Point_3*, // used for indirection const typename K::Point_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Point_3 Point; typedef typename K::Point_3 Point;
@ -77,7 +77,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Point_3*, // used for indirection const typename K::Point_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Point_3 Point; typedef typename K::Point_3 Point;

View File

@ -48,7 +48,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K&, // kernel const K&, // kernel
const typename K::Iso_rectangle_2*,// used for indirection const typename K::Iso_rectangle_2*,// used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag())
{ {
// types // types
typedef typename K::FT FT; typedef typename K::FT FT;
@ -124,20 +124,17 @@ linear_least_squares_fitting_2(InputIterator first,
covariance[1] += mass * (-1.0 * c.x() * c.y()); covariance[1] += mass * (-1.0 * c.x() * c.y());
covariance[2] += mass * (-1.0 * c.y() * c.y()); covariance[2] += mass * (-1.0 * c.y() * c.y());
// to remove later
// std::cout<<covariance[0]<<" "<<covariance[1]<<" "<<covariance[2]<<std::endl;
// solve for eigenvalues and eigenvectors. // solve for eigenvalues and eigenvectors.
// eigen values are sorted in descending order, // eigen values are sorted in descending order,
// eigen vectors are sorted in accordance. // eigen vectors are sorted in accordance.
std::pair<FT,FT> eigen_values; std::pair<FT,FT> eigen_values;
std::pair<Vector,Vector> eigen_vectors; std::pair<Vector,Vector> eigen_vectors;
// CGALi::eigen_symmetric_2<K>(final_cov, eigen_vectors, eigen_values);
FT eigen_vectors1[4]; FT eigen_vectors1[4];
FT eigen_values1[2]; FT eigen_values1[2];
eigen_symmetric<FT>(covariance,2, eigen_vectors1, eigen_values1); eigen_symmetric<FT>(covariance,2, eigen_vectors1, eigen_values1);
eigen_values = std::make_pair(eigen_values1[0],eigen_values1[1]); eigen_values = std::make_pair(eigen_values1[0],eigen_values1[1]);
eigen_vectors = std::make_pair(Vector(eigen_vectors1[0],eigen_vectors1[1]),Vector(eigen_vectors1[2],eigen_vectors1[3])); eigen_vectors = std::make_pair(Vector(eigen_vectors1[0],eigen_vectors1[1]),Vector(eigen_vectors1[2],eigen_vectors1[3]));
// check unicity and build fitting line accordingly // check unicity and build fitting line accordingly
if(eigen_values.first != eigen_values.second) if(eigen_values.first != eigen_values.second)
{ {
@ -163,7 +160,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K&, // kernel const K&, // kernel
const typename K::Iso_rectangle_2*,// used for indirection const typename K::Iso_rectangle_2*,// used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag)
{ {
// types // types
typedef typename K::Iso_rectangle_2 Iso_rectangle; typedef typename K::Iso_rectangle_2 Iso_rectangle;
@ -189,7 +186,9 @@ linear_least_squares_fitting_2(InputIterator first,
} // end linear_least_squares_fitting_2 for rectangle set with 1D tag } // end linear_least_squares_fitting_2 for rectangle set with 1D tag
template < typename InputIterator, typename K >
template < typename InputIterator,
typename K >
typename K::FT typename K::FT
linear_least_squares_fitting_2(InputIterator first, linear_least_squares_fitting_2(InputIterator first,
InputIterator beyond, InputIterator beyond,
@ -197,7 +196,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K&, // kernel const K&, // kernel
const typename K::Iso_rectangle_2*,// used for indirection const typename K::Iso_rectangle_2*,// used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
// types // types
typedef typename K::Iso_rectangle_2 Iso_rectangle; typedef typename K::Iso_rectangle_2 Iso_rectangle;

View File

@ -48,7 +48,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K&, // kernel const K&, // kernel
const typename K::Segment_2*,// used for indirection const typename K::Segment_2*,// used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag())
{ {
// types // types
typedef typename K::FT FT; typedef typename K::FT FT;
@ -73,8 +73,7 @@ linear_least_squares_fitting_2(InputIterator first,
FT covariance[3] = {0.0,0.0,0.0}; FT covariance[3] = {0.0,0.0,0.0};
// assemble 2nd order moment about the origin. // assemble 2nd order moment about the origin.
FT temp[4] = {1.0, 0.5, FT temp[4] = {1.0, 0.5, 0.5, 1.0};
0.5, 1.0};
Matrix moment = (1.0/3.0) * init_matrix<K>(2,temp); Matrix moment = (1.0/3.0) * init_matrix<K>(2,temp);
for(InputIterator it = first; for(InputIterator it = first;
@ -148,7 +147,7 @@ linear_least_squares_fitting_2(InputIterator first,
typename K::Point_2& c, // centroid typename K::Point_2& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Segment_2*,// used for indirection const typename K::Segment_2*,// used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
// types // types
typedef typename K::Point_2 Point; typedef typename K::Point_2 Point;

View File

@ -41,7 +41,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Segment_3*, // used for indirection const typename K::Segment_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Segment_3 Segment; typedef typename K::Segment_3 Segment;
@ -71,7 +71,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Segment_3*, // used for indirection const typename K::Segment_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Segment_3 Segment; typedef typename K::Segment_3 Segment;
@ -105,7 +105,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Segment_3*, // used for indirection const typename K::Segment_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Segment_3 Segment; typedef typename K::Segment_3 Segment;
@ -135,7 +135,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Segment_3*, // used for indirection const typename K::Segment_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Segment_3 Segment; typedef typename K::Segment_3 Segment;

View File

@ -31,7 +31,7 @@ CGAL_BEGIN_NAMESPACE
namespace CGALi { namespace CGALi {
// fits a plane to a 3D sphere set // fits a plane to a set of 3D balls (3D)
template < typename InputIterator, template < typename InputIterator,
typename K > typename K >
typename K::FT typename K::FT
@ -41,7 +41,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Sphere_3*, // used for indirection const typename K::Sphere_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Sphere_3 Sphere; typedef typename K::Sphere_3 Sphere;
@ -71,7 +71,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Sphere_3*, // used for indirection const typename K::Sphere_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Sphere_3 Sphere; typedef typename K::Sphere_3 Sphere;
@ -91,7 +91,8 @@ linear_least_squares_fitting_3(InputIterator first,
} // end linear_least_squares_fitting_spheres_3 } // end linear_least_squares_fitting_spheres_3
// fits a line to a 3D sphere set
// fits a line to a 3D ball set
template < typename InputIterator, template < typename InputIterator,
typename K > typename K >
typename K::FT typename K::FT
@ -101,7 +102,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Sphere_3*, // used for indirection const typename K::Sphere_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Sphere_3 Sphere; typedef typename K::Sphere_3 Sphere;
@ -132,7 +133,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Sphere_3*, // used for indirection const typename K::Sphere_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Sphere_3 Sphere; typedef typename K::Sphere_3 Sphere;

View File

@ -41,7 +41,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Tetrahedron_3*, // used for indirection const typename K::Tetrahedron_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Tetrahedron_3 Tetrahedron; typedef typename K::Tetrahedron_3 Tetrahedron;
@ -72,7 +72,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Tetrahedron_3*, // used for indirection const typename K::Tetrahedron_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Tetrahedron_3 Tetrahedron; typedef typename K::Tetrahedron_3 Tetrahedron;
@ -182,7 +182,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Tetrahedron_3*, // used for indirection const typename K::Tetrahedron_3*, // used for indirection
const CGAL::PCA_dimension_3_tag& tag) const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Tetrahedron_3 Tetrahedron; typedef typename K::Tetrahedron_3 Tetrahedron;

View File

@ -41,7 +41,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;
@ -71,7 +71,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;
@ -106,7 +106,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;
@ -141,7 +141,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_2_tag& tag) const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag())
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;
@ -171,7 +171,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_1_tag& tag) const CGAL::PCA_dimension_1_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;
@ -206,7 +206,7 @@ linear_least_squares_fitting_3(InputIterator first,
typename K::Point_3& c, // centroid typename K::Point_3& c, // centroid
const K& k, // kernel const K& k, // kernel
const typename K::Triangle_3*, // used for indirection const typename K::Triangle_3*, // used for indirection
const CGAL::PCA_dimension_0_tag& tag) const CGAL::PCA_dimension_0_tag& tag)
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Triangle_3 Triangle; typedef typename K::Triangle_3 Triangle;