Beispiel #1
0
int Line::intersect(std::list<Kernel::V3D> &PntOut, const Sphere &Sph) 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/sphere intersection
@param Sph :: Sphere to intersect line with
@return Number of points found by intersection
*/
{
    // Nasty stripping of useful stuff from sphere
    const Kernel::V3D Ax = Origin - Sph.getCentre();
    const double R = Sph.getRadius();
    // First solve the equation of intersection
    double C[3];
    C[0] = 1;
    C[1] = 2.0 * Ax.scalar_prod(Direct);
    C[2] = Ax.scalar_prod(Ax) - R * R;
    std::pair<std::complex<double>, std::complex<double>> SQ;
    const int ix = solveQuadratic(C, SQ);
    return lambdaPair(ix, SQ, PntOut);
}