![Page 1: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/1.jpg)
CS361Week 5 - Wednesday
![Page 2: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/2.jpg)
Last time
What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions
![Page 3: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/3.jpg)
Questions?
![Page 4: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/4.jpg)
Project 2
![Page 5: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/5.jpg)
Quaternions
![Page 6: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/6.jpg)
Quaternions
Quaternions are a compact way to represent orientations
Pros: Compact (only four values needed) Do not suffer from gimbal lock Are easy to interpolate between
Cons: Are confusing Use three imaginary numbers Have their own set of operations
![Page 7: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/7.jpg)
Definition
A quaternion has three imaginary parts and one real part
We use vector notation for quaternions but put a hat on them
Note that the three imaginary number dimensions do not behave the way you might expect
wvwzyxwv qqkqjqiqq qqq ),ˆ(ˆ
kjiij
jikki
ikjjk
kji
1222
![Page 8: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/8.jpg)
Operations
Multiplication
Addition
Conjugate
Norm
Identity
),(ˆˆ vvwwvwvwvv rqqr rqrqrqrq
),(ˆˆ wwvv rq rqrq
),(ˆ*wv qqq
2222)̂( wzyx qqqqn q
)1,(ˆ 0i
![Page 9: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/9.jpg)
More operations
Inverse
One (useful) conjugate rule: Note that scalar multiplication is just like
scalar vector multiplication for any vector Quaternion quaternion multiplication is
associative but not commutative For any unit vector u, note that the
following is a unit quaternion:
*2
1 ˆ)̂(
1ˆ qq
qn
)cos,(sinˆ φφuq
*** ˆˆ)̂ˆ( qrrq
![Page 10: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/10.jpg)
Quaternion transforms
Take a vector or point p and pretend its four coordinates make a quaternion
If you have a unit quaternion the result of is p rotated around the u axis by 2
Note that, because it's a unit quaternion,
There are ways to convert between rotation matrices and quaternions
The details are in the book
p̂)cos,(sinˆ φφuq
1ˆˆˆ qpq
*1 ˆˆ qq
![Page 11: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/11.jpg)
Quaternion rotation example Take vector (0,0,3), write it as p =
(0,0,3,0) Let's rotate it 90° around the x-axis using
a quaternion We want where u is the x-axis and is 45°
p = (0, -3 sin , 0, 3cos , 0) = (0, -6sincos,3cos2-3sincos, 0)= (0, -3, 0, 0)
![Page 12: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/12.jpg)
Slerp
Short for spherical linear interpolation Using unit quaternions that represent
orientations, we can slerp between them to find a new orientation at time t = [0,1], tracing the path on a unit sphere between the orientations
To find the angle between the quaternions, you can use the fact that cos = qxrx + qyry + qzrz + qwrw
rqrqs ˆsin
)sin(ˆsin
))1(sin(),̂,ˆ(̂
φtφ
φtφ
t
![Page 13: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/13.jpg)
Student Lecture: Vertex Blending and Morphing
![Page 14: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/14.jpg)
Vertex blending
If we animate by moving rigid bodies around each other, joints won't look natural
To do so, we define bones and skin and have the rigid bone changes dictate blended changes in the skin
![Page 15: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/15.jpg)
Vertex blending continued The following equation shows the effect that
each bone i (and its corresponding animation transform matrix Bi(t) and bone to world transform matrix Mi ) have on the p, the original location of a vertex
Vertex blending is popular in part because it can be computed in hardware with the vertex shader
1
0
1
0
1 1 where )()(n
ii
n
iiii wtwt pMBu
![Page 16: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/16.jpg)
Morphing
Morphing is the technique for interpolating between two complete 3D models
It has two problems: Vertex correspondence▪ What if there is not a 1 to 1 correspondence
between vertices? Interpolation▪ How do we combine the two models?
![Page 17: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/17.jpg)
Morphing continued
We're going to ignore the correspondence problem (because it's really hard)
If there's a 1 to 1 correspondence, we use parameter s[0,1] to indicate where we are between the models and then find the new location m based on the two locations p0 and p1
Morph targets is another technique that adds in weighted poses to a neutral model
10)1( ppm ss
![Page 18: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/18.jpg)
Projections
Finally, we deal with the issue of projecting the points into view space
Since we only have a 2D screen, we need to map everything to x and y coordinates
Like other transforms, we can accomplish projection with a 4 x 4 matrix
Unlike affine transforms, projection transforms can affect the w components in homogeneous notation
![Page 19: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/19.jpg)
Orthographic projections
An orthographic projection maintains the property that parallel lines are still parallel after projection
The most basic orthographic projection matrix simply removes all the z values
This projection is not ideal because z values are lost Things behind the camera are in front z-buffer algorithms don't work
1000
0000
0010
0001
0P
![Page 20: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/20.jpg)
Canonical view volume
To maintain relative depths and allow for clipping, we usually set up a canonical view volume based on (l,r,b,t,n,f)
These letters simply refer to the six bounding planes of the cube Left Right Bottom Top Near Far
Here is the (OpenGL) matrix that translates all points and scales them into the canonical view volume
1000
200
02
0
002
0
nfnf
nf
btbt
bt
lrlr
lr
P
![Page 21: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/21.jpg)
Stupid SharpDX
OpenGL normalizes to a canonical view volume from [-1,1] in x, [-1,1] in y, and [-1,1] in z
Just to be silly, SharpDX normalizes to a canonical view volume of [-1,1] in x, [-1,1] in y, and [0,1] in z
Thus, its projection matrix is:
1000
100
02
0
002
0
nfn
nf
btbt
bt
lrlr
lr
P
![Page 22: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/22.jpg)
Perspective projection
A perspective projection does not preserve parallel lines
Lines that are farther from the camera will appear smaller
Thus, a view frustum must be normalized to a canonical view volume
Because points actually move (in x and y) based on their z distance, there is a distorting term in the w row of the projection matrix
![Page 23: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/23.jpg)
Perspective projection matrix
Here is the SharpDX projection matrix
It is different from the OpenGL again because it only uses [0,1] for z
0100
00
02
0
002
0
nffn
nffbtbt
btn
lrlr
lrn
P
![Page 24: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/24.jpg)
SharpDX Projection Examples
![Page 25: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/25.jpg)
Quiz
![Page 26: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/26.jpg)
Upcoming
![Page 27: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/27.jpg)
Next time…
Light Materials Sensors
![Page 28: Week 5 - Wednesday. What did we talk about last time? Project 2 Normal transforms Euler angles Quaternions](https://reader035.vdocuments.us/reader035/viewer/2022070409/56649e985503460f94b9b63e/html5/thumbnails/28.jpg)
Reminders
Read Chapter 5 for FridayExam 1 next Friday Keep working on Project 2