int Line::intersect(std::list<Kernel::V3D> &PntOut, const Cylinder &Cyl) const /** For the line that intersects the cylinder generate add the point to the VecOut, return number of points added. It does not check the points for validity. @param PntOut :: Vector of points found by the line/cylinder intersection @param Cyl :: Cylinder to intersect line with @return Number of points found by intersection */ { const Kernel::V3D Cent = Cyl.getCentre(); const Kernel::V3D Ax = Origin - Cent; const Kernel::V3D N = Cyl.getNormal(); const double R = Cyl.getRadius(); const double vDn = N.scalar_prod(Direct); const double vDA = N.scalar_prod(Ax); // First solve the equation of intersection double C[3]; C[0] = 1.0 - (vDn * vDn); C[1] = 2.0 * (Ax.scalar_prod(Direct) - vDA * vDn); C[2] = Ax.scalar_prod(Ax) - (R * R + vDA * vDA); std::pair<std::complex<double>, std::complex<double>> SQ; const int ix = solveQuadratic(C, SQ); // This takes the centre displacement into account: return lambdaPair(ix, SQ, PntOut); }