comparison Framework/Toolbox/CoordinateSystem3D.cpp @ 151:c5044bbfc303 wasm

CoordinateSystem3D::IntersectSegment()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 01 Feb 2018 17:37:03 +0100
parents e2fe9352f240
children 2e023be0563c
comparison
equal deleted inserted replaced
150:62670cc2bb50 151:c5044bbfc303
166 // offset of the origin of the slice wrt. the origin of the 166 // offset of the origin of the slice wrt. the origin of the
167 // reference plane https://en.wikipedia.org/wiki/Vector_projection 167 // reference plane https://en.wikipedia.org/wiki/Vector_projection
168 offsetX = boost::numeric::ublas::inner_prod(axisX_, projection - origin_); 168 offsetX = boost::numeric::ublas::inner_prod(axisX_, projection - origin_);
169 offsetY = boost::numeric::ublas::inner_prod(axisY_, projection - origin_); 169 offsetY = boost::numeric::ublas::inner_prod(axisY_, projection - origin_);
170 } 170 }
171
172
173 bool CoordinateSystem3D::IntersectSegment(double& x,
174 double& y,
175 const Vector& edgeFrom,
176 const Vector& edgeTo) const
177 {
178 Vector p;
179 double d = -(normal_[0] * origin_[0] + normal_[1] * origin_[1] + normal_[2] * origin_[2]);
180 if (GeometryToolbox::IntersectPlaneAndSegment(p, normal_, d, edgeFrom, edgeTo))
181 {
182 ProjectPoint(x, y, p); // TODO could be optimized, as the point
183 // is on the plane by construction
184 return true;
185 }
186 else
187 {
188 return false;
189 }
190 }
171 } 191 }