mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#914 Added method to create rotation mx from two inplane vectors
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "cvfArrayWrapperConst.h"
|
||||
#include "cvfMatrix3.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -35,6 +36,7 @@ class GeometryTools
|
||||
{
|
||||
public:
|
||||
static cvf::Vec3d computeFaceCenter(const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2, const cvf::Vec3d& v3);
|
||||
static cvf::Mat3f computePlaneHorizontalRotationMx(const cvf::Vec3f& inPlaneVec0, const cvf::Vec3f& inPlaneVec1);
|
||||
|
||||
static cvf::Vec3d projectPointOnLine(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& p3, double* normalizedIntersection);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user