Ejemplo n.º 1
0
        public static Point3d?GetOrthoNormalPoint(this Arc arc, Point3d point, bool nullForOutOfRange = true)
        {
            point = point.OrthoProject(arc.GetPlane());

            CircularArc3d  arc3d   = arc.ConvertToCircularArc();
            Vector3d       central = point - arc3d.Center;
            PointOnCurve3d pointOn = null;

            try
            {
                pointOn = arc3d.GetNormalPoint(point, Tolerance.Global);
            }
            catch (InvalidOperationException)
            {
                if (nullForOutOfRange)
                {
                    return(null);
                }
                else
                {
                    if ((point - arc3d.StartPoint).Length < (point - arc3d.EndPoint).Length)
                    {
                        return(arc3d.StartPoint);
                    }
                    else
                    {
                        return(arc3d.EndPoint);
                    }
                }
            }
            if (pointOn != null)
            {
                return(pointOn.Point);
            }



            return(null);
        }