2 coen 290 - computer graphics i evening’s goals n discuss the mathematical transformations that...
TRANSCRIPT
![Page 1: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/1.jpg)
![Page 2: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/2.jpg)
2COEN 290 - Computer Graphics I
Evening’s Goals
Discuss the mathematical transformations that are utilized for computer graphics• projection• viewing• modeling
Describe aspect ratio and its importance Provide a motivation for homogenous
coordinates and their uses
![Page 3: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/3.jpg)
3COEN 290 - Computer Graphics I
Mathematical Transformations
Use transformations for moving from one coordinate space to another
The good news• only requires multiplication and addition
The bad news• its multiplication and addition of matrices
![Page 4: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/4.jpg)
4COEN 290 - Computer Graphics I
Mathematical Transformations ( cont. )
Coordinate spaces we’ll be using• model• world• eye• normalized device ( NDC’s )• window• screen• viewport
![Page 5: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/5.jpg)
5COEN 290 - Computer Graphics I
Simplified 2D Transform Pipeline
What if your data is not in viewport coordinates?
World Coordinates
Date
Sto
ck P
rice
Viewport coordinates
???
![Page 6: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/6.jpg)
6COEN 290 - Computer Graphics I
Simplified 2D Transform Pipeline ( cont. )
Need to map world to viewport coordinates Simple linear transformation
• linear transformations can be represented by matrices
dc
ba
y
x
y
x
worldviewport
![Page 7: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/7.jpg)
7COEN 290 - Computer Graphics I
Almost, but not quite
The 2x2 matrix isn’t quite enough to do the whole job• think about trying to map a point like (10,10)
into the (0,0) Enter … homogenous coordinates
• add an additional “dimension” to your coordinate vector
1yx
![Page 8: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/8.jpg)
8COEN 290 - Computer Graphics I
Determining the Matrix Entries
Matrix forms of linear transforms are shorthand for an “line” equation
So what we need is to determine what equations we want to write as matrices
1101
xbmybmxy
![Page 9: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/9.jpg)
9COEN 290 - Computer Graphics I
Mapping World to Viewport Coordinates
Viewport coordinates
???
World CoordinatesDate
Sto
ck P
rice
worldyMinxMin
worldyMinxMin
worldyMaxxMax
vpyMinxMin
vpyMaxxMax
vpworldworldworld
vpvpvp
vpworldworldworld
vpvpvp
yMinyMinyyMaxyMax
yMinyMaxy
xMinxMinxxMaxxMax
xMinxMaxx
![Page 10: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/10.jpg)
10
COEN 290 - Computer Graphics I
Or as a Matrix
Let
then our matrix becomes
worldworld
vpvp
worldworld
vpvp
yMinyMax
yMinyMax
yxMinxMax
xMinxMax
x mm
world
worldyvpy
worldxvpx
vp
y
x
yMinmyMinm
xMinmxMinm
y
x
1100
0
0
1
![Page 11: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/11.jpg)
11
COEN 290 - Computer Graphics I
Setting up OpenGL’s 2D world
OpenGL will do this automatically for us
gluOrtho2D( xMin, xMax, yMin, yMax );
However, it doesn’t do it quite as we described• first maps world coordinates into normalized
device coordinates ( NDC )• then maps from NDC’s to viewport coordinates
![Page 12: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/12.jpg)
12
COEN 290 - Computer Graphics I
Normalized Device Coordinates
Map each dimension linearly into• sometimes mapped to
Simplifies several things• clipping
– don’t need to know viewport for clipping
• describes a device independent space– no concerns about resolution, etc.
• more things which we’ll get to in a minute– very useful when we’re in 3D
1,1 1,0
![Page 13: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/13.jpg)
13
COEN 290 - Computer Graphics I
Putting it all together
World Coordinates
Date
Sto
ck P
rice
Date
Sto
ck P
rice
NDCDateS
tock
Pri
ce
ViewportCoordinates
![Page 14: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/14.jpg)
14
COEN 290 - Computer Graphics I
Err … something doesn’t look right
Need to match aspect ratio
Aspect ratios of different coordinate spaces need to match
height
widthratioaspect
vpworld arar
![Page 15: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/15.jpg)
15
COEN 290 - Computer Graphics I
What’s different for 3D
Add another dimension
Our transformation matrices become 4x4 More options for our projection transform
wzyx
![Page 16: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/16.jpg)
16
COEN 290 - Computer Graphics I
Where we’re at
What our transformation pipeline looks like so far ...
viewportNDC’sWorld
This is really called a projection transform
![Page 17: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/17.jpg)
17
COEN 290 - Computer Graphics I
Projection Transformations
Map coordinates into NDC’s Defines our viewing frustum
• sets the position of our imaging plane Two types for 3D
• Orthographic (or parallel) Projection–gluOrtho2D()
• Perspective Projection
![Page 18: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/18.jpg)
18
COEN 290 - Computer Graphics I
A Few Definitions First …
A viewing frustum is the region in space in which objects can be seen• All of the visible objects in our scene will be in
the viewing frustum The imaging plane is a plane in space onto
which we project our scene• viewing frustum controls where the imaging
plane is located
![Page 19: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/19.jpg)
19
COEN 290 - Computer Graphics I
Orthographic Projections
Project objects in viewing frustum without distortion• good for computer aided engineering and
design – preserves angles and relative sizes
![Page 20: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/20.jpg)
20
COEN 290 - Computer Graphics I
Orthographic Projections ( cont. )
![Page 21: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/21.jpg)
21
COEN 290 - Computer Graphics I
Defining an Orthographic Projection
Very similar to mapping 2D to NDC’s Use OpenGL’s
glOrtho( l, r, b, t, n, f );
1000
00
00
00
2
2
2
nfnf
nf
btbt
bt
lrlr
lr
![Page 22: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/22.jpg)
22
COEN 290 - Computer Graphics I
Perspective Projections
Model how the eye sees• objects farther from the eye are smaller
A few assumptions• eye is positioned at the world space origin• looking down the world -z axis
Clipping plane restrictions
farnear 0
![Page 23: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/23.jpg)
23
COEN 290 - Computer Graphics I
Perspective Projections ( cont. )
Based on similar triangles
y
z
n
'y
![Page 24: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/24.jpg)
24
COEN 290 - Computer Graphics I
Perspective Projections ( cont. )
Viewing frustum looks like a truncated Egyptian pyramid
![Page 25: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/25.jpg)
25
COEN 290 - Computer Graphics I
Defining Perspective Projections
Two OpenGL versions• glFrustum( l, r, b, t, n, f );
– frustum not necessarily aligned down line of sight
– good for simulating peripheral vision
• gluPerspective( fovy, aspect, n, f );– frustum centered down line of sight
– more general form
– reasonable values:–aspect should match aspect ratio of viewport
0.1400.65 fovy
![Page 26: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/26.jpg)
26
COEN 290 - Computer Graphics I
Defining a Perspective Projection
glFrustum( l, r, b, t, n, f );
0100
00
00
00
2)(
2
2
nfnf
nffn
btbt
btn
lrlr
lrn
![Page 27: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/27.jpg)
27
COEN 290 - Computer Graphics I
Defining a Perspective Projection ( cont. )
gluPerspective( fovy, aspect, n, f );
• then use glFrustum()
rl
aspecttr
tb
nt fovy
)tan( 2
![Page 28: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/28.jpg)
28
COEN 290 - Computer Graphics I
Clipping in 3D
Projections transforms make clipping easy Use your favorite algorithm Clipping region well defined
wzw
wyw
wxw
![Page 29: 2 COEN 290 - Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing](https://reader036.vdocument.in/reader036/viewer/2022062322/56649ea95503460f94bad94d/html5/thumbnails/29.jpg)
29
COEN 290 - Computer Graphics I
Normalizing Projected Coordinates
w is a scaling factor Perspective divide
• divide each coordinate by w• maps into NDC’s
What about z?
1wz
wywx