Outline
- Conic Sections
- Surfaces of Revolution
- Interpolation
- Catmull-Rom Splines
Introduction
- Last day, we discussed Bezier patches and how to join and subdivided them.
- Then we talked about how to draw Bezier curves and surfaces using the built-in functions in OpenGL.
- Finally, we reviewed homogeneous coordinates and defined rational Bezier Curves to be Bezier curves given in homogeneous coordinates.
- We gave some example uses of this, the last one that we started talking about in detail was on how to use points at infinity to define conic sections using rational Bezier curves.
- In particular, we were considering the points, `\vec p_0 = \langle 0, 1, 1 \rangle`, `\vec p_1 = \langle 1, 0, 0 \rangle`, and `\vec p_2 = \langle 0, -1, 1 \rangle` as homogeneous representations of points in `\mathbb R^2`. And we let `\vec q(u)` be the degree two Bezier curve given by these points. We claimed `\vec q(u)` traces out the right half of the circle `x^2 + y^2 = 1` as `u` varies from `0` to `1`.
Conic Sections
- To see the curve given by `\vec p_0, \vec p_1, \vec p_2` is in fact the right half circle, let's write out and expand `\vec q(u)` defined by these points:
`\vec q(u) = (1 - u)^2\langle 0, 1, 1\rangle + 2u(1-u)\langle 1, 0 , 0\rangle + u^2\langle 0, -1, 1 \rangle`
`=\langle 2u(1-u), (1-u)^2 - u^2 , (1-u)^2 +u^2 \rangle.`
- Re-expressing this as a point in `\mathbb{R}^2` gives
`\langle x(u), y(u) \rangle = \langle\frac{2u(1-u)}{(1-u)^2 +u^2}, \frac{(1-u)^2 - u^2}{(1-u)^2 +u^2}\rangle`
and one can verify that:
`x(u)^2 + y(u)^2 = ([2u(1-u)]^2 + [(1-u)^2 - u^2]^2)/ [(1-u)^2 + u^2]^2 = 1.`
- In this example, if we wanted a semi-circle the choice of `\vec p_0, \vec p_2` were forced on us. How could we have known to choose `\vec p_1` as we did?
- Since, the tangents to the semi-circle at the two end points are parallel, we knew we had to be dealing with a value of `\vec p_1` at infinity.
- The easiest way to find this value was then to try to use the control point `\langle h, 0, 0 \rangle`, carrying out the above proof and only fixing `h` to make the last equation work.
- Terms in the last equation would then have a factor of `h^2` in them, so to get this equal to 1 one would need `h^2 = 1`, giving `h = \pm 1`. It turns out choosing `h = -1` gives the left half of the circle; whereas, `h = 1` gives the right half.
More Conic Sections
- The result for circles we just had can be extended to finite connected portions of arbitrary conic sections.
- Let `\vec p_0` and `\vec p_2` be the two endpoints of such a curve `C`. Let `T_0` and `T_1` be the tangent lines to the conic section at these points and let `\vec p_1` be the point in homogeneous coordinates (with weight to be determined) of intersection of these tangents (which might be at infinity).
- One can show (see book) there is a choice of weight `w_1 \geq 0` to give `\vec p_1` in homogeneus coordinates such that the curve C is given by `\vec p_0`, `\vec p_1`, and `\vec p_2`
- It turns out the converse of this statement is also provable. Namely, let
`\vec q(u) = \langle x(u), y(u), z(u) \rangle` be a rational quadratic curve in `\mathbb{R}^2`. Then there is a conic section such that every point of `\vec q(u)` lies on the conic section.
Surfaces of Revolution
- One way to make a surface in 3D is to start with a Bezier curve in 3D and rotate it about some line.
- The points swept out as the curve rotates form a surface.
More Surfaces of Revolution
- In order to carry out a revolution of a rational Bezier curve, though, we first need to understand a little about rotations, translation, and scalings of such curves.
- Suppose we take our semi-circle we had before and we want to translate it to the point `\langle 4, 2\rangle`. What would the new control points be?
- Not much thought is needed to see that `\vec p_0` maps to `\vec p_0^* = \langle 4,3,1 \rangle` and `\vec p_2` maps to `\vec p_2^* = \langle 4,1,1 \rangle`, but what about the point `\vec p_1` at infinity?
- The correct answer is that it stays at `\vec p_1^* = \langle 1, 0, 0\rangle` which is still where the translated curve's tangent lines cross.
- If we work with matrices we can recall that in 2D-homogeneous coordinates a translation is given by:
`M = ((1, 0, x),(0, 1, y), (0, 0, 1)).`
- One can then check this gives the desired result for `x=4, y=2`.
- Similarly, one can show that a scaling corresponds to multiplying against a diagonal matrix with the scaling appearing on the diagonal and a rotation matrix is given by the 2x 2 rotation matrix for the x and y components and a 1 on the diagonal for the w component.
Homogeneous Transformations in 3D and Revolutions
- Using homogeneous coordinates to represent points in 3D, our translations, rotation, and scaling matrices become:
`M_(trans) = ((1, 0, 0, x),(0, 1, 0, y), (0, 0, 1, z), (0, 0, 0, 1)), M_(scal e) = ((r, 0, 0, 0),(0, r, 0, 0), (0, 0, r, 0), (0, 0, 0, 1)), and M_(z-rotate) = ((cos \theta, - sin \theta, 0, 0),( sin \theta, cos \theta, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))`
- Given these if we now want to make a Bezier Patch corresponding to a hemisphere, we start with our circle now in 3D and expressed in homogeneous coordinates.
- We first do degree elevation to make it a degree three curve.
- When we rotate this curve around the y-axis each of the four control point will trace out a semi-circle in the x-z plane.
- If the control point start at location (x, y, 0, 1), after a rotation of `\pi` around the y-axis it ends at (-x, y, 0, 1).
- We can make the semi-circle a control point traces out into a rational Bezier curve by again using a point at infinity, and do degree elevation on the result.
- If we do this for each starting control point we get the sixteen points that define a Bezier patch for a semi-sphere.
Interpolating with Bezier Curves
- It is quite common that one is given a set of points and is asked to come up with a nice curve that goes through those points.
- We next look at how to do such interpolations using Bezier curves.
- In this set up, we are often given a set of points `\vec p_0, \ldots, \vec p_m` and a set of "knot values" `u_0, \ldots, u_m` and we want a piecewise degree three Bezier curve `\vec q(u)` such that `\vec q(u_i) = \vec p_i` for each `i`.
- We will next look at a couple of different ways to make surch a curve, one is using Catmull-Rom splines, another is using Overhauser splines. One last common technique which we won't discuss is via tension-continuity-bias interpolation methods.
Catmull-Rom Splines
- Catmull-Rom Splines are used when the point `\vec p_i` are more or less evenly spaced.
- Rather than have `u` from the interval `[0, 1]` we consider larger intervals and assume `u_i = i`. So our goal is now that `\vec q(i) = \vec p_i` for each i.
- The Catmull-Rom spline will consist of `m-2` Bezier curves with the `i`th curve beginning at `\vec p_i` and ending at `\vec p_(i+1)`.
- To hook up the curves we need to make an estimate of the first derivatives of adjacent curves.
- Let `\vec L_i = \frac{1}{2}(\vec p_(i+1) - \vec p_(i-1))`
- Define `\vec p_i^+ = \vec p_i + \frac{1}{3}\vec L_i` and `\vec p_i^- = \vec p_i - \frac{1}{3}\vec L_i`
- Finally, let `\vec q_i(u)` be the Bezier curve translated to the domain `i \leq u \leq i+1` defined with control points `\vec p_i, \vec p_i^+, \vec p_i^-, \vec p_(i+1)`.
Properties of Catmull-Rom Splines
- From the definition of Catmull-Rom splines we will have that `\vec q(i) = p_i`
- Notice that if we calculate `\vec q'(i)` for `i > 0` using either the `i`th Bezier curve in the sequence or the the `i-1`st curve we get `\vec q'(i) = \vec L_i = (p_(i+1) - \vec p_(i-1))/2`.
- So the Catmull-Rom spline will be `C^1`-continous.
- Next day, we will look at Overhauser splines.