PsrFunctionResult ComputePlaneLineIntersectPoint( const PsrPoint &pointOfPlane,
const PsrVector3D &normalOfPlane,
const PsrPoint &pointOfLine,
const PsrVector3D &directionOfLine,
PsrPoint &intersectPoint)
{
PsrLOG_FUNC_TRACE();
/*
case1: centerline need to be extend.
Plane is decided by the lumen's endpoint and tangent of centerline's endpoint.
Line is decided by the centerline's endpoint and tangent of centerline's endpoint.
case2: lumen or wall need to be extend.
Plane is decided by the sliceInfo's normal and center.
Line is decided by the lumen or wall's endpoint and tangent of centerline's endpoint.
input:
pointOfPlane: the point in the plane. (n1,n2,n3)
normalOfPlane: the normal vector of the plane. (vp1, vp2, vp3)
pointOfLine: the point of the line. (m1, m2, m3)
directionOfLine: the direction vector of the plane. (v1, v2, v3).
output:
intersectPoint: the intersectPoint.
equation of line:
x = m1+v1*t;
y = m2+v2*t;
z = m3+v3*t;
equation of plane:
vp1*(x-n1)+vp2*(y-n2)+vp3*(z-n3)=0;
so: t = ((n1-m1)*vp1 + (n2-m2)*vp2 + (n3-m3)*vp3)/(vp1*v1+vp2*v2+vp3*v3).
if: vp1*v1+vp2*v2+vp3*v3 ==0, no intersecPoint.
intersecPoint:
intersecPoint.x = m1+v1*t;
intersecPoint.y = m2+v2*t;
intersecPoint.z = m3+v3*t;
*/
PsrVector3D pointOfPlaneSource(pointOfPlane);
PsrVector3D pointOfLineSource(pointOfLine);
PsrVector3D intersectPointSource;
//factor = vp1*v1+vp2*v2+vp3*v3. if factor==0, there is no crosspoint.
double factor = normalOfPlane.Dot(directionOfLine);
if (factor == 0)
{
return PsrFunctionResult(SUCCESS_NO_CROSSPOINT);
}
else
{
double factorOfLine; // factorOfLine is the factor "t" of equation line.
// t = (pointOfPlane-pointOfLine).(normalOfPlane)/factor.
factorOfLine = pointOfPlaneSource.Substract(pointOfLineSource).Dot(normalOfPlane)/factor;
// intersecPoint = pointOfLine + (directionOfLine * factorOfLine).
intersectPointSource = pointOfLineSource.Add(directionOfLine.Scalar(factorOfLine));
intersectPoint.SetPoint(intersectPointSource.X(),intersectPointSource.Y(),intersectPointSource.Z());
return PsrFunctionResult::ReturnOK();
}
}
09-23
3781
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交