01.14.08

Polar Form in 15 Minutes

Posted in Computer Graphics, Mathematics tagged , , , at 5:22 pm by Eon Strife

B-Spline as a tool to draw a complex shape is pretty popular but unfortunately it’s a bit complicated (Check this Wikipedia article and the links inside it first if you’re not acquainted with B-Spline yet.) . Dr. L. Ramshaw introduced the Polar Form to simplify the understanding and the computation of B-Spline.

In short, every control point (or de Boor point) is given a number of values (we can think of them as a label for the point) which are taken from the knot vector. The number of values assigned to each point depends on the degree of the B-Spline, if it’s a cubic B-Spline, then each point is assigned three values. For example, if the knot vector of a B-Spline curve is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, then the polar values for the first point P0 is (1, 2, 3) (note : it always starts at the second element of knot vector), for the second point P1 is (2, 3, 4), the third point P2 is (3, 4, 5), and so on until the last point P5 (6, 7, 8 ) (note : the last element of the knot vector is excluded). The nice thing about this labeling is that the positions of the values of each point are not fixed and can be changed without changing the spatial position of the point in the space. For example, P0(1, 2, 3) is just the same as P0(2, 3, 1).

Given these points with their own polar values we can compute the spatial coordinate of another point as long as there are two points which have same number of degree-1 polar values with each other and with the new point. For example in degree 4, we can compute P(2, 3, 4, 5) if we already have two existing points which have polar values P(x, 3, 4, 5) or P(2, x, 4, 5), or P(2, 3, x, 5), or P(2, 3, 4, x). As for another example from the previous paragraph, we can compute P(3, 3.5, 4) by using P(2, 3, 4) and P(3, 4, 5). The formula for the computation is (parameter u(s) are the values shared by the three points) :

formula.jpg

Sometimes we can’t calculate a point directly and we have to calculate the intermediate points first. For example, if we want to find P(4, 4, 4) we have to compute P(3, 4, 4) and P(4, 4, 5). P(3, 4, 4) can be computed using P(2, 3, 4) and P(3, 4, 5), and P(4, 4, 5) can be computed using P(4, 5, 6). It’s as if we choose the sequence of operations arbitrary, and it will become more difficult in higher degree, which will be somehow impossible for computer to do it.

There’s a systematic way to do the process (and because of that it’s possible to program it into computer). The way to do it is pretty simple, we start from the desired point, and in each iteration we recursively compute two points which are needed to compute the particular point. The way to determine the two points is just to remove one duplicate element (if there are no duplicates anymore, we remove the one which is not in the knot vector) and replace it with the immediate lower value in the knot vector(for the first point used) or higher value in the knot vector(for the second point used). For example, if we have a five degree B-Spline with the knot vector {…, 0, 1, 2, 3, 4, 6, 7, 8, 10, 12, 14, …} and we want to compute P(6, 6, 6, 6, 6), we can do this sequence of operations, starting from the top to bottom :

untitled2.jpg

Now we know how to compute using Polar Form, the rest is easy. To draw a B-Spline we do the iteration over the knot vector. Using the aforementioned cubic B-Spline, for if example if we want to compute the point on the curve just say on t = 3.5, we assign the point with polar values P(3.5, 3.5, 3.5) (duplicates the t degree times) and compute it.

To learn more about polar form and the formal explanation of the polar form, you may check this paper (An Introduction to Polar Forms).

Leave a Comment

You must be logged in to post a comment.