Implementation of de Casteljau algorithm for drawing Bezier curves of degree n and the surface of revolution of the drawn curve.
Course Assignment for IS F311- Computer Graphics @ BITS Pilani, Hyderabad Campus.
Done under the guidance of Prof. Tathagata Ray, Associate Professor, BITS Pilani, Hyderabad Campus.
Table of contents generated with markdown-toc
Run the following commands to launch the curve drawing interface:
g++ *.cpp -lglfw -pthread -lGLEW -lGLU -lGL
./a.out
Control | Action |
---|---|
LMB | Add point (in add mode)/ Move points (in move mode) |
RMB | Delete point |
M | Toggle Move mode |
A | Togle Add mode |
Space | Write OFF file to disk |
A Bezier curve is a parametric curve frequently used in computer graphics and related fields. Bezier curves are completely contained within the convex hull formed by the control points. The blending functions of Bezier curves are Bernstein polynomials which are of the form-
The Bezier curve has the equation-
De Casteljau's algorithm is a recursive method to evaluate polynomials in Bernstein form or Bézier curves.
1. q0 = Lerp(t, p0, p1), q1 = Lerp(t, p1, p2), q2 = Lerp(t, p2, p3)
2. r0 = Lerp(t, q0, q1), r1 = Lerp(t, q1, q2)
When the above steps are repeated across a large no. of values of t between 0 and 1, the following curve results.
Our program has the following features:
- An interactive GUI to plot points. The resulting bezier curve from the points is generated and displayed in real-time.
- The ability to move and remove plotted points.
- The curve is rotated about y-axis to generate the surface of rotation. The resulting surface is stored in OFF format and can be viewed using software such as MeshLab, noesis, etc.