/// <summary> /// /// </summary> /// <param name="offset"></param> /// <param name="persist"></param> /// <returns></returns> internal Point Translate(Vector offset, bool persist) { if (offset == null) { throw new ArgumentNullException("direction"); } IPointEntity pthost = PointEntity.Add(offset); Point pt = pthost.ToPoint(persist, this); // setup backlinks pt.Direction = offset.Normalize(); pt.Distance = offset.Length; return(pt); }
/// <summary> /// /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <param name="offset"></param> /// <returns></returns> internal Point PointAtParametersCore(ref double u, ref double v, double offset) { bool uchange = GeometryExtension.ClipParamRange(ref u); bool vchange = GeometryExtension.ClipParamRange(ref v); // TO DO - throw a warning each time a condition above is satisfied. //throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "u or v parameter", "Surface.PointAtParameters")); IPointEntity pt = SurfaceEntity.PointAtParameter(u, v); if (!offset.EqualsTo(0.0)) { Vector normal = new Vector(SurfaceEntity.NormalAtPoint(pt)); Vector translation = normal.Normalize().Scale(offset); IPointEntity offsetPt = pt.Add(translation); pt.Dispose(); pt = offsetPt; } return(pt.ToPoint(true, this)); }
private static ILineEntity GetPerpBisector(Point startPt, Point endPt, IPlaneEntity planeOfCircle) { Vector dir = startPt.DirectionTo(endPt); dir = dir.Normalize(); IPointEntity midPt = HostFactory.Factory.CreatePoint((startPt.X + endPt.X) / 2, (startPt.Y + endPt.Y) / 2, (startPt.Z + endPt.Z) / 2); // get the perpendicular plane to plane of circle at mid point of segment[startPt, endPt] // IPlaneEntity perpPlane = HostFactory.Factory.PlaneByOriginNormal(midPt, dir.IVector); // this intersection results in line perp to segment[startPt, endPt] & plane normal // and happens to be the perpBisector of mentioned segment in planeOfCircle // ILineEntity perpBisector = planeOfCircle.IntersectWith(perpPlane); return(perpBisector); }
/// <summary> /// Internal utility method /// </summary> /// <param name="profile"></param> /// <param name="distance"></param> /// <param name="direction"></param> /// <returns></returns> internal static IBSplineSurfaceEntity[] ExtrudeAsBSplineSurfaces(this ICurveEntity profile, double distance, Vector direction) { if (null == profile || direction.IsZeroVector()) { return(null); } using (IPointEntity startPt = profile.PointAtParameter(0.5)) { Vector offset = direction.Normalize().Scale(distance); using (IPointEntity endPt = startPt.CopyAndTranslate(offset.IVector) as IPointEntity) { using (ILineEntity path = HostFactory.Factory.LineByStartPointEndPoint(startPt, endPt)) { using (ISurfaceEntity surf = HostFactory.Factory.SurfaceBySweep(profile, path)) { return(surf.ConvertToBSplineSurface()); } } } } }
private static IPlaneEntity ByOriginNormalCore(Point origin, ref Vector normal, double size) { if (origin == null) { throw new ArgumentNullException("origin"); } else if (normal == null) { throw new ArgumentNullException("normal"); } else if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, normal), "normal"); } normal = normal.IsNormalized ? normal : normal.Normalize(); IPlaneEntity entity = HostFactory.Factory.PlaneByOriginNormal(origin.PointEntity, normal.IVector); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "Plane.ByOriginNormal")); } return(entity); }
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); }