3 #include "curveTools.H"
5 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
12 scalar distance(const vector& p1, const vector& p2)
18 bool stepForwardsToNextPoint
29 while (++ip1n < Curve.size() && distance(o, Curve[ip1n]) < l);
34 if (ip1n < Curve.size() && in >= 0)
36 eoc = interpolate(Curve[in], Curve[ip1n], o, n, l);
46 bool stepBackwardsToNextPoint
57 while (--ip1n >= 0 && distance(o, Curve[ip1n]) < l);
62 if (ip1n >= 0 && in < Curve.size())
64 eoc = interpolate(Curve[in], Curve[ip1n], o, n, l);
85 scalar b = 2.0*(D&(p2 - o));
86 scalar c = magSqr(p2) + (o&(o - 2.0*p2)) - l*l;
88 scalar b2m4ac = b*b - 4.0*a*c;
92 scalar srb2m4ac = sqrt(b2m4ac);
94 scalar lamda = (-b - srb2m4ac)/(2.0*a);
96 if (lamda > 1.0+curveSmall || lamda < -curveSmall)
98 lamda = (-b + srb2m4ac)/(2.0*a);
101 if (lamda < 1.0+curveSmall && lamda > -curveSmall)
103 n = p2 + lamda*(p1 - p2);
120 bool XstepForwardsToNextPoint
131 while (++ip1n < Curve.size() && mag(o.x() - Curve[ip1n].x()) < l);
136 if (ip1n < Curve.size() && in >= 0)
138 eoc = Xinterpolate(Curve[in], Curve[ip1n], o, n, l);
160 if (p2.x() < o.x() + l - curveSmall && p2.x() > o.x() - l + curveSmall)
165 if (p2.x() < o.x() + l)
171 scalar lamda = (n.x() - p1.x())/D.x();
172 n.y() = p1.y() + lamda*D.y();
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 } // End namespace Foam
182 // ************************************************************************* //