private static IArcEntity ByPointsOnCurveCore(Point firstPoint, Point secondPoint, Point 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 (GeometryExtension.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, "Arc.ByPointsOnCurve")); } return(entity); }
private static ILineEntity ByStartPointEndPointCore(Point startPt, Point endPt) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (endPt == null) { throw new ArgumentNullException("endPt"); } else if (startPt.Equals(endPt)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "end point")); } ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Line.ByStartPointEndPoint")); } return(entity); }
private static ICircleEntity By2PointsCore(Point firstPoint, Point secondPoint, ref Vector normal) { if (null == firstPoint) { throw new ArgumentNullException("firstPoint"); } if (null == secondPoint) { throw new ArgumentNullException("secondPoint"); } if (null == normal) { throw new ArgumentNullException("normal"); } if (firstPoint.Equals(secondPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint"); } if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal"); } var fptPos = firstPoint.PointEntity; var sptPos = secondPoint.PointEntity; var cptPos = HostFactory.Factory.CreatePoint((fptPos.X + sptPos.X) / 2.0, (fptPos.Y + sptPos.Y) / 2.0, (fptPos.Z + sptPos.Z) / 2.0); var centerPt = cptPos.ToPoint(false, null); var circleEntity = Circle.ByCenterPointRadiusCore(centerPt, cptPos.DistanceTo(fptPos), ref normal); if (circleEntity == null) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.By2Points")); } return(circleEntity); }
private static IArcEntity ByCenterPointStartPointSweepAngleCore(Point centerPoint, Point startPoint, double sweepAngle, ref Vector normal) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (startPoint == null) { throw new ArgumentNullException("startPoint"); } else if (normal == null) { throw new ArgumentNullException("normal"); } else if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal vector"), "normal"); } else if (centerPoint.Equals(startPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "center point", "start point"), "centerPoint, startPoint"); } else if (sweepAngle == 0.0) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroAngle, "sweep"), "sweepAngle"); } normal = normal.IsNormalized ? normal : normal.Normalize(); var entity = HostFactory.Factory.ArcByCenterPointStartPointSweepAngle(centerPoint.PointEntity, startPoint.PointEntity, GeometryExtension.DegreesToRadians(sweepAngle), normal.IVector); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "Arc.ByCenterPointStartPointSweepAngle")); } return(entity); }
private static ICircleEntity ByPointsOnCurveCore(Point firstPoint, Point secondPoint, Point 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, thirdPoint"); } else if (thirdPoint.Equals(firstPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "third point", "first point"), "thirdPoint, firstPoint"); } else if (GeometryExtension.ArePointsColinear(firstPoint, secondPoint, thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.PointsColinear, "first, second and thrid points"), "firstPoint, secondPoint, thirdPoint"); } /* Vector normal = null; var centerPt = Utils.GetCircumCenter(firstPoint, secondPoint, thirdPoint, out normal); if (centerPt == null || normal == null) { return null; } double rad = firstPoint.PointEntity.DistanceTo(centerPt.PointEntity); if( rad <= 0.0) { return null; } */ var entity = HostFactory.Factory.CircleByPointsOnCurve(firstPoint.PointEntity, secondPoint.PointEntity, thirdPoint.PointEntity); if (null == entity) throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.ByPointsOnCurve")); return entity; }
private static ICircleEntity By2PointsCore(Point firstPoint, Point secondPoint, ref Vector normal) { if (null == firstPoint) throw new ArgumentNullException("firstPoint"); if (null == secondPoint) throw new ArgumentNullException("secondPoint"); if (null == normal) throw new ArgumentNullException("normal"); if (firstPoint.Equals(secondPoint)) throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint"); if (normal.IsZeroVector()) throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal"); var fptPos = firstPoint.PointEntity; var sptPos = secondPoint.PointEntity; var cptPos = HostFactory.Factory.CreatePoint((fptPos.X + sptPos.X) / 2.0, (fptPos.Y + sptPos.Y) / 2.0, (fptPos.Z + sptPos.Z) / 2.0); var centerPt = cptPos.ToPoint(false, null); var circleEntity = Circle.ByCenterPointRadiusCore(centerPt, cptPos.DistanceTo(fptPos), ref normal); if (circleEntity == null) throw new Exception(string.Format(Properties.Resources.OperationFailed, "Circle.By2Points")); return circleEntity; }
private static ILineEntity ByStartPointEndPointCore(Point startPt, Point endPt) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (endPt == null) { throw new ArgumentNullException("endPt"); } else if (startPt.Equals(endPt)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "end point")); } ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Line.ByStartPointEndPoint")); return entity; }
private static IArcEntity ByPointsOnCurveCore(Point firstPoint, Point secondPoint, Point 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 (GeometryExtension.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, "Arc.ByPointsOnCurve")); return entity; }
private static IArcEntity ByCenterPointStartPointSweepPointCore(Point centerPoint, Point startPoint, Point sweepPoint) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (startPoint == null) { throw new ArgumentNullException("startPoint"); } else if (sweepPoint == null) { throw new ArgumentNullException("sweepPoint"); } else if (startPoint.Equals(sweepPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "sweep point"), "startPoint, sweepPoint"); } else if (startPoint.Equals(centerPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "center point"), "startPoint, centerPoint"); } var arcEntity = HostFactory.Factory.ArcByCenterPointStartPointSweepPoint(centerPoint.PointEntity, startPoint.PointEntity, sweepPoint.PointEntity); if (null == arcEntity) throw new Exception(string.Format(Properties.Resources.OperationFailed, "Arc.ByCenterPointStartPointSweepPoint")); return arcEntity; }
private static IArcEntity ByCenterPointStartPointSweepAngleCore(Point centerPoint, Point startPoint, double sweepAngle, ref Vector normal) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (startPoint == null) { throw new ArgumentNullException("startPoint"); } else if (normal == null) { throw new ArgumentNullException("normal"); } else if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal vector"), "normal"); } else if (centerPoint.Equals(startPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "center point", "start point"), "centerPoint, startPoint"); } else if (sweepAngle == 0.0) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroAngle, "sweep"), "sweepAngle"); } normal = normal.IsNormalized ? normal : normal.Normalize(); var entity = HostFactory.Factory.ArcByCenterPointStartPointSweepAngle(centerPoint.PointEntity, startPoint.PointEntity, GeometryExtension.DegreesToRadians(sweepAngle), normal.IVector); if (null == entity) throw new Exception(string.Format(Properties.Resources.OperationFailed, "Arc.ByCenterPointStartPointSweepAngle")); return entity; }