Transcript PowerPoint

CS 551/645
Fall 2000
Splines
Assignment 3 part 2
• How to combine many textures into one large texture
– You might want to combine textures in one image
– ~dcb8j/Gfx/Tools/bin/assemble
• Just type ‘assemble’ with no arguments for instructions
• You specify the number of images to combine in height and width
and it creates one image from them
• Note, image type must be SGI’s sgi format (also called rgb)
• ~dcb8j/Gfx/Tools/bin/addframe
– Just type ‘addframe’ without arguments for instructions
– Adds a border of pixels to an image
• You chose the pixel color
Axis-angle Rotation
Given
r – Vector in space to rotate
n – Axis in space about which to rotate
q – The amount about n to rotate
Solve
r’ – The rotated vector
n r
r’
Axis-angle Rotation
• Step 1
– Compute rk an extended version of the rotation
axis, n
– rk = (n ¢ r) r
rk
r’
r
Axis-angle Rotation
• Compute r?
• r? = r – (n ¢ r) n
r? r’
r
Axis-angle Rotation
• Compute v, a vector perpendicular to n and r?
• v = n £ r?
• Use v and r? and q to compute r’
v
cos(q) r? + sin(q) v
q
r?
Parametric Curves
• Very flexible representation
• They are not required to be functions
– They can be multivalued with respect to any
dimension
• Decouples dimension of object
from dimension of space
Specifying Curves
• Control Points
– A set of points that influence the
curve’s shape
• Knots
– Control points that lie on the curve
• Interpolating Splines
– Curves that pass through the control
points (knots)
• Approximating Splines
– Control points merely influence shape
Piecewise Curve Segments
• One curve constructed by connecting many
smaller segments end-to-end
• Continuity describes the joint
Parametric Cubic Curves
• In order to assure C2 continuity, curves must
be of at least degree 3
• Here is the parametric definition of a spline
in two dimensions
Parametric Cubic Splines
• Can represent this as a matrix too
Coefficients
• So how do we select the coefficients?
– [ax bx cx dx] and [ay by cy dy] must satisfy the
constraints defined by the knots and the
continuity conditions
Hermite Cubic Splines
• An example of knot and continuity
constraints
Spline Derivatives
• How do we control spline derivatives?
Hermite Specification
• Matrix equation for Hermite Curve
t3
t2
t1
t0
p1
t=0
p2
t=1
r p1
t=0
r p2
t=1
Solve Hermite Matrix
Spline and Geometry Matrices
Resulting Hermite Spline
Equation
Demonstration
• http://graphics.lcs.mit.edu/classes/6.837/F9
8/Lecture9/Slide15.html
Sample Hermite Curves
Blending Functions
• By multiplying first two components, you
have four functions of ‘t’ that blend the four
control parameters
Hermite Blending Functions
• If you plot the
blending
functions on
the parameter
‘t’
Bézier Curves
• Similar to Hermite, but more intuitive
definition of endpoint derivatives
• Four control points, two of which are knots
Bézier Curves
• The derivative values of the Bezier Curve at
the knots are dependent on the adjacent points
• The scalar 3 was selected just for this curve
Bézier vs. Hermite
• We can write our Bezier in terms of Hermite
– Note this is just matrix form of previous equations
Bézier vs. Hermite
• Now substitute this in for previous Hermite
Bézier Basis and Geometry
Matrices
• Matrix Form
• But why is MBezier a good basis matrix?
Bézier Blending Functions
• Look at the blending
functions
• This family of
polynomials is called
order-3 Bernstein
Polynomials
– They are all positive in interval [0,1]
– Their sum is equal to 1
Bézier Blending Functions
• Thus, every point on curve
is linear combination of the
control points
• The weights of the
combination are all positive
• The sum of the weights is 1
• Therefore, the curve is a
convex combination of the
control points
Bézier Curves
• Will always remain within bounding region
defined by control points
• http://graphics.lcs.mit.edu/classes/6.837/F9
8/Lecture9/Slide24.html
Uniform Nonrational B-Splines
• Piecewise curve creation can be difficult
– Tedious
– All points effect one another
• To preserve continuity conditions
• We desire a curve with local control
– Moving a control point only affects a small part of the
curve
– This also reduces the computations required
Uniform Nonrational B-Splines
• Approximating Splines
• Approximates m+1 control points
– P0, P1, …, Pm, m ¸ 3
• Curve consists of m –2 cubic polynomial segments
– Q3, Q4, … Qm
• t varies along B-spline as Qi: ti <= t < ti+1
• ti (i = integer) are knot points that join segment Qi-1 to Qi
• Curve is uniform because knots are spaced at equal intervals
of parameter, t
• Curve is nonrational because it isn’t a rational B-spline (one
formed by the ratio of two cubic polynomials
Uniform Nonrational B-Splines
• First curve segment, Q3, is defined by first
four control points
• Last curve segment, Qm, is defined by last
four control points, Pm-3, Pm-2, Pm-1, Pm
• Each control point affects four curve
segments
B-spline Basis Matrix
• Formulate 16 equations to solve the 16
unknowns
• The 16 equations enforce the C0, C1, and C2
continuity between adjoining segments, Q
 1 3  3
 3 6 3
1
M B  spline 
3
6  3 0

4
1
1
1

0
0

0
B-Spline
• Points along B-Spline are computed just as
with Bezier Curves
Qi t   UM B  SplineP

Qi t   t 3 t 2
 1 3  3
 3 6 3
1
t 1
3
6  3 0

4
1
1

1  pi 



0  pi 1 
0  pi  2 


0  pi 3 
B-Spline
• By far the most popular spline used
• C0, C1, and C2 continuous
Converting Between Splines
• Consider two spline basis formulations for
two spline types
Converting Between Splines
• We can transform the control points from
one spline basis to another
Converting Between Splines
• With this conversion, we can convert a BSpline into a Bezier Spline
• Bezier Splines are easy to render
Rendering Bezier Spline
public void spline(ControlPoint p0, ControlPoint p1,
ControlPoint p2, ControlPoint p3, int pix) {
float len = ControlPoint.dist(p0,p1) + ControlPoint.dist(p1,p2)
+ ControlPoint.dist(p2,p3);
float chord = ControlPoint.dist(p0,p3);
if (Math.abs(len - chord) < 0.25f) return;
fatPixel(pix, p0.x, p0.y);
ControlPoint p11 = ControlPoint.midpoint(p0, p1);
ControlPoint tmp = ControlPoint.midpoint(p1, p2);
ControlPoint p12 = ControlPoint.midpoint(p11, tmp);
ControlPoint p22 = ControlPoint.midpoint(p2, p3);
ControlPoint p21 = ControlPoint.midpoint(p22, tmp);
ControlPoint p20 = ControlPoint.midpoint(p12, p21);
spline(p20, p12, p11, p0, pix);
spline(p3, p22, p21, p20, pix);
}