Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel
Chronological Thread
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel
- Date: Thu, 06 Oct 2011 17:49:49 +0200
You cannot do it exactly. You can only get an approximation.
Something like this should work
K::FT sqrt(K::FT v) {
return K::FT(std::sqrt(CGAL::to_double(v)));
}
No guarantee that you will not have a problem with another
function not available for this number type.
Sebastien.
Kai WANG wrote:
I'm sorry that I still don't quite understand how to modify it. Could you please give a detailed explanation on the way to add a "sqrt" function please? For example, given the following simple program which has complile error, where should I add the "sqrt" function please?
Thanks very much for ur help!
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Line_3 Line;
typedef K::Plane_3 Plane;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
int main(void)
{
std::list<Triangle> triangles;
Point a(1.0,2.0,3.0);
Point b(4.0,0.0,6.0);
Point c(7.0,8.0,9.0);
Point d(8.0,7.0,6.0);
Point e(5.0,3.0,4.0);
triangles.push_back(Triangle(a,b,c));
triangles.push_back(Triangle(a,b,d));
triangles.push_back(Triangle(d,e,c));
Line line;
Plane plane;
// fit plane to whole triangles
linear_least_squares_fitting_3(triangles.begin(),triangles.end(),plane,CGAL::Dimension_tag<2>());
// fit line to triangle vertices
linear_least_squares_fitting_3(triangles.begin(),triangles.end(),line, CGAL::Dimension_tag<0>());
return 0;
}
On Thu, Oct 6, 2011 at 11:31 PM, Sebastien Loriot (GeometryFactory) < <mailto:>> wrote:
the PCA package make use of the square root function, so the underlying
number type in the kernel you are using should have a sqrt function
available.
Sebastien.
kyewong wrote:
Hi,
When I'm using the linear_least_squares_fitting_3 and
CGAL::Exact_predicates_exact___constructions_kernel as kernel,
there will be a
compile error as follows.
Could anyone tell me how to modify it if I want to use both of
them at the
same time please? Thanks very much!
1>F:\Program Files\CGAL-3.8\include\CGAL/__PCA_util.h(132) :
error C2665:
'sqrt' : none of the 3 overloads could convert all the argument
types
1> F:\Program Files\Microsoft Visual Studio
9.0\VC\include\math.h(581): could be 'long double sqrt(long double)'
1> F:\Program Files\Microsoft Visual Studio
9.0\VC\include\math.h(533): or 'float sqrt(float)'
1> F:\Program Files\Microsoft Visual Studio
9.0\VC\include\math.h(128): or 'double sqrt(double)'
1> while trying to match the argument list
'(CGAL::Lazy_exact_nt<ET_>)'
1> with
1> [
1> ET_=CGAL::Gmpq
1> ]
1> F:\Program
Files\CGAL-3.8\include\CGAL/__linear_least_squares_fitting___triangles_3.h(57)
:
see reference to function template instantiation 'void
CGAL::internal::assemble___covariance_matrix_3<__InputIterator,K>(__InputIterator,InputIterator,__CGAL::Lazy_exact_nt<ET_>
[],const CGAL::Point_3<R_> &,const K &,const
CGAL::Triangle_3<R_> *,const
CGAL::Dimension_tag<dim> &)' being compiled
1> with
1> [
1> InputIterator=std::list<__Triangle>::_Iterator<true>,
1> K=CGAL::Epeck,
1> ET_=CGAL::Gmpq,
1> R_=CGAL::Epeck,
1> dim=2
1> ]
1> F:\Program
Files\CGAL-3.8\include\CGAL/__linear_least_squares_fitting___3.h(58)
: see
reference to function template instantiation
'CGAL::Lazy_exact_nt<ET_>
CGAL::internal::linear_least___squares_fitting_3<__InputIterator,Kernel>(__InputIterator,InputIterator,__CGAL::Plane_3<R_>
&,CGAL::Point_3<R_> &,const CGAL::Triangle_3<R_> *,const K &,const
CGAL::Dimension_tag<dim> &)' being compiled
1> with
1> [
1> ET_=CGAL::Gmpq,
1> InputIterator=std::list<__Triangle>::_Iterator<true>,
1> Kernel=CGAL::Epeck,
1> R_=CGAL::Epeck,
1> K=CGAL::Epeck,
1> dim=2
1> ]
1> F:\Program
Files\CGAL-3.8\include\CGAL/__linear_least_squares_fitting___3.h(76)
: see
reference to function template instantiation
'CGAL::Lazy_exact_nt<ET_>
CGAL::linear_least_squares___fitting_3<InputIterator,__Object,CGAL::Epeck,Tag>(__InputIterator,InputIterator,__Object
&,CGAL::Point_3<R_> &,const Tag &,const Kernel &)' being compiled
1> with
1> [
1> ET_=CGAL::Gmpq,
1> InputIterator=std::list<__Triangle>::_Iterator<true>,
1> Object=Plane,
1> Tag=CGAL::Dimension_tag<2>,
1> R_=CGAL::Epeck,
1> Kernel=CGAL::Epeck
1> ]
1> F:\Program
Files\CGAL-3.8\include\CGAL/__linear_least_squares_fitting___3.h(93)
: see
reference to function template instantiation
'CGAL::Lazy_exact_nt<ET_>
CGAL::linear_least_squares___fitting_3<InputIterator,__Object,CGAL::Point_3<R_>__,Tag>(InputIterator,__InputIterator,Object
&,Point &,const Tag &)' being compiled
1> with
1> [
1> ET_=CGAL::Gmpq,
1> InputIterator=std::list<__Triangle>::_Iterator<true>,
1> Object=Plane,
1> R_=CGAL::Epeck,
1> Tag=CGAL::Dimension_tag<2>,
1> Point=CGAL::Point_3<CGAL::__Epeck>
1> ]
1> .\linear_least_squares___fitting_triangles_3.cpp(33) :
see reference
to function template instantiation 'CGAL::Lazy_exact_nt<ET_>
CGAL::linear_least_squares___fitting_3<std::list<_Ty&__gt;::_Iterator<_Secure___validation>,Plane,CGAL::__Dimension_tag<dim>>(__InputIterator,InputIterator,__Object
&,const Tag &)' being compiled
1> with
1> [
1> ET_=CGAL::Gmpq,
1> _Ty=Triangle,
1> _Secure_validation=true,
1> dim=2,
1> InputIterator=std::list<__Triangle>::_Iterator<true>,
1> Object=Plane,
1> Tag=CGAL::Dimension_tag<2>
1> ]
--
View this message in context:
http://cgal-discuss.949826.n4.__nabble.com/compiling-error-of-__linear-least-squares-fitting-__3-under-Exact-predicates-__exact-constructions-kernel-__tp3878596p3878596.html
<http://cgal-discuss.949826.n4.nabble.com/compiling-error-of-linear-least-squares-fitting-3-under-Exact-predicates-exact-constructions-kernel-tp3878596p3878596.html>
Sent from the cgal-discuss mailing list archive at Nabble.com.
-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/__wws/info/cgal-discuss
<https://lists-sop.inria.fr/wws/info/cgal-discuss>
--
Kai WANG
- [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, kyewong, 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Laurent Rineau (GeometryFactory), 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/07/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Kai WANG, 10/06/2011
- Re: [cgal-discuss] compiling error of "linear_least_squares_fitting_3" under :Exact_predicates_exact_constructions_kernel, Sebastien Loriot (GeometryFactory), 10/06/2011
Archive powered by MHonArc 2.6.16.