1 1 CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2 David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University 2 Outline • Math review • Introduction to 2D curves • Functional representations • Parametric cubic curves • Introduction to Bézier curves 3 Geometric Preliminaries • Affine Geometry – Scalars + Points + Vectors and their ops • Euclidian Geometry – Affine Geometry lacks angles, distance – New op: Inner/Dot product, which gives • Length, distance, normalization • Angle, Orthogonality, Orthogonal projection • Projective Geometry 4 Affine Geometry • Affine Operations: • Affine Combinations: a1v1 + a2v2 + … + anvn where v1,v2, …,vn are vectors and Example: 5 Mathematical Preliminaries • Vector: an n-tuple of real numbers • Vector Operations – Vector addition: u + v = w • Commutative, associative, identity element (0) – Scalar multiplication: cv • Note: Vectors and Points are different – Can not add points – Can find the vector between two points 6 Linear Combinations & Dot Products • A linear combination of the vectors v1, v2, … vn is any vector of the form a1v1 + a2v2 + … + anvn where ai is a real number (i.e. a scalar) • Dot Product: a real value u1v 1 + u2v 2 + … + unv n written as v u •
8
Embed
Outline Geometric Preliminaries Computer Graphics Affine ...david/Classes/CS536/Lectures/L-02_IntroCurves.6.pdfOutline • Math review • Introduction to 2D curves •Functional representations
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
1
CS 536Computer Graphics
Intro to CurvesWeek 1, Lecture 2
David Breen, William Regli and Maxim PeysakhovDepartment of Computer Science
Drexel University
2
Outline
• Math review• Introduction to 2D curves• Functional representations• Parametric cubic curves• Introduction to Bézier curves
3
Geometric Preliminaries
• Affine Geometry– Scalars + Points + Vectors and their ops
• Euclidian Geometry– Affine Geometry lacks angles, distance– New op: Inner/Dot product, which gives
• Implementation issue:Where does the index start?(0 or 1, it’s up to you…)
10
Matrix Multiplication• [C] = [A][B] • Sum over rows & columns• Recall: matrix multiplication
is not commutative• Identity Matrix:
1s on diagonal0s everywhere else
11
Matrix Determinants
• A single real number• Computed recursively• Example:
• Uses: – Find vector ortho to two other vectors– Determine the plane of a polygon
bcaddbca
−="#
$%&
'det
€
det(A) = Ai, j (−1)i+ j Mi, j
j=1
n
∑
12
Cross Product
• Given two non-parallel vectors, A and B• A x B calculates third vector C that is
orthogonal to A and B• A x B = (aybz - azby, azbx - axbz, axby - aybx)
€
A × B =
x y z
ax ay az
bx by bz
3
13
Matrix Transpose & Inverse
• Matrix Transpose:Swap rows and cols:
• Facts about the transpose:
• Matrix Inverse: Given A, find B such thatAB = BA = I BèA-1
(only defined for square matrices)
Derivatives of Polynomials
14
f (x) =αxn
df (x)dx
=αnxn−1
f (x) = 5x3
df (x)dx
=15x2
Partial Derivatives of Polynomials
15
f (x, y) =αxnym
∂f (x, y)∂x
=αnxn−1ym
f (x, y) = 5x3y4
∂f (x, y)∂x
=15x2y4
Curves
16 17
Example Application: Font Design and Display
• Curved objects are everywhere
• There is always need for:– mathematical fidelity– high precision– artistic freedom and
flexibility– physical realism
Pic s /Math courtesy of G. Farin @ ASU18
Example Application: Graphic Design and Arts
Courtes y of h ttp ://www.p i lo t3d.c om
4
19
Example Application: Tool Path Generation
Pic s /Math courtesy of G. Farin @ ASUv ia M. Wagner @ ASU
20
Example Application: Motion Planning
21
Functional Representations
• Explicit Functions:– representing one variable with another– fine if only one x value for each y value– Problem: what if I have a sphere?
• Multiple values …. (not used in graphics)
Pic s /Math courtesy of Dave Mount @ UMD-CP
€
z = ± r2 − x 2 − y 2
∃
22
Functional Representations
• Implicit Functions:– curves/surfaces represented as “the zeros”– good for rep. of (n-1)D objects in nD space– Sphere example:– What class of function?
• polynomial: linear combo of integer powers of x,y,z• algebraic curves & surfaces: rep’d by implicit
polynomial functions• polynomial degree: total sum of powers,
i.e. polynomial of degree 6:
Pic s /Math courtesy of Dave Mount @ UMD-CP
02222 =−++ rzyx
02222 =−++ rzyx23
• Parametric Functions:– 2D/3D curve: two functions of one parameter
(x(u), y(u)) (x(u), y(u), z(u))– 3D surface: three functions of two parameters
(x(u,v), y(u,v), z(u,v))– Example: Sphere
Note: rep. notalgebraic, but isparametric
Functional Representations
24
Functional Representations
• Which is best??– It depends on the application– Implicit is good for
• computing ray/surface intersection• point inclusion (inside/outside test)• mass & volume properties
– Parametric is good for• subdivision, faceting for rendering• Surface & area properties• popular in graphics
5
25
Issues in Specifying/Designing Curves/Surfaces
• Note: the internal mathematical representation can be very complex– high degree polynomials– hard to see how parameters relate to shape
• How do we deal with this complexity?– Use curve control points and either
• Interpolate• Approximate
26
Points to Curves
• The Lagrangian interpolating polynomial– n+1 points, the unique polynomial of degree n– curve wiggles thru each control point– Issue: not good if you want smooth or flat curves
• Approximation of control points– points are weights that tug on the curve or surface
Pic s /Math courtesy of Dave Mount @ UMD-CP27
Warning, Warning, Warning:Pending Notation Abuse
• t and u are used interchangeably as a parameterization variable for functions
• Why?– t historically is “time”, certain parametric functions
can describe “change over time” (e.g. motion of a camera, physics models)
– u comes from the 3D world, i.e. where two variables describe a B-spline surface
• u and v are the variables for defining a surface• Choice of t or u depends on the text/reference
28
Parametric Curves
• General rep:
• Properties:– individual functions are single-
valued– approximations are done with
piecewise polynomial curves– Each segment is given by two
• The general form for the i-th Bernstein polynomial for a degree k Bézier curve is
• Some properties of BPs– Invariant under transformations– Form a partition of unity, i.e. summing to 1– Low degree BPs can be written as high degree BPs– BP derivatives are linear combo of BPs– Form a basis for space of polynomials w/ deg≤k
40
Bernstein Polynomials
• For those that forget combinatorics
• Note: k does not have to be 3.
€
bik (u) =k!
i!(k − i)!(1− u)k− i ui
41
Bézier Curves and the Bernstein Polynomials
• Cubic Bernstein blending functions
• Observe: the coefficients are just rows in Pascal’s triangle
Pic s /Math courtesy of Dave Mount @ UMD-CP42
Bézier Curves and the Bernstein Polynomials
• Observe
The Four Bernstein polynomials– also defined by
• These represent the blending proportions among the control points
Pic s /Math courtesy of Dave Mount @ UMD-CP
8
43
Bézier Curves and the Bernstein Polynomials
• The four cubic Bernstein polynomials
• Observe:– at t=0, only BB1 is >0
• curve interpolates P1– at t=1, only BB4 is >0
• curve interpolates P4
Pic s /Math courtesy of Dave Mount @ UMD-CP44
General Form of Bezier Curve
€
Q(u) = Pi+1ki"
# $ %
& ' (1− u)k− i ui
i= 0
k
∑
Control points: P1, P2, …, Pk+1; 0 ≤ u ≤ 1Produces a point on curve Q at parameter value u
45
Properties of Bézier Curves• k+1 control points defines a
single curve of degree k• Affine invariance• Invariance under affine
parameter transformations• Convex hull property
– curve lies completely within convex hull of control points
• Endpoint interpolation• Intuitive for design
– curve mimics the control polygonPic s /Math courtesy of G. Farin @ ASU
46
Issues with Bézier Curves
• Creating complex curves requires many control points– potentially a very high-degree polynomial
with many wiggles• Bézier blending functions have global
support over the whole curve– move just one point, change whole curve
• Improved Idea: link (C1) lots of low degree (cubic) Bézier curves end-to-end
47
Programming Assignment 1• Process command-line arguments• Read in 3D control points• Iterate through parameter space by du
• for loop should use integers!
• At each u value evaluate Bezier curve formula to produce a sequence of 3D points
• Output points by printing them to standard out as a polyline and control points as spheres in Open Inventor