Example #1
0
        /// <summary>
        /// 判断点是否在线段上
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public override bool PointIsOnCurveSegment(Point3D point)
        {
            PointLineRelationShipType type = GetPointRelationShip(point);

            if (type == PointLineRelationShipType.Point_On_Line)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// 判断传入的射线和当前线段位置关系(当前线段在射线的左、右...)
        /// </summary>
        /// <param name="line">传入的射线</param>
        /// <returns></returns>
        public override LineCurveRelationShipType GetCurveCurveRelationShipType(LineSegment line)
        {
            var dirStart = line.GetTurnDirection(this.GetStartPoint());
            var dirEnd   = line.GetTurnDirection(this.GetEndPoint());

            if (dirStart == TurnDirectionType.Stright && dirEnd == TurnDirectionType.Stright)
            {
                return(LineCurveRelationShipType.Coincide);
            }
            else if (dirStart == TurnDirectionType.Left && dirEnd == TurnDirectionType.Right ||
                     dirStart == TurnDirectionType.Right && dirEnd == TurnDirectionType.Left)
            {
                Point3D p = line.GetIntersect(this.BeginPoint, this.EndPoint);
                PointLineRelationShipType t = line.GetPointRelationShip(p);
                if (line != null && t == PointLineRelationShipType.Point_On_Line || t == PointLineRelationShipType.Point_On_Line_EndDir)
                {
                    return(LineCurveRelationShipType.Intersect);
                }
                else
                {
                    return(LineCurveRelationShipType.Others);
                }
            }
            else if (dirStart == TurnDirectionType.Left && dirEnd == TurnDirectionType.Left)
            {
                return(LineCurveRelationShipType.Left);
            }
            else if (dirStart == TurnDirectionType.Right && dirEnd == TurnDirectionType.Right)
            {
                return(LineCurveRelationShipType.Right);
            }
            else if (dirStart == TurnDirectionType.Stright && dirEnd == TurnDirectionType.Left ||
                     dirStart == TurnDirectionType.Left && dirEnd == TurnDirectionType.Stright)
            {
                return(LineCurveRelationShipType.On_Left);
            }
            else if (dirStart == TurnDirectionType.Stright && dirEnd == TurnDirectionType.Right ||
                     dirStart == TurnDirectionType.Right && dirEnd == TurnDirectionType.Stright)
            {
                return(LineCurveRelationShipType.On_Right);
            }
            return(LineCurveRelationShipType.Others);
        }
Example #3
0
        /// <summary>
        /// 根据直线段上的一点把线段截为两个子线段
        /// </summary>
        /// <param name="point">直线上用于截取的点</param>
        /// <returns>截取后的子线段,点不在直线上返回原始线段</returns>
        public override List <CurveSegment> CuteOutbyPoint(Point3D point)
        {
            PointLineRelationShipType relationShipType = this.GetPointRelationShip(point);

            if (relationShipType == PointLineRelationShipType.Point_On_Line)
            {
                List <CurveSegment> list = new List <CurveSegment>();
                list.Add(new LineSegment(this.BeginPoint, point));
                list.Add(new LineSegment(point, this.EndPoint));
                return(list);
            }
            else
            {
                return(new List <CurveSegment>()
                {
                    this
                });
            }
        }