Fault activation: node adjustments along fault (#11235)

Make sure same thickness vectors and fault lines are used for both parts.
This commit is contained in:
jonjenssen
2024-02-27 17:05:48 +01:00
committed by GitHub
parent a0ecdf47a5
commit 86c33c1b46
8 changed files with 109 additions and 38 deletions

View File

@@ -56,6 +56,8 @@ public:
Line findLineBetweenNearestPoints( const Line& otherLine, bool* withinLineSegments = nullptr );
cvf::Vector3<S> closestPointOnLine( const cvf::Vector3<S>& point ) const;
private:
cvf::Vector3<S> m_start;
cvf::Vector3<S> m_end;

View File

@@ -105,3 +105,27 @@ caf::Line<S> caf::Line<S>::findLineBetweenNearestPoints( const Line& otherLine,
}
return Line( start() + s * d1, otherLine.start() + t * d2 );
}
//--------------------------------------------------------------------------------------------------
/// Returns the closest point on the line segment to the given point
/// From https://paulbourke.net/geometry/pointlineplane/
//--------------------------------------------------------------------------------------------------
template <typename S>
cvf::Vector3<S> caf::Line<S>::closestPointOnLine( const cvf::Vector3<S>& point ) const
{
S distance = vector().length();
const double u = ( ( ( point.x() - start().x() ) * ( end().x() - start().x() ) ) +
( ( point.y() - start().y() ) * ( end().y() - start().y() ) ) +
( ( point.z() - start().z() ) * ( end().z() - start().z() ) ) ) /
( distance * distance );
if ( u < 0.0 ) return start();
if ( u > 1.0 ) return end();
cvf::Vector3<S> projectedPoint( ( start().x() + u * ( end().x() - start().x() ) ),
( start().y() + u * ( end().y() - start().y() ) ),
( start().z() + u * ( end().z() - start().z() ) ) );
return projectedPoint;
}