Do not do a matrix-matrix multiplication, but do N matrix-vector multiplications as we only want min and max

This commit is contained in:
Andreas Fabri 2018-05-04 13:53:30 +01:00 committed by Konstantinos Katrioplas
parent eb9cb4b8eb
commit 0fef43ef03
2 changed files with 28 additions and 5 deletions

View File

@ -42,6 +42,27 @@ const double compute_fitness(const Vertex& R, const Matrix& data)
CGAL_assertion(data.rows() >= 3);
// rotate points
#if 1
double xmin, xmax, ymin, ymax, zmin, zmax;
for(int i = 0; i < data.rows(); i++){
Eigen::Vector3d vec = data.row(i);
vec = R * vec;
if(i == 0){
xmin = xmax = vec.coeff(0);
ymin = ymax = vec.coeff(1);
zmin = zmax = vec.coeff(2);
}else {
if(vec.coeff(0) < xmin) xmin = vec.coeff(0);
if(vec.coeff(1) < ymin) ymin = vec.coeff(1);
if(vec.coeff(2) < zmin) zmin = vec.coeff(2);
if(vec.coeff(0) > xmax) xmax = vec.coeff(0);
if(vec.coeff(1) > ymax) ymax = vec.coeff(1);
if(vec.coeff(2) > zmax) zmax = vec.coeff(2);
}
}
#else
Vertex RT = R.transpose();
Matrix rotated_data;
rotated_data = data * RT;
@ -55,7 +76,9 @@ const double compute_fitness(const Vertex& R, const Matrix& data)
double ymax = rotated_data.col(1).maxCoeff();
double zmin = rotated_data.col(2).minCoeff();
double zmax = rotated_data.col(2).maxCoeff();
#endif
double x_dim = abs(xmax - xmin); // abs needed?
double y_dim = abs(ymax - ymin);
double z_dim = abs(zmax - zmin);

View File

@ -362,14 +362,14 @@ bench(const char* fname)
std::cout << "number of points= " << sm_points.size() << std::endl;
CGAL::Optimal_bounding_box::find_obb(sm_points, obb_points, true);
CGAL::Optimal_bounding_box::find_obb(sm_points, obb_points, false);
/*
std::cout.precision(17);
for(int i =0; i < obb_points.size(); i ++){
std::cout << obb_points[i] << std::endl;
}
*/
/*
CGAL::Surface_mesh<K::Point_3> mesh;
CGAL::make_hexahedron(obb_points[0], obb_points[1], obb_points[2], obb_points[3], obb_points[4], obb_points[5],
@ -378,7 +378,7 @@ bench(const char* fname)
std::ofstream out("/tmp/result_obb.off");
out << mesh;
out.close();
*/
}