SLIDE 1
Week 4 - Friday What did we talk about last time? Homogeneous - - PowerPoint PPT Presentation
Week 4 - Friday What did we talk about last time? Homogeneous - - PowerPoint PPT Presentation
Week 4 - Friday What did we talk about last time? Homogeneous notation Vector equations for lines and planes Once we are in 3D, we have to talk about planes as well The explicit form of a plane is similar to a line: p ( u , v
SLIDE 2
SLIDE 3
SLIDE 4
SLIDE 5
SLIDE 6
Once we are in 3D, we have to talk about planes as well The explicit form of a plane is similar to a line:
- p(u,v) = o + us + vt
- o is a point on the plane
- s and t are vectors that span the plane
- s x t is the normal of the plane
SLIDE 7
The implicit equation for a plane is just like the implicit for a line,
except with an extra dimension
Let n be a vector (a, b, c) Let p be a point (x, y, z) p is on plane π if and only if
- n • p + d = 0
Since n is the normal of the plane we can compute it in a couple of
ways:
- n = s x t where s and t span the plane
- n = (u – w) x (v – w) where u, v, and w are noncollinear points in the plane
SLIDE 8
Again, it works just like a line If we write f(p) = n • p + d
Assuming q ∈ plane π
- f(p) = 0 iff p ∈ π
- f(p) > 0 iff p lies on the same side as the point q + n
- f(p) < 0 iff p lies on the same side as the point q - n
f(p) again gives a (scaled) measure of the perpendicular distance
from p to π
Distance(p) = f(p)/||n|| This implies that Distance(0) = d, making d the shortest distance
from the origin to the plane
SLIDE 9
The cross product of two vectors finds a vector that is
- rthogonal to both
For 3D vectors u and v in an orthonormal basis, the cross
product w is:
− − − = × = =
x y y x z x x z y z z y z y x
v u v u v u v u v u v u w w w v u w
SLIDE 10
Plane defined by:
- (1, 3, 2)
- (2, 5, 2)
- (3, 8, 2)
Where is (3, 3, 2)? What about (3, 4, 5)?
SLIDE 11
SLIDE 12
Let p = (px, py) be a unit vector Let ϕ be the angle the vector makes with the x-axis sin ϕ = py cos ϕ = px tan ϕ = sin ϕ/cos ϕ = py/px
SLIDE 13
For a right triangle with sides a and b and hypotenuse c:
- sin α = a/c
- cos α = b/c
- tan α = sin α/cos α = a/b
- c2 = a2 + b2
SLIDE 14
For any triangle:
- Law of sines:
- Law of cosines:
c2 = a2 + b2 – 2ab cosγ
- Law of tangents:
c γ b β a α sin sin sin = =
2 tan 2 tan β α β α b a b a − + = − +
SLIDE 15
Trigonometric identity: cos2ϕ + sin2ϕ = 1 Double angle:
- sin2 ϕ = 2sin ϕcos ϕ = 2tan ϕ/(1 + tan2 ϕ)
- cos2 ϕ=cos2ϕ- sin2ϕ=1 – sin2ϕ
- tan2 ϕ = 2tan ϕ/(1-tan2 ϕ)
There are a host of other useful ones listed in the book
SLIDE 16
SLIDE 17
The computer science behind texture mapping uses a lot of
techniques to make it look better
For now, we're only worried about mapping a vertex to a
location in a rectangular texture
- MonoGame will take care of the rest
SLIDE 18
Texture coordinates are usually
given in (u, v) form
u is the horizontal direction and
v is the vertical
These coordinates are each
almost always in the range [0, 1]
In MonoGame, u grows from left
to right and v grows from top to bottom
u v
(0,0) (1,0) (0,1)
SLIDE 19
Load images into Texture2D objects as before Use a vertex format that allows a texture to be specified (such
as VertexPositionNormalTexture)
Set appropriate texture coordinates on each vertex When drawing, set the Texture property on the
BasicEffect object to the texture you want to use
Apply the change on the pass
SLIDE 20
SLIDE 21
SLIDE 22
A transform is an operation that changes points, vectors, or
colors
We can use them to position and animate objects, lights, and
cameras
A linear transform is one that holds over vector addition and
scalar multiplication
- Rotation
- Scaling
- Can be represented by a 3 x 3 matrix
SLIDE 23
Adding a vector after a linear transform makes an affine
transform
Affine transforms can be stored in a 4 x 4 matrix using
homogeneous notation
Affine transforms:
- Translation
- Rotation
- Scaling
- Reflection
- Shearing
SLIDE 24
Notation Name Characteristics T(t) Translation matrix Moves a point (affine) R Rotation matrix Rotates points (orthogonal and affine) S(s) Scaling matrix Scales along x, y, an z axes according to s (affine) Hij(s) Shear matrix Shears component i by factor s with respect to component j E(h,p,r) Euler transform Orients by Euler angles head (yaw), pitch, and roll (orthogonal and affine) Po(s) Orthographic projection Parallel projects onto a plane or volume (affine) Pp(s) Perspective projection Project with perspective onto a plane or a volume slerp(q,r,t) Slerp transform Interpolates quaternions q and r with parameter t
SLIDE 25
SLIDE 26
More on standard transforms Normal transforms Inverses Euler transform Matrix decomposition Rotation around an arbitrary axis Quaternions
SLIDE 27