예제 #1
0
/*!

 */
int
Circle2D::intersection( const Ray2D & ray,
                        Vector2D * sol1,
                        Vector2D * sol2 ) const
{
    Line2D line( ray.origin(), ray.dir() );
    Vector2D tsol1, tsol2;

    int n_sol = intersection( line, &tsol1, &tsol2 );

    if ( n_sol > 1
         && ! ray.inRightDir( tsol2, 1.0 ) )
    {
        --n_sol;
    }

    if ( n_sol > 0
         && ! ray.inRightDir( tsol1, 1.0 ) )
    {
        tsol1 = tsol2; // substituted by second solution
        --n_sol;
    }

    if ( n_sol > 0 && sol1 )
    {
        *sol1 = tsol1;
    }

    if ( n_sol > 1 && sol2 )
    {
        *sol2 = tsol2;
    }

    return n_sol;
}