comparison 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
comparison
equal deleted inserted replaced
1012:050f01d7951b 1013:53cc787bd7bc
166 double CoordinateSystem3D::ProjectAlongNormal(const Vector& point) const 166 double CoordinateSystem3D::ProjectAlongNormal(const Vector& point) const
167 { 167 {
168 return boost::numeric::ublas::inner_prod(point, normal_); 168 return boost::numeric::ublas::inner_prod(point, normal_);
169 } 169 }
170 170
171 void CoordinateSystem3D::ProjectPoint2(double& offsetX, double& offsetY, const Vector& point) const
172 {
173 // Project the point onto the slice
174 double projectionX,projectionY,projectionZ;
175 GeometryToolbox::ProjectPointOntoPlane2(projectionX, projectionY, projectionZ, point, normal_, origin_);
176
177 // As the axes are orthonormal vectors thanks to
178 // CheckAndComputeNormal(), the following dot products give the
179 // offset of the origin of the slice wrt. the origin of the
180 // reference plane https://en.wikipedia.org/wiki/Vector_projection
181 offsetX = axisX_[0] * (projectionX - origin_[0]) + axisX_[1] * (projectionY - origin_[1]) + axisX_[2] * (projectionZ - origin_[2]);
182 offsetY = axisY_[0] * (projectionX - origin_[0]) + axisY_[1] * (projectionY - origin_[1]) + axisY_[2] * (projectionZ - origin_[2]);
183 }
171 184
172 void CoordinateSystem3D::ProjectPoint(double& offsetX, 185 void CoordinateSystem3D::ProjectPoint(double& offsetX,
173 double& offsetY, 186 double& offsetY,
174 const Vector& point) const 187 const Vector& point) const
175 { 188 {