Instructor: Gershon Elber
T.A.: Haitham Fadila
Handed out: May 14th, 2023 Due date: June 5th, 2023
Develop an interactive graphics program that will compute and display Bezier and B-spline curves. Your program should allow the user to display the data (both the curve and its control polygon) and edit it. You are to provide methods to add, delete and modify the control points. The curves should be redrawn accordingly. You also should provide a way to change only the weight of a control point (a possible nice way, is by editing the radius of a circle around the control point, which represents the weight at the control point).
For B-spline curves, you should provide a graphical mechanism to edit the knot vector. The user should be able to specify the end conditions of a B-spline curve (open end or floating end conditions), as well as the degree of the curve to be created.
Note: The responsibility of the consistency between number of knots and number of control points for a given degree is of the user – therefore if a knot (or a control point) is added/removed, your program should not draw a curve until the user makes appropriate changes to resume consistency. However, if the knot vector has a special character – uniform float or uniform open end – you should automatically fix the knot vector if the control polygon is changed, such that the knot vector retains this special property.
You should be able to handle more than one curve at a time, and to connect two Bezier/B-spline curves with C0, C1, and G1 continuity into a single B-spline via modifications of the second curve only.
You should also implement one of the following additional options:
Your program should be able to read in data files in the following format: an integer specifying the order (= number of points if it is a Bezier curve), followed by a knot vector if a B-spline curve as knots[n] = k1, …, kn, followed by the control points themselves as pairs or triplets, specifying (x, y {, w}). Each control point will appear on a separate line. Blank lines should be skipped. Lines beginning with a pound sign, #, should be treated as comments. Comment lines may appear in the body of the data file. Here is an example:
# A cubic Bezier curve.
4
0.000000 -3.000000
2.000000 -1.000000
2.000000 1.000000
0.000000 3.000000
In the files in which w is specified, the given x and y coordinates are the original coordinates AFTER they have been multiplied by w. Display the rational circle example (circle.dat) so you can check that your code fits this convention (i.e the circle looks circular…). Note there can be multiple curves in a single file, having the curves one after the other.
Provide the capability to save your resulting data into a data file. You are also required to contribute one interesting data file of your own and this save capability will make it easier for you to create this data file.
There are sample data files here (Bezier) and here (B-Spline).
As always, we will schedule a time to grade the program with you.