mirror of https://github.com/CGAL/cgal
Speed up fitness function computations
This commit is contained in:
parent
d6c1abadcf
commit
b3968d2b0d
|
|
@ -25,6 +25,10 @@ public:
|
||||||
/// matrix-matrix and scalar-matrix multiplication, as well as matrix-matrix addition
|
/// matrix-matrix and scalar-matrix multiplication, as well as matrix-matrix addition
|
||||||
typedef unspecified_type Matrix;
|
typedef unspecified_type Matrix;
|
||||||
|
|
||||||
|
/// A 3 dimensional vector type; model of the concept `SvdTraits::Vector` and which supports
|
||||||
|
/// matrix-vector and multiplication
|
||||||
|
typedef unspecified_type Vector;
|
||||||
|
|
||||||
/// Returns the unitary matrix `Q` obtained in the QR-decomposition of the matrix `m`
|
/// Returns the unitary matrix `Q` obtained in the QR-decomposition of the matrix `m`
|
||||||
Matrix get_Q(const Matrix& m) const;
|
Matrix get_Q(const Matrix& m) const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#ifdef CGAL_EIGEN3_ENABLED
|
#ifdef CGAL_EIGEN3_ENABLED
|
||||||
#include <CGAL/Eigen_matrix.h>
|
#include <CGAL/Eigen_matrix.h>
|
||||||
|
#include <CGAL/Eigen_vector.h>
|
||||||
#include <Eigen/QR>
|
#include <Eigen/QR>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -51,6 +52,9 @@ public:
|
||||||
/// The matrix type
|
/// The matrix type
|
||||||
typedef CGAL::Eigen_matrix<FT, 3, 3> Matrix;
|
typedef CGAL::Eigen_matrix<FT, 3, 3> Matrix;
|
||||||
|
|
||||||
|
/// The matrix type
|
||||||
|
typedef CGAL::Eigen_vector<FT, 3> Vector;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef typename Matrix::EigenType EigenType;
|
typedef typename Matrix::EigenType EigenType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ compute_fitness(const typename Traits::Matrix& R, // rotation matrix
|
||||||
{
|
{
|
||||||
typedef typename Traits::FT FT;
|
typedef typename Traits::FT FT;
|
||||||
typedef typename Traits::Point_3 Point;
|
typedef typename Traits::Point_3 Point;
|
||||||
|
typedef typename Traits::Vector Vector;
|
||||||
|
|
||||||
CGAL_assertion(R.number_of_rows() == 3 && R.number_of_columns() == 3);
|
CGAL_assertion(R.number_of_rows() == 3 && R.number_of_columns() == 3);
|
||||||
CGAL_assertion(points.size() >= 3);
|
CGAL_assertion(points.size() >= 3);
|
||||||
|
|
@ -43,18 +44,18 @@ compute_fitness(const typename Traits::Matrix& R, // rotation matrix
|
||||||
|
|
||||||
for(const Point& pt : points)
|
for(const Point& pt : points)
|
||||||
{
|
{
|
||||||
const FT x = pt.x(), y = pt.y(), z = pt.z();
|
Vector pv(3);
|
||||||
|
pv.set(0, pt.x());
|
||||||
|
pv.set(1, pt.y());
|
||||||
|
pv.set(2, pt.z());
|
||||||
|
pv = R * pv;
|
||||||
|
|
||||||
const FT rx = x*R(0, 0) + y*R(0, 1) + z*R(0, 2);
|
xmin = (std::min)(xmin, pv(0));
|
||||||
const FT ry = x*R(1, 0) + y*R(1, 1) + z*R(1, 2);
|
ymin = (std::min)(ymin, pv(1));
|
||||||
const FT rz = x*R(2, 0) + y*R(2, 1) + z*R(2, 2);
|
zmin = (std::min)(zmin, pv(2));
|
||||||
|
xmax = (std::max)(xmax, pv(0));
|
||||||
xmin = (std::min)(xmin, rx);
|
ymax = (std::max)(ymax, pv(1));
|
||||||
ymin = (std::min)(ymin, ry);
|
zmax = (std::max)(zmax, pv(2));
|
||||||
zmin = (std::min)(zmin, rz);
|
|
||||||
xmax = (std::max)(xmax, rx);
|
|
||||||
ymax = (std::max)(ymax, ry);
|
|
||||||
zmax = (std::max)(zmax, rz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// volume
|
// volume
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue