private static IArcEntity ByCenterPointRadiusAngleCore(DSPoint centerPoint, double radius, double startAngle, double sweepAngle, ref DSVector normal) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (normal == null) { throw new ArgumentNullException("normal"); } else if (radius <= 0.0) { throw new ArgumentException(string.Format(Properties.Resources.LessThanZero, "radius")); } else if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, normal), "normal"); } normal = normal.IsNormalized ? normal : normal.Normalize(); var endAngle = (startAngle + sweepAngle); IArcEntity entity = HostFactory.Factory.ArcByCenterPointRadiusAngle(centerPoint.PointEntity, radius, DSGeometryExtension.DegreesToRadians(startAngle), DSGeometryExtension.DegreesToRadians(endAngle), normal.IVector); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSArc.ByCenterPointRadiusAngle")); } return(entity); }
private DSArc(IArcEntity entity, bool persist = false) : base(entity, persist) { if (null != entity) { InitializeGuaranteedProperties(); } }
public void WriteObject(IArcEntity entity) { WriteEntity("CenterPoint", entity.CenterPoint); WriteDouble("Radius", entity.Radius); WriteDouble("StartAngle", entity.StartAngle); WriteDouble("SweepAngle", entity.SweepAngle); WriteEntity("Normal", entity.Normal); }
public string WriteEntity(IArcEntity arc, string paramName = null) { if (string.IsNullOrEmpty(paramName)) { paramName = string.Format("__arc_{0}", ++id); } string center = WriteEntity(arc.CenterPoint); string normal = WriteEntity(arc.Normal); mExpression.AppendFormat("{0} = Arc.ByCenterPointRadiusAngle({1}, {2}, {3}, {4}, {5});", paramName, center, arc.Radius, GeometryExtension.RadiansToDegrees(arc.StartAngle), GeometryExtension.RadiansToDegrees(arc.SweepAngle), normal); mExpression.AppendLine(); return(paramName); }
private static IArcEntity ByPointsOnCurveCore(DSPoint firstPoint, DSPoint secondPoint, DSPoint thirdPoint) { if (firstPoint == null) { throw new ArgumentNullException("firstPoint"); } else if (secondPoint == null) { throw new ArgumentNullException("secondPoint"); } else if (thirdPoint == null) { throw new ArgumentNullException("thirdPoint"); } else if (firstPoint.Equals(secondPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint"); } else if (secondPoint.Equals(thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "second point", "thrid point"), "secondPoint, thridPoint"); } else if (thirdPoint.Equals(firstPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "third point", "first point"), "thirdPoint, firstPoint"); } else if (DSGeometryExtension.ArePointsColinear(firstPoint, secondPoint, thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.PointsColinear, "first, second and thrid points"), "firstPoint, secondPoint, thridPoint"); } IArcEntity entity = HostFactory.Factory.ArcByPointsOnCurve(firstPoint.PointEntity, secondPoint.PointEntity, thirdPoint.PointEntity); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSArc.ByPointsOnCurve")); } return(entity); }