コード例 #1
0
ファイル: CircleHullPart.cs プロジェクト: sungaoyong/ProSuite
        public bool Cut(HullLineLine line, ref double tMin, ref double tMax)
        {
            // Handle start point of endPart
            Pnt   lS         = line.EndPart.Ps;
            Lin2D s          = line.Lin.GetParallel(lS);
            bool  intersects = CutLineThis(s.Ps, s.L, ref tMin, ref tMax);

            // Handle end point of endPart
            Pnt   lE = line.EndPart.Pe;
            Lin2D e  = line.Lin.GetParallel(lE);

            intersects |= CutLineThis(e.Ps, e.L, ref tMin, ref tMax);

            if (Angle.HasValue)
            {
                double r = _radius;
                // Handle start point of arc
                double angS = StartDirection;
                Pnt    aS   = new Pnt2D(r * Math.Cos(angS), r * Math.Sin(angS)) + _center - lS;
                Lin2D  eS   = line.EndPart.GetParallel(aS);
                intersects |= LineHullPart.CutLin(eS, e, ref tMin, ref tMax);

                // Handle end point of arc
                double angE = StartDirection + Angle.Value;
                Pnt    aE   = new Pnt2D(r * Math.Cos(angE), r * Math.Sin(angE)) + _center - lS;
                Lin2D  eE   = line.EndPart.GetParallel(aE);
                intersects |= LineHullPart.CutLin(eE, e, ref tMin, ref tMax);
            }

            // Handle tangents
            Pnt    eNormal = line.EndPart.LNormal;
            double dir     = Angle.HasValue
                                             ? Math.Atan2(eNormal.Y, eNormal.X)
                                             : double.NaN;

            if (!Angle.HasValue || IsInArcAngle(dir))
            {
                Lin2D eT0 = line.EndPart.GetParallel(_center + _radius * eNormal - lS);
                intersects |= LineHullPart.CutLin(eT0, e, ref tMin, ref tMax);
            }

            if (!Angle.HasValue || IsInArcAngle(dir + Math.PI))
            {
                Lin2D eT1 = line.EndPart.GetParallel(_center - _radius * eNormal - lS);
                intersects |= LineHullPart.CutLin(eT1, e, ref tMin, ref tMax);
            }

            return(intersects);
        }
コード例 #2
0
ファイル: LineHullPart.cs プロジェクト: sungaoyong/ProSuite
        public bool Cut(HullLineLine line, ref double tMin, ref double tMax)
        {
            Lin2D s          = line.Lin.GetParallel(line.EndPart.Ps);
            bool  intersects = CutLin(_lin, s, ref tMin, ref tMax);

            Lin2D e = line.Lin.GetParallel(line.EndPart.Pe);

            intersects |= CutLin(_lin, e, ref tMin, ref tMax);

            var thisAtStart = new Lin2D(_lin.Ps, _lin.Ps + line.EndPart.L);

            intersects |= CutLin(thisAtStart, e, ref tMin, ref tMax);

            var thisAtEnd = new Lin2D(_lin.Pe, _lin.Pe + line.EndPart.L);

            intersects |= CutLin(thisAtEnd, e, ref tMin, ref tMax);

            return(intersects);
        }