mirror of https://github.com/CGAL/cgal
PCA: renamed example file for tetrahedra
started cleaning up the examples codes
This commit is contained in:
parent
638b292458
commit
d88923b47c
|
|
@ -3036,7 +3036,7 @@ Principal_component_analysis/examples/Principal_component_analysis/linear_least_
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_segments_2.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_segments_2.cpp -text
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_segments_3.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_segments_3.cpp -text
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_spheres_3.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_spheres_3.cpp -text
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_tetrahedrons_3.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_tetrahedra_3.cpp -text
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_2.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_2.cpp -text
|
||||||
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp -text
|
Principal_component_analysis/examples/Principal_component_analysis/linear_least_squares_fitting_triangles_3.cpp -text
|
||||||
Principal_component_analysis/include/CGAL/PCA_tags.h -text
|
Principal_component_analysis/include/CGAL/PCA_tags.h -text
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,28 @@ typedef K::Iso_cuboid_3 Iso_cuboid_3;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::list<Iso_cuboid_3> Iso_cuboids;
|
std::list<Iso_cuboid_3> cuboids;
|
||||||
Iso_cuboids.push_back(Iso_cuboid_3(Point_3(0.0,0.0,0.0),Point_3(1.0,1.0,1.0)));
|
cuboids.push_back(Iso_cuboid_3(Point_3(0.0,0.0,0.0),Point_3(1.0,1.0,1.0)));
|
||||||
Iso_cuboids.push_back(Iso_cuboid_3(Point_3(1.0,1.0,1.0),Point_3(6.0,6.0,6.0)));
|
cuboids.push_back(Iso_cuboid_3(Point_3(1.0,1.0,1.0),Point_3(6.0,6.0,6.0)));
|
||||||
|
|
||||||
Line_3 line;
|
Line_3 line;
|
||||||
linear_least_squares_fitting_3(Iso_cuboids.begin(),Iso_cuboids.end(),line,CGAL::PCA_dimension_3_tag());
|
|
||||||
|
|
||||||
Plane_3 plane;
|
Plane_3 plane;
|
||||||
linear_least_squares_fitting_3(Iso_cuboids.begin(),Iso_cuboids.end(),plane,CGAL::PCA_dimension_3_tag());
|
|
||||||
|
|
||||||
|
// fit volume
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),line,CGAL::PCA_dimension_3_tag());
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),plane,CGAL::PCA_dimension_3_tag());
|
||||||
|
|
||||||
//Use only faces.
|
// fit faces
|
||||||
linear_least_squares_fitting_3(Iso_cuboids.begin(),Iso_cuboids.end(),line,CGAL::PCA_dimension_2_tag());
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),line,CGAL::PCA_dimension_2_tag());
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),plane,CGAL::PCA_dimension_2_tag());
|
||||||
|
|
||||||
linear_least_squares_fitting_3(Iso_cuboids.begin(),Iso_cuboids.end(),plane,CGAL::PCA_dimension_2_tag());
|
// fit edges
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),line,CGAL::PCA_dimension_1_tag());
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),plane,CGAL::PCA_dimension_1_tag());
|
||||||
|
|
||||||
|
// fit vertices
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),line,CGAL::PCA_dimension_0_tag());
|
||||||
|
linear_least_squares_fitting_3(cuboids.begin(),cuboids.end(),plane,CGAL::PCA_dimension_0_tag());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Example program for the linear_least_square_fitting function
|
||||||
|
// on a set of tetrahedra in 3D
|
||||||
|
|
||||||
|
#include <CGAL/Cartesian.h>
|
||||||
|
#include <CGAL/linear_least_squares_fitting_3.h>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
typedef double FT;
|
||||||
|
typedef CGAL::Cartesian<FT> K;
|
||||||
|
typedef K::Line_3 Line_3;
|
||||||
|
typedef K::Plane_3 Plane_3;
|
||||||
|
typedef K::Point_3 Point_3;
|
||||||
|
typedef K::Tetrahedron_3 Tetrahedron_3;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
Point a( 0.0,0.0,0.0);
|
||||||
|
Point b( 1.0,0.0,0.0);
|
||||||
|
Point c(-1.0,0.0,0.0);
|
||||||
|
Point d( 0.0,1.0,1.0);
|
||||||
|
Point e( 0.0,0.0,0.0);
|
||||||
|
|
||||||
|
std::list<Tetrahedron_3> tetrahedra;
|
||||||
|
tetrahedra.push_back(Tetrahedron_3(a,b,c,d));
|
||||||
|
tetrahedra.push_back(Tetrahedron_3(a,b,c,e));
|
||||||
|
|
||||||
|
// fit a line
|
||||||
|
Line_3 line;
|
||||||
|
linear_least_squares_fitting_3(tetrahedra.begin(),tetrahedra.end(),line,CGAL::PCA_dimension_3_tag());
|
||||||
|
|
||||||
|
// fit a plane
|
||||||
|
Plane_3 plane;
|
||||||
|
linear_least_squares_fitting_3(tetrahedra.begin(),tetrahedra.end(),plane,CGAL::PCA_dimension_3_tag());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
// Example program for the linear_least_square_fitting function on set of tetrahedrons in 3D
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/linear_least_squares_fitting_3.h>
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
typedef double FT;
|
|
||||||
typedef CGAL::Cartesian<FT> K;
|
|
||||||
typedef K::Line_3 Line_3;
|
|
||||||
typedef K::Plane_3 Plane_3;
|
|
||||||
typedef K::Point_3 Point_3;
|
|
||||||
typedef K::Tetrahedron_3 Tetrahedron_3;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::list<Tetrahedron_3> tetrahedrons;
|
|
||||||
tetrahedrons.push_back(Tetrahedron_3(Point_3(0.0,0.0,0.0),Point_3(1.0,0.0,0.0),Point_3(0.0,1.0,0.0),Point_3(0.0,0.0,1.0)));
|
|
||||||
tetrahedrons.push_back(Tetrahedron_3(Point_3(0.0,0.0,0.0),Point_3(-1.0,0.0,0.0),Point_3(0.0,-1.0,0.0),Point_3(0.0,0.0,1.0)));
|
|
||||||
|
|
||||||
Line_3 line;
|
|
||||||
linear_least_squares_fitting_3(tetrahedrons.begin(),tetrahedrons.end(),line,CGAL::PCA_dimension_3_tag());
|
|
||||||
|
|
||||||
Plane_3 plane;
|
|
||||||
linear_least_squares_fitting_3(tetrahedrons.begin(),tetrahedrons.end(),plane,CGAL::PCA_dimension_3_tag());
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -12,7 +12,7 @@ typedef K::Plane_3 Plane_3;
|
||||||
typedef K::Point_3 Point_3;
|
typedef K::Point_3 Point_3;
|
||||||
typedef K::Triangle_3 Triangle_3;
|
typedef K::Triangle_3 Triangle_3;
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
std::list<Triangle_3> triangles;
|
std::list<Triangle_3> triangles;
|
||||||
triangles.push_back(Triangle_3(Point_3(1.0,0.0,0.0),Point_3(0.0,1.0,0.0),Point_3(0.0,0.0,0.0)));
|
triangles.push_back(Triangle_3(Point_3(1.0,0.0,0.0),Point_3(0.0,1.0,0.0),Point_3(0.0,0.0,0.0)));
|
||||||
|
|
|
||||||
|
|
@ -30,22 +30,10 @@ CGAL_BEGIN_NAMESPACE
|
||||||
//::between these different types of the same geometry
|
//::between these different types of the same geometry
|
||||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
// Fully filled geometry object, such as disks in 2d and balls in 3d
|
|
||||||
struct PCA_dimension_3_tag {};
|
|
||||||
|
|
||||||
// Empty geometry objects, such as triangles in 2d and hollow cubes with just the planar facets in 3d
|
|
||||||
struct PCA_dimension_2_tag {};
|
|
||||||
|
|
||||||
// Only relevant for 3d objects, outlines of 3d geometry objects formed by just lines joing appropriate vetrices, such as outline of a cuboid.
|
|
||||||
struct PCA_dimension_1_tag {};
|
|
||||||
|
|
||||||
// For the vertices of objects.
|
|
||||||
struct PCA_dimension_0_tag {};
|
struct PCA_dimension_0_tag {};
|
||||||
|
struct PCA_dimension_1_tag {};
|
||||||
|
struct PCA_dimension_2_tag {};
|
||||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
struct PCA_dimension_3_tag {};
|
||||||
// Struct to denote dimension compile time decisions
|
|
||||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,6 @@ assemble_covariance_matrix_3(InputIterator first,
|
||||||
const Triangle& t = *it;
|
const Triangle& t = *it;
|
||||||
|
|
||||||
// defined for convenience.
|
// defined for convenience.
|
||||||
// FT example = CGAL::to_double(t[0].x());
|
|
||||||
FT delta[9] = {t[0].x(), t[1].x(), t[2].x(),
|
FT delta[9] = {t[0].x(), t[1].x(), t[2].x(),
|
||||||
t[0].y(), t[1].y(), t[2].y(),
|
t[0].y(), t[1].y(), t[2].y(),
|
||||||
t[0].z(), t[1].z(), t[2].z()};
|
t[0].z(), t[1].z(), t[2].z()};
|
||||||
|
|
@ -380,7 +379,6 @@ assemble_covariance_matrix_3(InputIterator first,
|
||||||
const Sphere& t = *it;
|
const Sphere& t = *it;
|
||||||
|
|
||||||
// defined for convenience.
|
// defined for convenience.
|
||||||
// FT example = CGAL::to_double(t[0].x());
|
|
||||||
FT radius = std::sqrt(t.squared_radius());
|
FT radius = std::sqrt(t.squared_radius());
|
||||||
FT delta[9] = {radius, 0.0, 0.0,
|
FT delta[9] = {radius, 0.0, 0.0,
|
||||||
0.0, radius, 0.0,
|
0.0, radius, 0.0,
|
||||||
|
|
@ -545,7 +543,6 @@ assemble_covariance_matrix_3(InputIterator first,
|
||||||
const Tetrahedron& t = *it;
|
const Tetrahedron& t = *it;
|
||||||
|
|
||||||
// defined for convenience.
|
// defined for convenience.
|
||||||
// FT example = CGAL::to_double(t[0].x());
|
|
||||||
FT x0 = t[0].x();
|
FT x0 = t[0].x();
|
||||||
FT y0 = t[0].y();
|
FT y0 = t[0].y();
|
||||||
FT z0 = t[0].z();
|
FT z0 = t[0].z();
|
||||||
|
|
@ -719,7 +716,7 @@ typename K::FT
|
||||||
fitting_line_3(const typename K::FT covariance[6], // covariance matrix
|
fitting_line_3(const typename K::FT covariance[6], // covariance matrix
|
||||||
const typename K::Point_3& c, // centroid
|
const typename K::Point_3& c, // centroid
|
||||||
typename K::Line_3& line, // best fit line
|
typename K::Line_3& line, // best fit line
|
||||||
const K& ) // kernel
|
const K&) // kernel
|
||||||
{
|
{
|
||||||
typedef typename K::FT FT;
|
typedef typename K::FT FT;
|
||||||
typedef typename K::Point_3 Point;
|
typedef typename K::Point_3 Point;
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,14 @@
|
||||||
#include <CGAL/Object.h>
|
#include <CGAL/Object.h>
|
||||||
#include <CGAL/Algebraic_structure_traits.h>
|
#include <CGAL/Algebraic_structure_traits.h>
|
||||||
#include <CGAL/IO/io.h>
|
#include <CGAL/IO/io.h>
|
||||||
|
|
||||||
#include <CGAL/linear_least_squares_fitting_points_3.h>
|
#include <CGAL/linear_least_squares_fitting_points_3.h>
|
||||||
#include <CGAL/linear_least_squares_fitting_segments_3.h>
|
|
||||||
#include <CGAL/linear_least_squares_fitting_triangles_3.h>
|
|
||||||
#include <CGAL/linear_least_squares_fitting_spheres_3.h>
|
#include <CGAL/linear_least_squares_fitting_spheres_3.h>
|
||||||
#include <CGAL/linear_least_squares_fitting_cuboids_3.h>
|
#include <CGAL/linear_least_squares_fitting_cuboids_3.h>
|
||||||
|
#include <CGAL/linear_least_squares_fitting_segments_3.h>
|
||||||
|
#include <CGAL/linear_least_squares_fitting_triangles_3.h>
|
||||||
#include <CGAL/linear_least_squares_fitting_tetrahedra_3.h>
|
#include <CGAL/linear_least_squares_fitting_tetrahedra_3.h>
|
||||||
|
|
||||||
#include <CGAL/PCA_tags.h>
|
#include <CGAL/PCA_tags.h>
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
@ -46,9 +48,9 @@ inline
|
||||||
typename Kernel::FT
|
typename Kernel::FT
|
||||||
linear_least_squares_fitting_3(InputIterator first,
|
linear_least_squares_fitting_3(InputIterator first,
|
||||||
InputIterator beyond,
|
InputIterator beyond,
|
||||||
typename Object& object, // plane or line (result)
|
typename Object& object, // plane or line
|
||||||
typename Kernel::Point_3& centroid,
|
typename Kernel::Point_3& centroid,
|
||||||
const Tag& tag,
|
const Tag& tag, // dimension tag, ranges from 0 to 3
|
||||||
const Kernel& kernel)
|
const Kernel& kernel)
|
||||||
{
|
{
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
||||||
|
|
@ -56,7 +58,6 @@ linear_least_squares_fitting_3(InputIterator first,
|
||||||
centroid, (Value_type*) NULL, kernel, tag);
|
centroid, (Value_type*) NULL, kernel, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// deduces kernel from value type of input iterator
|
// deduces kernel from value type of input iterator
|
||||||
template < typename InputIterator,
|
template < typename InputIterator,
|
||||||
typename Object,
|
typename Object,
|
||||||
|
|
@ -66,16 +67,16 @@ inline
|
||||||
typename Kernel_traits<Object>::Kernel::FT
|
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, // plane or line
|
||||||
Point& centroid,
|
Point& centroid,
|
||||||
const Tag& tag)
|
const Tag& tag) // dimension tag, ranges from 0 to 3
|
||||||
{
|
{
|
||||||
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 Kernel;
|
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
|
||||||
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag,Kernel());
|
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag,Kernel());
|
||||||
}
|
}
|
||||||
|
|
||||||
// does not writes centroid and deduces kernel
|
// deduces kernel and does not write centroid
|
||||||
template < typename InputIterator,
|
template < typename InputIterator,
|
||||||
typename Object,
|
typename Object,
|
||||||
typename Tag>
|
typename Tag>
|
||||||
|
|
@ -83,108 +84,15 @@ inline
|
||||||
typename Kernel_traits<Object>::Kernel::FT
|
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, // plane or line
|
||||||
const Tag& tag)
|
const Tag& tag) // dimension tag, ranges from 0 to 3
|
||||||
{
|
{
|
||||||
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 Kernel;
|
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
|
||||||
typename Kernel::Point_3 centroid; // unused by caller
|
typename Kernel::Point_3 centroid; // not used by caller
|
||||||
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag);
|
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// does not return the centroid, deduces kernel, and default tag
|
|
||||||
// simplest (default) call of the function
|
|
||||||
/*
|
|
||||||
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 Kernel;
|
|
||||||
typename Kernel::Point_3 centroid; // unused by caller
|
|
||||||
return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,(Value_type *)NULL,K());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
template < typename InputIterator,
|
|
||||||
typename Object, typename tag >
|
|
||||||
inline
|
|
||||||
typename Kernel_traits<Object>::Kernel::FT
|
|
||||||
linear_least_squares_fitting_3(InputIterator first,
|
|
||||||
InputIterator beyond,
|
|
||||||
Object& object,
|
|
||||||
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));
|
|
||||||
typedef typename Kernel_traits<Value_type>::Kernel K;
|
|
||||||
return CGAL::linear_least_squares_fitting_3(first,beyond,object,K(), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
// default tag (dimension of fitted objects, ie 1 for segments, 2 for triangles, 3 for tets, etc.)
|
|
||||||
template < typename InputIterator,
|
|
||||||
typename Object,
|
|
||||||
typename Kernel >
|
|
||||||
inline
|
|
||||||
typename Kernel::FT
|
|
||||||
linear_least_squares_fitting_3(InputIterator first,
|
|
||||||
InputIterator beyond,
|
|
||||||
typename Object& object, // plane or line
|
|
||||||
typename Kernel::Point_3& centroid,
|
|
||||||
const Kernel& kernel)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
|
||||||
return CGALi::linear_least_squares_fitting_3(first, beyond, object,
|
|
||||||
centroid, (Value_type*) NULL, kernel);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// omits centroid
|
|
||||||
template < typename InputIterator,
|
|
||||||
typename Object,
|
|
||||||
typename Kernel,
|
|
||||||
typename Tag >
|
|
||||||
inline
|
|
||||||
typename Kernel::FT
|
|
||||||
linear_least_squares_fitting_3(InputIterator first,
|
|
||||||
InputIterator beyond,
|
|
||||||
Object& object,
|
|
||||||
const Kernel& kernel,
|
|
||||||
const Tag& tag)
|
|
||||||
{
|
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
|
|
||||||
typename Kernel::Point_3 centroid; // unused by caller
|
|
||||||
return CGALi::linear_least_squares_fitting_3(first, beyond, object,
|
|
||||||
centroid, (Value_type*) NULL, kernel, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_3_H
|
#endif // CGAL_LINEAR_LEAST_SQUARES_FITTING_3_H
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,31 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
typedef double FT;
|
typedef double FT;
|
||||||
typedef CGAL::Cartesian<FT> K;
|
typedef CGAL::Cartesian<FT> Kernel;
|
||||||
typedef K::Line_3 Line_3;
|
typedef Kernel::Line_3 Line_3;
|
||||||
typedef K::Plane_3 Plane_3;
|
typedef Kernel::Plane_3 Plane_3;
|
||||||
typedef K::Point_3 Point_3;
|
typedef Kernel::Point_3 Point_3;
|
||||||
typedef K::Sphere_3 Sphere_3;
|
typedef Kernel::Sphere_3 Sphere_3;
|
||||||
|
|
||||||
int main()
|
int main(void)
|
||||||
{
|
{
|
||||||
std::list<Sphere_3> spheres;
|
// centers
|
||||||
spheres.push_back(Sphere_3(Point_3(0.0,0.0,0.0),9));
|
Point c1(0.0,0.0,0.0);
|
||||||
spheres.push_back(Sphere_3(Point_3(0.0,10.0,0.0),25));
|
Point c2(1.0,1.0,1.0);
|
||||||
|
|
||||||
|
// radii
|
||||||
|
FT sqr1 = 0.1;
|
||||||
|
FT sqr2 = 0.5;
|
||||||
|
|
||||||
|
// add two spheres
|
||||||
|
std::list<Sphere_3> spheres;
|
||||||
|
spheres.push_back(Sphere_3(c1,sqr1));
|
||||||
|
spheres.push_back(Sphere_3(c2,sqr2));
|
||||||
|
|
||||||
|
Kernel k;
|
||||||
|
Point_3 c;
|
||||||
Line_3 line;
|
Line_3 line;
|
||||||
Plane_3 plane;
|
Plane_3 plane;
|
||||||
K k;
|
|
||||||
Point_3 c;
|
|
||||||
|
|
||||||
linear_least_squares_fitting_3(spheres.begin(),spheres.end(),line,CGAL::PCA_dimension_3_tag());
|
linear_least_squares_fitting_3(spheres.begin(),spheres.end(),line,CGAL::PCA_dimension_3_tag());
|
||||||
linear_least_squares_fitting_3(spheres.begin(),spheres.end(),line,CGAL::PCA_dimension_2_tag());
|
linear_least_squares_fitting_3(spheres.begin(),spheres.end(),line,CGAL::PCA_dimension_2_tag());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue