private Arc CreateArc(XYZ PointStart, XYZ PointEnd, double radius, bool largeSagitta) { XYZ midPointChord = 0.5 * (PointStart + PointEnd); XYZ v = null; if (!(bool)this.GetArcRotationAntiClockWise()) { v = PointEnd - PointStart; } else { v = PointStart - PointEnd; } double d = 0.5 * v.GetLength(); // half chord length // Small and large circle sagitta: // http://www.mathopenref.com/sagitta.html double s = largeSagitta ? radius + Math.Sqrt(radius * radius - d * d) // sagitta large : radius - Math.Sqrt(radius * radius - d * d); // sagitta small var PX = Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI); var PX2 = v.Normalize(); var PX3 = v.Normalize().Multiply(s); XYZ midPointArc = midPointChord + Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI).OfVector(v.Normalize().Multiply(s)); return(Arc.Create(PointEnd, PointStart, midPointArc)); }
public static Arc CreateArcFromCircCurve(XYZ PointStart, XYZ PointEnd, double radius, bool largeSagitta) { PointStart = new XYZ(PointStart.X, PointStart.Z, 0); PointEnd = new XYZ(PointEnd.X, PointEnd.Z, 0); XYZ midPointChord = 0.5 * (PointStart + PointEnd); XYZ v = null; //if (!(bool)this.GetArcRotationAntiClockWise()) //{ // v = PointEnd - PointStart; //} //else //{ v = PointStart - PointEnd; //} //} double d = 0.5 * v.GetLength(); // half chord length // Small and large circle sagitta: // http://www.mathopenref.com/sagitta.html double s = largeSagitta ? radius + Math.Sqrt(radius * radius - d * d) // sagitta large : radius - Math.Sqrt(radius * radius - d * d); // sagitta small var PX = Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI); var PX2 = v.Normalize(); var PX3 = v.Normalize().Multiply(s); XYZ midPointArc = midPointChord + Transform.CreateRotation(XYZ.BasisZ, 0.5 * Math.PI).OfVector(v.Normalize().Multiply(s)); var PointARcEnd = new XYZ(PointEnd.X, PointEnd.Z, PointEnd.Y); var PointArcStart = new XYZ(PointStart.X, PointStart.Z, PointStart.Y); var PointArcMid = new XYZ(midPointArc.X, midPointArc.Z, midPointArc.Y); return(Arc.Create(PointARcEnd, PointArcStart, PointArcMid)); }