Point3dCollection ArcToVectors(CircularArc3d arc, int numSegments)
        {
            Interval interval   = arc.GetInterval();
            double   increment  = interval.Length / (double)numSegments;
            double   controller = interval.LowerBound;

            Point3dCollection points = new Point3dCollection();

            for (int i = 0; i < numSegments; ++i)
            {
                points.Add(arc.EvaluatePoint(controller));
                controller += increment;
            }

            points.Add(arc.EvaluatePoint(controller));

            return(points);
        }
示例#2
0
        // Arc
        public Arc ArcToSpeckle(CircularArc3d arc)
        {
            var interval = arc.GetInterval();
            var _arc     = new Arc(PlaneToSpeckle(arc.GetPlane()), arc.Radius, arc.StartAngle, arc.EndAngle, Math.Abs(arc.EndAngle - arc.StartAngle), ModelUnits);

            _arc.startPoint = PointToSpeckle(arc.StartPoint);
            _arc.endPoint   = PointToSpeckle(arc.EndPoint);
            _arc.midPoint   = PointToSpeckle(arc.EvaluatePoint((interval.UpperBound - interval.LowerBound) / 2));
            _arc.domain     = IntervalToSpeckle(arc.GetInterval());
            _arc.length     = arc.GetLength(arc.GetParameterOf(arc.StartPoint), arc.GetParameterOf(arc.EndPoint), tolerance);
            _arc.bbox       = BoxToSpeckle(arc.OrthoBoundBlock);
            return(_arc);
        }
        public static Arc CreateArcFromRadius(this Editor acCurEd, Point3d startPoint, Point3d endPoint, double radius)
        {
            Arc arc     = null;
            var ucsMat  = acCurEd.CurrentUserCoordinateSystem;
            var vNormal = ucsMat.CoordinateSystem3d.Zaxis;
            var pStart  = startPoint.TransformBy(ucsMat); // Start point in WCS
            var pEnd    = endPoint.TransformBy(ucsMat);   // End point in WCS
            //  Finding center point of arc.
            var circ1 = new CircularArc3d(pStart, vNormal, radius);
            var circ2 = new CircularArc3d(pEnd, vNormal, radius);
            var pts   = circ1.IntersectWith(circ2);

            circ1.Dispose();
            circ2.Dispose();

            try
            {
                if (pts.Length < 1)
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }

            var      pCenter = pts[0];
            Vector3d v1 = pStart - pCenter, v2 = pEnd - pCenter;

            if (v1.CrossProduct(v2).DotProduct(vNormal) < 0)
            {
                pCenter = pts[1];
            }
            var cCirc    = new CircularArc3d(pCenter, vNormal, radius);
            var parStart = cCirc.GetParameterOf(pStart);
            var parEnd   = cCirc.GetParameterOf(pEnd);
            var parMid   = (parStart + parEnd) * 0.5;
            var pMid     = cCirc.EvaluatePoint(parMid);

            cCirc.Dispose();
            var cArc  = new CircularArc3d(pStart, pMid, pEnd);
            var angle =
                cArc.ReferenceVector.AngleOnPlane(new Plane(cArc.Center, cArc.Normal));

            arc = new Arc(cArc.Center, cArc.Normal, cArc.Radius, cArc.StartAngle + angle, cArc.EndAngle + angle);
            cArc.Dispose();
            return(arc);
        }