pre-proto - Adding function for getting the transformMatrix of polygon

This commit is contained in:
astridkbjorke 2017-01-12 10:52:47 +01:00
parent 44aefe6ed7
commit 86d98cb55b
2 changed files with 25 additions and 12 deletions

View File

@ -105,19 +105,9 @@ void RimFracture::computeGeometry()
float b = fractureDef->halfLength;
tesselator.tesselateEllipsis(a, b, &polygonIndices, &nodeCoords);
}
// Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y
cvf::Mat4f rotationFromTesselator = cvf::Mat4f::fromRotation(cvf::Vec3f::X_AXIS, cvf::Math::toRadians(90.0f));
// Azimuth rotation
cvf::Mat4f azimuthRotation = cvf::Mat4f::fromRotation(cvf::Vec3f::Z_AXIS, cvf::Math::toRadians(-azimuth()));
cvf::Mat4f m = azimuthRotation * rotationFromTesselator;
m.setTranslation(cvf::Vec3f(center));
//Denne matrisa bør ut i egen funksjon for å brukes andre steder også...
cvf::Mat4f m = transformMatrix();
for (cvf::Vec3f& v : nodeCoords)
{
@ -129,6 +119,27 @@ void RimFracture::computeGeometry()
m_recomputeGeometry = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Mat4f RimFracture::transformMatrix()
{
cvf::Vec3d center = centerPointForFracture();
// Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y
cvf::Mat4f rotationFromTesselator = cvf::Mat4f::fromRotation(cvf::Vec3f::X_AXIS, cvf::Math::toRadians(90.0f));
// Azimuth rotation
cvf::Mat4f azimuthRotation = cvf::Mat4f::fromRotation(cvf::Vec3f::Z_AXIS, cvf::Math::toRadians(-azimuth()));
cvf::Mat4f m = azimuthRotation * rotationFromTesselator;
m.setTranslation(cvf::Vec3f(center));
return m;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -25,6 +25,7 @@
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfMatrix4.h"
class RimFractureEllipseDefinition;
@ -45,7 +46,8 @@ public:
caf::PdmField<double> azimuth;
virtual cvf::Vec3d centerPointForFracture() = 0;
// virtual cvf::Mat4d transformMatrix() = 0; TODO: add such method
cvf::Mat4f transformMatrix();
virtual RimFractureEllipseDefinition* attachedFractureDefinition() = 0;
cvf::ref<RigFracture> attachedRigFracture();