#914 Added method to create rotation mx from two inplane vectors

This commit is contained in:
Jacob Støren
2016-10-19 12:06:27 +02:00
parent 522ae9998f
commit d82eb6a774
2 changed files with 31 additions and 0 deletions

View File

@@ -38,6 +38,35 @@ cvf::Vec3d GeometryTools::computeFaceCenter(const cvf::Vec3d& v0, const cvf::Vec
return centerCoord;
}
//--------------------------------------------------------------------------------------------------
/// Ez = Plane normal, Ex = in XY plane (horizontal), Ey = semi vertical
//--------------------------------------------------------------------------------------------------
cvf::Mat3f GeometryTools::computePlaneHorizontalRotationMx(const cvf::Vec3f& inPlaneVec0, const cvf::Vec3f& inPlaneVec1)
{
cvf::Vec3f Ez = inPlaneVec0 ^ inPlaneVec1;
if (!Ez.normalize()) return cvf::Mat3f::IDENTITY;
cvf::Vec3f Ex = Ez ^ cvf::Vec3f::Z_AXIS;
if (!Ex.normalize()) return cvf::Mat3f::IDENTITY;
cvf::Vec3f Ey = Ez ^ Ex;
if(Ey[2] < 0.0f) // Semi vertical is down
{
return cvf::Mat3f(-Ex[0], -Ey[0], Ez[0],
-Ex[1], -Ey[1], Ez[1],
-Ex[2], -Ey[2], Ez[2]);
}
else
{
return cvf::Mat3f(Ex[0], Ey[0], Ez[0],
Ex[1], Ey[1], Ez[1],
Ex[2], Ey[2], Ez[2]);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------