Skip to content
Snippets Groups Projects
Commit c9095b99 authored by Tom Fischer's avatar Tom Fischer
Browse files

[GL] Use Eigen in computeRotationMatrixToXY.

parent 891fea96
No related branches found
No related tags found
No related merge requests found
......@@ -196,11 +196,8 @@ void rotateGeometryToXY(std::vector<GeoLib::Point*>& points,
// compute the plane normal
auto const [plane_normal, d] =
GeoLib::getNewellPlane(points.begin(), points.end());
// ToDo (TF) remove when computeRotationMatrixToXY uses Eigen
MathLib::Vector3 const tmp_plane_normal(
{plane_normal[0], plane_normal[1], plane_normal[2]});
// rotate points into x-y-plane
GeoLib::computeRotationMatrixToXY(tmp_plane_normal, rotation_matrix);
GeoLib::computeRotationMatrixToXY(plane_normal, rotation_matrix);
GeoLib::rotatePoints(rotation_matrix, points.begin(), points.end());
GeoLib::AABB aabb(points.begin(), points.end());
......
......@@ -118,8 +118,7 @@ void compute3DRotationMatrixToX(MathLib::Vector3 const& v,
}
template <class T_MATRIX>
void computeRotationMatrixToXY(MathLib::Vector3 const& n,
T_MATRIX & rot_mat)
void computeRotationMatrixToXY(Eigen::Vector3d const& n, T_MATRIX& rot_mat)
{
// check if normal points already in the right direction
if (n[0] == 0 && n[1] == 0) {
......@@ -178,7 +177,7 @@ void computeRotationMatrixToXY(MathLib::Vector3 const& n,
return;
}
double h1(1 / n.getLength());
double const h1(1 / n.norm());
// general case: calculate entries of rotation matrix
rot_mat(0, 0) = n[2] / h0;
......@@ -219,13 +218,10 @@ MathLib::DenseMatrix<double> rotatePointsToXY(InputIterator1 p_pnts_begin,
// compute the plane normal
auto const [plane_normal, d] =
GeoLib::getNewellPlane(p_pnts_begin, p_pnts_end);
// ToDo (TF) remove when computeRotationMatrixToXY uses Eigen
MathLib::Vector3 const tmp_plane_normal(
{plane_normal[0], plane_normal[1], plane_normal[2]});
// rotate points into x-y-plane
MathLib::DenseMatrix<double> rot_mat(3, 3);
computeRotationMatrixToXY(tmp_plane_normal, rot_mat);
computeRotationMatrixToXY(plane_normal, rot_mat);
rotatePoints(rot_mat, r_pnts_begin, r_pnts_end);
for (auto it = r_pnts_begin; it != r_pnts_end; ++it)
......
......@@ -103,7 +103,7 @@ void compute3DRotationMatrixToX(MathLib::Vector3 const& v, T_MATRIX & rot_mat);
* @param rot_mat 3x3 rotation matrix
*/
template <class T_MATRIX>
void computeRotationMatrixToXY(MathLib::Vector3 const& n, T_MATRIX& rot_mat);
void computeRotationMatrixToXY(Eigen::Vector3d const& n, T_MATRIX& rot_mat);
/**
* rotate points according to the rotation matrix
......
......@@ -27,8 +27,11 @@ std::vector<bool> markNodesOutSideOfPolygon(
std::vector<MeshLib::Node*> const& nodes, GeoLib::Polygon const& polygon)
{
// *** rotate polygon to xy_plane
MathLib::Vector3 normal;
GeoLib::Polygon rot_polygon(GeoLib::rotatePolygonToXY(polygon, normal));
MathLib::Vector3 tmp_normal;
GeoLib::Polygon rot_polygon(GeoLib::rotatePolygonToXY(polygon, tmp_normal));
// ToDo (TF) remove when computeRotationMatrixToXY accepts Eigen normal
auto const normal = Eigen::Map<Eigen::Vector3d>(
const_cast<double*>(tmp_normal.getCoords()));
// *** rotate mesh nodes to xy-plane
// 1 copy all mesh nodes to GeoLib::Points
......
......@@ -58,12 +58,8 @@ void getRotationMatrixToGlobal(const unsigned element_dimension,
{
// get plane normal
auto const [plane_normal, d] = GeoLib::getNewellPlane(points);
// ToDo (TF) remove when computeRotationMatrixToXY uses Eigen
MathLib::Vector3 const tmp_plane_normal(
{plane_normal[0], plane_normal[1], plane_normal[2]});
// compute a rotation matrix to XY
GeoLib::computeRotationMatrixToXY(tmp_plane_normal, matR);
GeoLib::computeRotationMatrixToXY(plane_normal, matR);
// set a transposed matrix
matR.transposeInPlace();
}
......
......@@ -24,7 +24,7 @@ auto test3equal = [](double a, double b, double c, double const* result)
TEST(GeoLib, ComputeRotationMatrixToXYnegative)
{
MathLib::Vector3 const n(0.0, -1.0, 0.0);
Eigen::Vector3d const n({0.0, -1.0, 0.0});
MathLib::DenseMatrix<double> rot_mat(3,3,0.0);
GeoLib::computeRotationMatrixToXY(n, rot_mat);
......@@ -50,7 +50,7 @@ TEST(GeoLib, ComputeRotationMatrixToXYnegative)
TEST(GeoLib, ComputeRotationMatrixToXYpositive)
{
MathLib::Vector3 const n(0.0, 1.0, 0.0);
Eigen::Vector3d const n{0.0, 1.0, 0.0};
MathLib::DenseMatrix<double> rot_mat(3,3,0.0);
GeoLib::computeRotationMatrixToXY(n, rot_mat);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment