Example #1
0
        /// <summary>
        /// 获取两条线段重合部分
        /// </summary>
        /// <param name="line1">线段1</param>
        /// <param name="line2">线段2</param>
        /// <returns>重合部分</returns>
        public static Line Coincide(Line line1, Line line2)
        {
            LineSegment3d  l1 = new LineSegment3d(line1.StartPoint, line1.EndPoint);
            LineSegment3d  l2 = new LineSegment3d(line2.StartPoint, line2.EndPoint);
            LinearEntity3d l3 = l1.Overlap(l2);

            return(new Line(l3.StartPoint, l3.EndPoint));
        }
Example #2
0
        public static bool isSegmentsProjectionOverlapped(LineSegment3d lineseg1, LineSegment3d lineseg2)
        {
            Point3d projectPt1 = lineseg1.GetClosestPointTo(lineseg2.StartPoint).Point;
            Point3d projectPt2 = lineseg1.GetClosestPointTo(lineseg2.EndPoint).Point;

            // after the projection, the two line segments(p1->p2 & p3->p4) may be same
            if ((projectPt1.IsEqualTo(lineseg1.StartPoint) && projectPt2.IsEqualTo(lineseg1.EndPoint)) ||
                (projectPt1.IsEqualTo(lineseg1.EndPoint) && projectPt2.IsEqualTo(lineseg1.StartPoint)))
            {
                return(true);
            }

            // [Daniel] retrun null if no overlap???
            LineSegment3d  projectSeg2 = new LineSegment3d(projectPt1, projectPt2);
            LinearEntity3d overlap     = lineseg1.Overlap(projectSeg2);

            return(overlap != null);
        }