computer graphics iigarryowen.csisdmz.ul.ie/~cs4085/resources/lect04.pdf · transformations...
TRANSCRIPT
Transformations
Computer Graphics II
P. Healy
CS1-08Computer Science Bldg.
tel: [email protected]
Autumn 2019–2020
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 1 / 18
Transformations
Outline
1 TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 2 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Outline
1 TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 3 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Orthogonal Projections
Suppose we want to project a point x onto a plane given by itsnormal,
#»
N
p
x
y
#»
Nn
#»
N
The point y is the of x onto the plane; the pointp is some given point on the planeFrom the vector y − p, we have
#»
N · (y − p) = 0
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 4 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Orthogonal Projections
Suppose we want to project a point x onto a plane given by itsnormal,
#»
N
p
x
y
#»
Nn
#»
N
The point y is the of x onto the plane; the pointp is some given point on the planeFrom the vector y − p, we have
#»
N · (y − p) = 0
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 4 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Orthogonal Projections (contd.)
Straight away we can see that
x = y + n#»
N
ory = x − n
#»
N
But what is n?The two components of the vector x − p are its componentin the plane, y − p, and an component whichwe can write as n
#»
N
x − p = (y − p) + n#»
N
Since y − p and#»
N are perpendicular, taking the dotproduct on both sides with
#»
N yields#»
N · (x − p) = n#»
N ·#»
N = n
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 5 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Orthogonal Projections (contd.)
Then
y = x −#»
Nn
= x −#»
N(#»
N · (x − p))
= x −#»
N(#»
N t(x − p))
= x −#»
N#»
N t(x − p)
= (I −#»
N#»
N t)x +#»
N#»
N tp
Notice that this is of the form y = Mx + b, for points y , x ,bThis is of the form “y is a multiple of x plus some constant,b”This is what we call an affine transformationOur previous example – projecting onto a line – was an
(See also first answer to this question.)P. Healy (University of Limerick) CS4085 Autumn 2019–2020 6 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Outline
1 TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 7 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Oblique Projections
Given a point x how do we project it obliquely onto a planegiven by its unit-length normal,
#»
N
p
#»
N
x
y
#»
D
Let#»
D be the direction in which we project points; w.l.o.g.we can assume that
#»
D is unit-length#»
D cannot be parallel to plane!#»
D ·#»
N =#»
N ·#»
D 6= 0
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 8 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Oblique Projections
Given a point x how do we project it obliquely onto a planegiven by its unit-length normal,
#»
N
p
#»
N
x
y
#»
D
Let#»
D be the direction in which we project points; w.l.o.g.we can assume that
#»
D is unit-length#»
D cannot be parallel to plane!#»
D ·#»
N =#»
N ·#»
D 6= 0
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 8 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Oblique Projections (contd.)
From y = x + d#»
D, and so
y − p = (x − p) + d#»
D
Dotting both sides with#»
N ,
0 =#»
N · (x − p) + d#»
N ·#»
D
d = −#»
N · (x − p)#»
N ·#»
D,
#»
N ·#»
D 6= 0
6=−(x − p)#»
Dand
y − p = (x − p)−#»
N · (x − p)#»
N ·#»
D
#»
D
=
(I −
#»
D#»
N t
#»
D t #»
N
)(x − p)
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 9 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Oblique Projections (contd.)
Finally,
y =
(I −
#»
D#»
N t
#»
D t #»
N
)x +
#»
D#»
N t
#»
D t #»
Np
Note:#»
N ·#»
D =#»
D ·#»
N =#»
N t #»
D =#»
D t #»
N 6=#»
D#»
N t
Since this is of the form y = Mx + b again, we can say thatoblique projections are also in the class of affinetransformations
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 10 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Oblique Projections (contd.)
Finally,
y =
(I −
#»
D#»
N t
#»
D t #»
N
)x +
#»
D#»
N t
#»
D t #»
Np
Since this is of the form y = Mx + b again, we can say thatoblique projections are also in the class of affinetransformations
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 10 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Outline
1 TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 11 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Perspective Projections
Graphics look much more realistic when drawn in theperspective styleIn this style points are projected onto a view plane not inparallel (as with orthogonal and oblique) but according torays that originate at a single point
This requires a special type of projection
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 12 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Perspective Projections (contd.)
p
#»
N
x
y
e
#»
D
With “source”, e, direction of projection is not uniform herebut depends instead on the vector x − e and
y = e + t(x − e), for some scalar t
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 13 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Perspective Projections (contd.)
Then since y − p is orthogonal to#»
N
y − p = (e − p) + t(x − e)
0 =#»
N · (e − p) + t#»
N · (x − e)
and, solving for t we get
t = −#»
N · (e − p)#»
N · (x − e)> 0
This makes sense since the vectors (e − p) and (x − e) haveopposite directions w.r.t.
#»
N so one will contribute a positive DPand the other negative.
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 14 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Perspective Projections (contd.)
So
y = e −#»
N · (e − p)#»
N · (x − e)(x − e)
= e#»
N · (x − e)#»
N · (x − e)−
#»
N · (e − p)#»
N · (x − e)(x − e)
=(e
#»
N t −#»
N · (e − p)I)(x − e)#»
N · (x − e)
(The last line is because#»
N · (x − e) =#»
N t(x − e).)This cannot be expressed as an affine transformation due to xappearing in the denominator.
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 15 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Beginnings of a Camera System
In the coordinate system of viewing direction#»
D, up vector#»
U ,how does a point x = e + d
#»
D + u#»
U + r#»
R get projected onto a“viewing” plane situated at position dmin units on the
#»
D axis infront of us?The viewing plane will be square to the viewing direction.Straight away we can say that d =
#»
D · (x − e), u =#»
U · (x − e)and r =
#»
R · (x − e)
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 16 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Beginnings of a Camera System (contd.)
We will say that the plane normal#»
N is −#»
D, that is, pointingback towards us. Then the closest point p on that plane is theone straight ahead (along the viewing direction)
p = e + dmin#»
D, for dmin > 0 and
e − p = −dmin#»
D
Putting this back in to the previous (2 slides ago), we get
y = e −#»
N · (e − p)#»
N · (x − e)(x − e)
= e − −#»
D · (−dmin#»
D)
−#»
D · (x − e)(x − e)
= e +dmin
d(x − e) = e +
d#»
D + u#»
U + r#»
Rm
, m = d/dmin
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 17 / 18
TransformationsOrthogonal Projection onto the PlaneOblique Projections onto the PlanePerspective Projections onto the Plane
Beginnings of a Camera System (contd.)
So a world point xdescribed as x = e + d
#»
D + u#»
U + r#»
Rwhich is the point (d ,u, r) in the
#»
D,#»
U ,#»
R co-ordinatesystem (that is centered at #»e )is associated with (gets projected to) (d ,u, r)/(d/dmin) onthe viewing plane situated at dmin on the
#»
D axisExercise: check where the point (d ,u, r) = (dmin,20,75)gets projected toNote the scaling factor, d/dmin, determines all threecomponents; we have been able to deal with scalingfactors from much earlier but the problem here is that thescaling factor is different for every point
P. Healy (University of Limerick) CS4085 Autumn 2019–2020 18 / 18