diff Framework/Toolbox/CoordinateSystem3D.cpp @ 1013:53cc787bd7bc toa2019092301

- Added an optimized ProjectPoint2 to CoordinateSystem3D. It has *not* replaced the ProjectPoint method because more tests need to be written. - ProjectPointOntoPlane2 is a faster version of GeometryToolbox::ProjectPointOntoPlane. Same remark as above. - DicomStructureSet.cpp now uses this optimized call.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 23 Sep 2019 15:18:33 +0200
parents 1f74bc3459ba
children ac88989817e3
line wrap: on
line diff
--- a/Framework/Toolbox/CoordinateSystem3D.cpp	Fri Sep 20 13:59:36 2019 +0200
+++ b/Framework/Toolbox/CoordinateSystem3D.cpp	Mon Sep 23 15:18:33 2019 +0200
@@ -168,6 +168,19 @@
     return boost::numeric::ublas::inner_prod(point, normal_);
   }
 
+  void CoordinateSystem3D::ProjectPoint2(double& offsetX, double& offsetY, const Vector& point) const
+  {
+    // Project the point onto the slice
+    double projectionX,projectionY,projectionZ;
+    GeometryToolbox::ProjectPointOntoPlane2(projectionX, projectionY, projectionZ, point, normal_, origin_);
+
+    // As the axes are orthonormal vectors thanks to
+    // CheckAndComputeNormal(), the following dot products give the
+    // offset of the origin of the slice wrt. the origin of the
+    // reference plane https://en.wikipedia.org/wiki/Vector_projection
+    offsetX = axisX_[0] * (projectionX - origin_[0]) + axisX_[1] * (projectionY - origin_[1]) + axisX_[2] * (projectionZ - origin_[2]);
+    offsetY = axisY_[0] * (projectionX - origin_[0]) + axisY_[1] * (projectionY - origin_[1]) + axisY_[2] * (projectionZ - origin_[2]);
+  }
 
   void CoordinateSystem3D::ProjectPoint(double& offsetX,
                                         double& offsetY,