public DotEdit(LPoint3D point) { _point = point; InitializeComponent(); this.Loaded += DotEdit_Loaded; }
/// <summary> /// interpolation Qbezier /// </summary> public static LObject QBezierByStep(Point StartPoint, Point ControlPoint, Point EndPoint, double CRS) { LPoint3D LastPoint = new LPoint3D(StartPoint); double Lenth = 0; for (int t = 1; t < 100; t++) { LPoint3D tempPoint = GetPoint((double)t / 99); Lenth += LPoint3D.Lenth2D(LastPoint, tempPoint); LastPoint = tempPoint; } int CountStep = (int)(Lenth / (CRS)) >= 2 ? (int)(Lenth / CRS) : 2; LObject tempObj = new LObject(); for (int t = 0; t < CountStep; t++) { tempObj.Add(GetPoint((double)t / (CountStep - 1))); } return(tempObj); LPoint3D GetPoint(double t) { return(new LPoint3D( (1 - t) * (1 - t) * StartPoint.X + 2 * (1 - t) * t * ControlPoint.X + t * t * EndPoint.X, (1 - t) * (1 - t) * StartPoint.Y + 2 * (1 - t) * t * ControlPoint.Y + t * t * EndPoint.Y)); } }
/// <summary> /// interpolation bezier /// </summary> public static LObject BezieByStep(Point point0, Point point1, Point point2, Point point3, double CRS) { double Lenth = 0; LPoint3D LastPoint = new LPoint3D(point1); for (int t = 0; t < 100; t++) { LPoint3D tempPoint = GetPoint((double)t / 99); Lenth += LPoint3D.Lenth2D(LastPoint, tempPoint); LastPoint = tempPoint; } LObject tempObj = new LObject(); int CountStep = (int)(Lenth / CRS) >= 2 ? (int)(Lenth / CRS) : 2; for (int t = 0; t < CountStep; t++) { tempObj.Add(GetPoint((double)t / (CountStep - 1))); } return(tempObj); LPoint3D GetPoint(double t) { return(new LPoint3D( ((1 - t) * (1 - t) * (1 - t)) * point0.X + 3 * ((1 - t) * (1 - t)) * t * point1.X + 3 * (1 - t) * (t * t) * point2.X + (t * t * t) * point3.X, ((1 - t) * (1 - t) * (1 - t)) * point0.Y + 3 * ((1 - t) * (1 - t)) * t * point1.Y + 3 * (1 - t) * (t * t) * point2.Y + (t * t * t) * point3.Y, (byte)1)); } }