diff --git a/MathLib/Point3d.h b/MathLib/Point3d.h index 75368621aa822dd8c9df062d82378b795938e4e7..ebc86d6fbe1a611179a05030629bf6bd9648cdde 100644 --- a/MathLib/Point3d.h +++ b/MathLib/Point3d.h @@ -42,5 +42,23 @@ bool lessEq(const MathLib::Point3d& p0, const MathLib::Point3d& p1, double tol = std::numeric_limits<double>::epsilon()); +/** + * rotation of points + * @param mat a rotation matrix + * @param p a point to be transformed + * @return a rotated point + */ +template <typename MATRIX> +inline MathLib::Point3d operator*(MATRIX const& mat, MathLib::Point3d const& p) +{ + MathLib::Point3d new_p; + for (std::size_t i(0); i<3; ++i) { + for (std::size_t j(0); j<3; ++j) { + new_p[i] += mat(i,j)*p[j]; + } + } + return new_p; +} + #endif /* POINT3D_H_ */ diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp index 44fd9ee973f9d7c4ed37b160479625fdf6d45644..a0b8a5364ce4b1084dd4c471cb9f1ad53893904b 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.cpp +++ b/MeshLib/ElementCoordinatesMappingLocal.cpp @@ -29,7 +29,7 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal( _point_vec.push_back(new MeshLib::Node(*(e.getNode(i)))); getRotationMatrixToGlobal(e, global_coords, _point_vec, _matR2global); - rotateToLocal(e, global_coords, _matR2global.transpose(), _point_vec); + rotateToLocal(_matR2global.transpose(), _point_vec); } ElementCoordinatesMappingLocal::~ElementCoordinatesMappingLocal() @@ -38,17 +38,11 @@ ElementCoordinatesMappingLocal::~ElementCoordinatesMappingLocal() } void ElementCoordinatesMappingLocal::rotateToLocal( - const Element &ele, - const CoordinateSystem &global_coords, const RotationMatrix &matR2local, std::vector<MeshLib::Node*> &vec_pt) const { - // rotate the point coordinates - for(unsigned i = 0; i < ele.getNNodes(); i++) - { - Eigen::Vector3d x_new = matR2local * Eigen::Map<Eigen::Vector3d>(const_cast<double*>(vec_pt[i]->getCoords())); - vec_pt[i]->setCoords(x_new.data()); - } + for(unsigned i = 0; i < vec_pt.size(); i++) + vec_pt[i]->setCoords((matR2local* (*vec_pt[i])).getCoords()); } void ElementCoordinatesMappingLocal::getRotationMatrixToGlobal( diff --git a/MeshLib/ElementCoordinatesMappingLocal.h b/MeshLib/ElementCoordinatesMappingLocal.h index 81b72197baf601a2736d009e9058faf42d4ceede..1cc97dddbfc4b621a8a920f711c7ef9005c66b7e 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.h +++ b/MeshLib/ElementCoordinatesMappingLocal.h @@ -57,9 +57,7 @@ public: private: /// rotate points to local coordinates - void rotateToLocal( - const Element &e, const CoordinateSystem &coordinate_system, - const RotationMatrix &matR2local, std::vector<MeshLib::Node*> &vec_pt) const; + void rotateToLocal(const RotationMatrix &matR2local, std::vector<MeshLib::Node*> &vec_pt) const; /// get a rotation matrix to the global coordinates /// it computes R in x=R*x' where x is original coordinates and x' is local coordinates