Exemplo n.º 1
0
        public LineCircleX Intersect(
            Line2 line,
            ref double l0,
            ref double l1,
            ref double a0,
            ref double a1)
        {
            a0 = double.NaN;
            a1 = double.NaN;
            LineCircleX lineCircleX;

            switch (this.Intersect(line, ref l0, ref l1))
            {
            case LineCircleX.None:
                lineCircleX = LineCircleX.None;
                break;

            case LineCircleX.Tangent:
                a0          = this.ClosestPointTo(line.PointAt(l0));
                lineCircleX = LineCircleX.Tangent;
                break;

            case LineCircleX.Secant:
                a0          = this.ClosestPointTo(line.PointAt(l0));
                a1          = this.ClosestPointTo(line.PointAt(l1));
                lineCircleX = LineCircleX.Secant;
                break;

            default:
                lineCircleX = LineCircleX.None;
                break;
            }
            return(lineCircleX);
        }
Exemplo n.º 2
0
        public LineCircleX Intersect(Line2 line, ref double l0, ref double l1)
        {
            if (this.R <= 0.0)
            {
                throw new Exception("Invalid circle, zero or negative radius");
            }
            l0 = double.NaN;
            l1 = double.NaN;
            int         num1 = (int)this.Contains(line.Ax, line.Ay);
            int         num2 = (int)this.Contains(line.Bx, line.By);
            double      t    = line.ClosestPoint(this.O);
            Node2       pt   = line.PointAt(t);
            LineCircleX lineCircleX;

            switch (this.Contains(pt))
            {
            case Containment.coincident:
                l0          = t;
                l1          = l0;
                lineCircleX = LineCircleX.Tangent;
                break;

            case Containment.outside:
                lineCircleX = LineCircleX.None;
                break;

            default:
                double num3 = Math.Sqrt(this.R * this.R - pt.DistanceSquared(this.O)) / line.Length();
                l0          = t - num3;
                l1          = t + num3;
                lineCircleX = LineCircleX.Secant;
                break;
            }
            return(lineCircleX);
        }