|
I wrote a class to represent a Bezier Surface. I read the input control points from a text file into this class (one instance per patch). When rendering the class will create n traces in s and t. In each trace 10*n line segments are used to give a smooth appearance. At the intersections of traces in s and t normal points are calculated as offset points from the sample points in the normal direction. The normals are calculated by taking the partial derivate in s and in t and then forming the cross product. The normals can be turned on and off by pressing the 'n' key. The partial derivative in s is calculated by replacing the vector [s^3 s^2 s 1] with [3s^2 2s 1 0] and likewise for t. Here are the screenshots: Large number of lines per patch: Few lines per patch:
Normals in pink at intersection points of patch lines. |