public Window() { InitializeComponent(); string[] fileLines = File.ReadAllLines(@"points"); for (int i = 5; i < fileLines.Length; i++) { string[] coordinates = fileLines[i].Split(';'); BSplineControlPoints.Add( new Point2D(ParseFloat(coordinates[0]), ParseFloat(coordinates[1]), Color.Coral, panel1) ); } BSplineCurve = new BSpline(BSplineControlPoints[0], BSplineControlPoints[1], BSplineControlPoints[2], BSplineControlPoints[3], BSplineControlPoints[4], BSplineControlPoints[5], Color.OrangeRed); for (int i = 0; i < 5; i++) { string[] coordinates = fileLines[i].Split(';'); BezierControlPoints.Add( new Point2D(ParseFloat(coordinates[0]), ParseFloat(coordinates[1]), Color.BlueViolet, panel1) ); } BezierCurve = new Bezier(BezierControlPoints[0], BezierControlPoints[1], BezierControlPoints[2], BezierControlPoints[3], BezierControlPoints[4], Color.Blue); panel1.Paint += new PaintEventHandler(panel1_Paint); button1.Click += (s, e) => { C0(); panel1.Invalidate(); }; button2.Click += (s, e) => { G1(); panel1.Invalidate(); }; button3.Click += (s, e) => { C1(); panel1.Invalidate(); }; button4.Click += (s, e) => { G2(); panel1.Invalidate(); }; button5.Click += (s, e) => { C2(); panel1.Invalidate(); }; chBox.Click += (s, e) => { ShowControlPoints = !ShowControlPoints; foreach (Point2D p in BSplineControlPoints) { p.Active = !p.Active; } foreach (Point2D p in BezierControlPoints) { p.Active = !p.Active; } panel1.Invalidate(); }; panel1.MouseWheel += MouseWheelEvent; panel1.MouseDown += (s, e) => { if (panel1.Dragging) { return; } DraggingPanel = true; MouseLocation = e.Location; }; panel1.MouseMove += (s, e) => { if (!DraggingPanel) { return; } PointF newMousePos = e.Location; foreach (Point2D p in BSplineControlPoints) { p.Location.X += newMousePos.X - MouseLocation.X; p.Location.Y += newMousePos.Y - MouseLocation.Y; } foreach (Point2D p in BezierControlPoints) { p.Location.X += newMousePos.X - MouseLocation.X; p.Location.Y += newMousePos.Y - MouseLocation.Y; } MouseLocation = newMousePos; panel1.Invalidate(); }; panel1.MouseUp += (s, e) => { DraggingPanel = false; }; }
public static CurvePoint[] GetCurvePoints(int resolution, Vector3[] controlPoints) { var curve = new Bezier(resolution, controlPoints); return curve.GetCurvePoints(); }
public static CurvePoint[] GetCurvePoints(int resolution, Vector3[] controlPoints) { var curve = new Bezier(resolution, controlPoints); return(curve.GetCurvePoints()); }
public static Vector3[] GetCurvePositions(int resolution, Vector3[] controlPoints) { var bezier = new Bezier(resolution, controlPoints); return GetCurvePositions(bezier, resolution, controlPoints); }
public static Vector3[] GetCurvePositions(int resolution, Vector3[] controlPoints) { var bezier = new Bezier(resolution, controlPoints); return(GetCurvePositions(bezier, resolution, controlPoints)); }