![Page 1: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/1.jpg)
CS 551 / 645: Introductory Computer Graphics
Mathematical Foundations
![Page 2: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/2.jpg)
From last class…
U.S. film projectors play film at 24 fps– Projectors have a shutter to block light during
frame advance– To reduce flicker, shutter opens twice for each
frame – resulting in 48 fps flashing– 48 fps is perceptually acceptable
European film projectors play film at 25 fps– American films are played ‘as is’ in Europe,
resulting in everything moving 4% faster– Faster movements and increased audio pitch are
considered perceptually acceptable
![Page 3: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/3.jpg)
From last class…
Film to DVD transfer– Problem: 24 film fps must be converted to television
interlaced 29.97 (30) fps
Use 3:2 Pulldown– First frame of movie is broken into first three frames– Next frame of movie is broken into next two frames– Next frame of movie is broken into next three frames…
![Page 4: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/4.jpg)
From last class…
![Page 5: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/5.jpg)
Additional Displays
Display Walls (Princeton)
![Page 6: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/6.jpg)
Additional Displays
Stereo
![Page 7: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/7.jpg)
Mathematical Foundations
Hearn and Baker (A1 – A4) appendix gives good review
I’ll give a brief, informal review of some of the mathematical tools we’ll employ– Geometry (2D, 3D)– Trigonometry– Vector spaces
Points, vectors, and coordinates
– Dot and cross products– Linear transforms and matrices
![Page 8: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/8.jpg)
2D Geometry
Know your high school geometry:– Total angle around a circle is 360° or 2π radians– When two lines cross:
Opposite angles are equivalent Angles along line sum to 180°
– Similar triangles: All corresponding angles are equivalent
![Page 9: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/9.jpg)
Trigonometry
Sine: “opposite over hypotenuse” Cosine: “adjacent over hypotenuse” Tangent: “opposite over adjacent” Unit circle definitions:
– sin () = x– cos () = y– tan () = x/y– Etc…
(x, y)
![Page 10: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/10.jpg)
Slope-intercept Line Equation
Slope = m = rise / run
Slope = (y - y1) / (x - x1) = (y2 - y1) / (x2 - x1)Solve for y:
y = [(y2 - y1)/(x2 - x1)]x + [-(y2-y1)/(x2 - x1)]x1 + y1
or: y = mx + b
x
y
P2 = (x2, y2)
P1 = (x1, y1)
P = (x, y)
![Page 11: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/11.jpg)
Parametric Line Equation
Given points P1 = (x1, y1) and P2 = (x2, y2)x = x1 + t(x2 - x1)y = y1 + t(y2 - y1)
When:– t=0, we get (x1, y1)– t=1, we get (x2, y2)– (0<t<1), we get points
on the segment between(x1, y1) and (x2, y2)
x
y
P2 = (x2, y2)
P1 = (x1, y1)
![Page 12: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/12.jpg)
Other helpful formulas
Length = sqrt (x2 - x1)2 + (y2 - y1)2
Midpoint, p2, between p1 and p3– p2 = ((x1 + x3) / 2, (y1 + y3) / 2))
Two lines are perpendicular if:– M1 = -1/M2– cosine of the angle between them is 0
![Page 13: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/13.jpg)
Coordinate Systems
Z
X
YY
X
Z
Right-handedcoordinatesystem
Left-handedcoordinatesystem
Grasp z-axis with handRoll fingers from positive x-axis towards positive y-axisThumb points in direction of z-axis
![Page 14: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/14.jpg)
Points
Points support these operations– Point-point subtraction: Q - P = v
Result is a vector pointing from P to Q
– Vector-point addition: P + v = Q Result is a new point
– Note that the addition of two points is not defined
P
Q
v
![Page 15: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/15.jpg)
Vectors
We commonly use vectors to represent:– Points in space (i.e., location)– Displacements from point to point– Direction (i.e., orientation)
![Page 16: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/16.jpg)
Vector Spaces
Two types of elements:– Scalars (real numbers): … – Vectors (n-tuples): u, v, w, …
Operations:– Addition– Subtraction– Dot Product– Cross Product– Norm
![Page 17: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/17.jpg)
Vector Addition/Subtraction
– operation u + v, with: Identity 0 v + 0 = v Inverse - v + (-v) = 0
– Vectors are “arrows” rooted at the origin– Addition uses the “parallelogram rule”:
u+vy
xu
v
u-v
y
x
uv
-v
![Page 18: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/18.jpg)
Scalar Multiplication
– Scalar multiplication: Distributive rule:(u + v) = (u) + (v)
( + )u = u + u
– Scalar multiplication “streches” a vector, changing its length (magnitude) but not its direction
![Page 19: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/19.jpg)
Dot Product
The dot product or, more generally, inner product of two vectors is a scalar:
v1 • v2 = x1x2 + y1y2 + z1z2 (in 3D) Useful for many purposes
– Computing the length (Euclidean Norm) of a vector: length(v) = ||v|| = sqrt(v • v)
– Normalizing a vector, making it unit-length: v = v / ||v||– Computing the angle between two vectors:
u • v = |u| |v| cos(θ)
– Checking two vectors for orthogonality u • v = 0.0
u θ
v
![Page 20: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/20.jpg)
u
Dot Product
Projecting one vector onto another– If v is a unit vector and we have another vector, w– We can project w perpendicularly onto v
– And the result, u, has length w • v
w
v
wv
wv
wvw
wu
)cos(
![Page 21: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/21.jpg)
Dot Product
Is commutative– u • v = v • u
Is distributive with respect to addition– u • (v + w) = u • v + u • w
![Page 22: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/22.jpg)
Cross Product
The cross product or vector product of two vectors is a vector:
The cross product of two vectors is orthogonal to both
Right-hand rule dictates direction of cross product
1221
1221
1221
21 )(
y x y x
z x z x
z y z y
vv
![Page 23: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/23.jpg)
Cross Product Right Hand Rule
See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the beginning of A and your fingers point in the direction of A
Twist your hand about the A-axis such that B extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb will point in the direction of the cross product
![Page 24: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/24.jpg)
Cross Product Right Hand Rule
See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the beginning of A and your fingers point in the direction of A
Twist your hand about the A-axis such that B extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb will point in the direction of the cross product
![Page 25: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/25.jpg)
Cross Product Right Hand Rule
See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the beginning of A and your fingers point in the direction of A
Twist your hand about the A-axis such that B extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb will point in the direction of the cross product
![Page 26: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/26.jpg)
Cross Product Right Hand Rule
See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the beginning of A and your fingers point in the direction of A
Twist your hand about the A-axis such that B extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb will point in the direction of the cross product
![Page 27: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/27.jpg)
Cross Product Right Hand Rule
See: http://www.phy.syr.edu/courses/video/RightHandRule/index2.html
Orient your right hand such that your palm is at the beginning of A and your fingers point in the direction of A
Twist your hand about the A-axis such that B extends perpendicularly from your palm
As you curl your fingers to make a fist, your thumb will point in the direction of the cross product
![Page 28: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/28.jpg)
Triangle Arithmetic
Consider a triangle, (a, b, c)– a,b,c = (x,y,z) tuples
Surface area = sa = ½ * ||(b –a) X (c-a)||
Unit normal = (1/2sa) * (b-a) X (c-a)
a c
b
![Page 29: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/29.jpg)
Vector Spaces
A linear combination of vectors results in a new vector:
v = 1v1 + 2v2 + … + nvn
If the only set of scalars such that
1v1 + 2v2 + … + nvn = 0
is 1 = 2 = … = 3 = 0
then we say the vectors are linearly independent The dimension of a space is the greatest number of linearly
independent vectors possible in a vector set For a vector space of dimension n, any set of n linearly
independent vectors form a basis
![Page 30: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/30.jpg)
Vector Spaces: Basis Vectors
Given a basis for a vector space:– Each vector in the space is a unique linear
combination of the basis vectors– The coordinates of a vector are the scalars from
this linear combination– If basis vectors are orthogonal and unit length:
Vectors comprise orthonormal basis
– Best-known example: Cartesian coordinates– Note that a given vector v will have different
coordinates for different bases
![Page 31: CS 551 / 645: Introductory Computer Graphics Mathematical Foundations](https://reader036.vdocuments.mx/reader036/viewer/2022070411/56649f585503460f94c7dda0/html5/thumbnails/31.jpg)
Conclusion
Read Chapters 1 – 3 of OpenGL Programming Guide
Assignment 1 out today, due 8 days from now, Wednesday the 12th