Last edited 9may05 by jpompe
Find this document at http://www.ncsa.uiuc.edu/Classes/MATH198/ivanhoe

Bezier Spline Wizard

Jeffrey Pompe

jpompe2@uiuc.edu

Math198 Hypergraphics, Spring 2005

Abstract

The project is an interactive program written in VPython that allows the user to select the number of control points they wish to place for a Bezier spline and after the end point is laid the spline is drawn between the 1st and last point and its shape governed by the control points.  The spline drawn is a basic Bezier Spline.  After the spline is drawn a key press will cause all of the points to move with random velocities and bounce around the box that they are inside.  As the points move the spline is redrawn to reflect the new position of the control points.

Bounce

The foundation of the program comes from the Bounce.py program and its various evolutions most heavily the bounce program in which multiple balls bounce inside a cube. The balls serve as the control points for the Spline Wizard program. The bounce program was modified so that the user selects the number of balls they wish to place (which serve as the control points) and then selects their position by mouseclicks. Random velocities were also added to make the movement more interesting.

Bezier Spline

The spline that is drawn between the points is a Bezier Spline. The spline connects the first point with the end point and curves towards the control points. The mathematical formula for this spline is as follows: where is a Bernstein polynomial which is given by . (http://mathworld.wolfram.com/BezierCurve.html). The spline is drawn by creating a line of spheres who’s position is governed by the equation for the Bezier Spline as controlled by the position of the control points. As each control point moves so do the position of the spheres in the spline thus making the spline move accordingly to how the control points move.

Screenshots

 The user first enters how many number of points they want to control the spline this included the start and end point. Therefore if the user enters 5 the spline will run from point 1 to 5 with 2,3,and 4 acting as control points. The user then clicks inside the box and where they click places the control point in a 3-d position. The first and last points are colored red and the control points are black
 The user can select as many control points as they want to create the spline. The image to the right shows the same spline from a different view point. The last two pictures are at different times as after the control points have been moving. As the points bounce around the box the spline moves as well according to the new positions of the control points.

Conclusion

The Spline Wizard works at creating the spline and fairly fluid movement for splines with a small number of control points (around 5), however it moves very slowly for larger number of control points due to the many number of calculations that must occur.  As I have little programming experience I am sure a much more efficient method of calculating the position of the spheres that make up the spline exists.  Also the method of drawing the spline by putting a number of spheres end to end is also a source of the visual discontinuity that occurs when the spline is stretched between many control points.  I unfortunately did not have time to fix this problem although I am sure it would be quite a simple task.  The VPython program also does not check to make sure the control points are placed inside the box so the user can accidentally place them outside of the box which still works for drawing the spline but causes the spline to extend out of the box in some cases as well as have erratic movement because of the bouncing off the walls of the ball outside of the walls.  These among other problems show that the program has some bugs that need to be worked out but the basic concept is shown by the program.  I originally wanted to work to be able to draw regular B-splines and eventually NURBS splines and perhaps will be able to accomplish this.  I believe I wrote the program in an object orientated way that would help facilitate the switch to the other types of splines by creating methods that calculate the appropriate weights needed for the more complex splines and then add these values to the general position calculation of the balls in the spline.

Many thanks to Professor Francis for helping inspire the project and help along the way, also to the rest of the Math 198 class for helping with various problems.