transformações geométricas rodrigo de toledo ufrj, cg1, 2010.2
TRANSCRIPT
![Page 1: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/1.jpg)
TransformaçõesGeométricas
Rodrigo de ToledoUFRJ, CG1, 2010.2
![Page 2: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/2.jpg)
Índice
• Exemplos de Transformações 2D
• Fórmulas e cálculos das transformações 2D
• Usando matriz de transformação (por que?)
• Coordenadas Homogêneas
• Concatenação de transformações
• Transformações 3D
![Page 3: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/3.jpg)
Exemplos de Transformações 2D
• Translação
• Escala– uniforme– não uniforme
• Rebatimento por um eixo (espelhamento)
• Troca de eixos
• Rotação pela origem
![Page 4: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/4.jpg)
Translação
Translation of a point is simply vector addition
x
y
P1
P2
P2 = P1 + -2-1
= +-2-1
33
12
![Page 5: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/5.jpg)
Escala
Scaling about the origin is scalar multiplication
x
y
P1
P2
22
= 2 * 11
P2 = P1 * 2
![Page 6: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/6.jpg)
Rebatimento por um eixo(espelhamento)
x = xy = -y
![Page 7: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/7.jpg)
Troca de Eixos
x = yy = x
![Page 8: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/8.jpg)
Rotação pela Origem
x´ = x.cos - y.sen y´ = x.sen + y.cos
x
y
P =
x´
y´ P´ =
x
y
![Page 9: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/9.jpg)
Por que usar Matriz nas Transformações?
• Todas as transformações podem ser efetuadas através da multiplicação de matrizes (usando coordenadas homogêneas).
• As transformações podem ser aninhadas e resolvidas de modo a haver apenas uma matriz de multiplicação a ser aplicada.
• A característica descrita acima se torna muito importante quando a mesma seqüência de transformações deve ser aplicada para diversos pontos.
![Page 10: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/10.jpg)
Multiplicação de Matrizes
a b
c d
x
y
x’
y’
a x b yx’ =
c x d yy’ =
onde:
![Page 11: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/11.jpg)
Uniform Scaling
,,S
s 0
0 sP
x
yM S P
s 0
0 s
x
y
s x
s y
,,I
1 0
0 1M Is P M s
x
y
![Page 12: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/12.jpg)
Non-uniform Scaling
Note orientation shift in line
M S P
s1 0
0 s2
xy
s1 x
s2 y
S
s1 0
0 s2
P
x
y
![Page 13: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/13.jpg)
Non-uniform Scaling
x
y
sx x´
y´ =
x
y
P =
x´
y´ P´ =
x
y
0 sy
0
Redução (0< sx <1) ,Aumento (sy >1)
![Page 14: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/14.jpg)
Flip an Axis...
What does this do to appearance of objects?
x
y
1 0
0 -1
x
y
![Page 15: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/15.jpg)
Swap Axes
y
x
0 1
1 0
x
y
![Page 16: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/16.jpg)
Rotate by
, ,M R P R
( )cos ( )sin
( )sin ( )cos P
x
y
( )cos x ( )sin y
( )sin x ( )cos y
( )cos ( )sin
( )sin ( )cos
x
y
![Page 17: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/17.jpg)
Transformações Geométricas(Translação)
x
y
P
x
yP’ =
P’
tx
ty
t =
tx
ty
+=x’
y’
x
y
? x´
y´ =
? ?? Não pode ser
escrito na forma
x
y
1 x´
y´ =
0 10 tx
ty
+Ruim paraimplementação
![Page 18: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/18.jpg)
Vantagens das coordenadas homogêneas(Translação)
yh
xh
w
w=1
x
y
t
P’ = =x’
y’
x’
y’
1
x
y
1
=
1
0
0
0
1
0
tx
ty
1
[T]
Matriz de Translação
![Page 19: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/19.jpg)
Coordenadas homogêneas
x
y
P
x
y
1
x
yP
wx
wy
w
xh
yh
w
= =
x = xh /w
y = yh /ww>0
= =
yh
xh
w
w=1
x
y
Ex.:
3
2
1
3
2
6
4
2
9
6
3
== =
![Page 20: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/20.jpg)
Vantagens das coordenadas homogêneas (pontos no infinito)
w=1
uh
wH1
C1H2 = C2
H3
C3
2
3
2
2
3
1
2
3
1/2
2
3
1/4
2
3
0
. . .
1
1.5
2
3
4
6
8
12
yh
xh
w
w=1
x
y
2
3u =
u
uh
2
3
0
=?
?
infinitona
direção(2,3)
infinitona
direção(2,3)
H1 H2 H3 H4
C1 C2 C3 C4
![Page 21: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/21.jpg)
Vantagens das coordenadas homogêneas (pontos no infinito, exemplo)
A
B
C
D
x
y
O
1
-1
1 2
A’
B’ C’
D’
x
y
O’infinito
-1
1
1 2
1
1
1
3
0
1
0
1
0
-2
0
0
3
0
1
0
1
0
-2
0
0
=
1
1
1
2
2
1
3
0
1
0
1
0
-2
0
0
=
4
2
2
1
-1
1
3
0
1
0
1
0
-2
0
0
=
1
-1
1
2
-2
1
3
0
1
0
1
0
-2
0
0
=
4
-2
2
2
1
1
=
=
2
-1
1
![Page 22: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/22.jpg)
Efeito de profundidade
x
y
x
y
![Page 23: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/23.jpg)
Simplificação da projeção cônica
plano de projeçãoeye
Projeção cônica
plano de projeção
direção de projeção
Projeção ortográfica
![Page 24: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/24.jpg)
Concatenação
x
y
x0
y0
x
y
x
y
x
y
x0
y0
1 0
0 1
0 0 1
0
0
x
y 1 0
0 1
0 0 1
0
0
x
y
cos sin
sin cos
0
0
0 0 1
x
y
x
y
x
y
x
y
'
'
cos sin
sin cos
1
1 0
0 1
0 0 1
0
0
0 0 1
1 0
0 1
0 0 1 1
0
0
0
0
![Page 25: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/25.jpg)
Concatenação de Transformações
x
y
x
y
x
y
x
y
x
y
x
yT1
R1
E
R2
T2
P’= T2 R2 E R1 T1 PP’= T2 R2 E R1 T1 P
![Page 26: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/26.jpg)
Composição com sistema local/móvel
X
Y
X
Y
X
Y
xy
X
Y
X
Y
x
y
Y
X
P2 = R T P
P =X
Y
P1=
X1
Y1
P2=
X2
Y2TR
R
T’
T’ = R T R-1
P1= T P e P2 = R P1
P =X
Y
P3=
X3
Y3
P2=
X2
Y2
P3= R P e P2 = T’ P3 P2 = R T R-1 R P P2 = R T Pou
![Page 27: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/27.jpg)
Geometria Projetiva e Coordenadas Homogêneas em 3D
xh
yh
zh
w
xyz1
m11 m12 m13 m14
m21 m22 m23 m24
m31 m32 m33 m34
m41 m42 m43 m44
=
P
P’
z
x
y
P
xyz
=P’ =
x’y’z’
xh /wyh/wzh/w
=
![Page 28: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/28.jpg)
Transformações em 3D(translações e escalas)
x’
y’
z’
1
0
1
0
0
0
0
1
0
tx
ty
tz
1
y
z
1
x
=
1
0
0
0
x
y
z
x’
y’
z’
1
0
sy
0
0
0
0
sz
0
0
0
0
1
y
z
1
x
=
sx
0
0
0
![Page 29: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/29.jpg)
Transformações em 3D(Rotações)
x
y
z
x’
y’
z’
1
0
cos x
sen x
0
0
cos x
0
0
0
0
1
y
z
1
x
=
1
0
0
0
-sen x
x x’
y’
z’
1
0cos ysen y
0
0 cos y
0
0
0
0
1
y
z
1
x
=10 0
0
-sen y
y
x’
y’
z’
1
0
cos z
sen x
0
0
cos x
0
0
0
0
1
y
z
1
x
=100
0
-sen x
z
![Page 30: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/30.jpg)
Transformações em 3D(rotação em torno de um eixo qualquer)
x’
y’
z’
1
m12
m22
m32
0
m13
m23
m33
0
0
0
0
1
y
z
1
x
=
m11
m21
m31
0
v = (vx, vy, vz)
x
y
z
m11 = vx2 + cos (1- vx
2)m12 = vxvy(1-cos) - vz senm13 = vzvx(1-cos) + vy senm21 = vxvy(1-cos) + vz senm22 = vy
2 + cos (1- vy2)
m23 = vyvz(1-cos) - vx senm31 = vxvz (1-cos) - vy senm32 = vyvz(1-cos)+ vx senm22 = vz
2 + cos (1- vz2)
![Page 31: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/31.jpg)
Projeções Clássicase
Matrizes de Projeção do OpenGL
![Page 32: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/32.jpg)
Projeções Planas Cônicas
A
BAp
Bp
realista
não preserva escala não preserva ângulos
![Page 33: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/33.jpg)
Projeções Planas Paralelas
A
BAp
Bp
preserva paralelismo possui escala conhecida
pouco realista
![Page 34: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/34.jpg)
Classificação das projeções planas
• Paralelas– ortográficas dp // n
• plantas• elevações• iso-métrica
– oblíquas dp não é paralela a n• cavaleiras• cabinet
• Cônicas– 1 pto de fuga– 2 ptos de fuga– 3 ptos de fuga
![Page 35: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/35.jpg)
Projeções de um cubo
planta ouelevação
iso-métrica
1/2
1
Cabinete(=45 ou 90)
Cavaleira(=45 ou 90)
1
1
1
1
• Paralelas
• Cônicas
1 pto de fuga 2 ptos de fuga
![Page 36: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/36.jpg)
Projeção plana é uma transformação linear?
Ou seja:T(P+Q) = T(P)+T(Q) eT(P) = T(P) ?
Vp
2V
V
(2V)p2(Vp)
O
cpcp
plano deprojeção
O
V
2V
Vp
2Vp
Projeções cônicas não são TL,paralelas podem ser.
Projeções cônicas não são TL,paralelas podem ser.
![Page 37: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/37.jpg)
Projeção plana paralela é uma transformação linear?
T(P+Q) = T(P)+T(Q) ?
T( 0 ) = 0 ?T( 0 ) = 0 ?
retas paralelas projetam em paralelas
Qp
Pp
Pp+ Qp
P
O
Q
Qp
Pp
P+Q
Projeção paralela em plano que passa pela origem é uma transformação linear
Projeção paralela em plano que passa pela origem é uma transformação linear
![Page 38: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/38.jpg)
Matrizes de projeções Cavaleiras e Cabinetes
k
x
y
z
(1,1,1)
x
y
1
1
M
T(1,0,0) = (1,0)
T(0,1,0) = (0,1)
T(0,0,1) = ( -k cos , -k sin )
1 0 -k.cos(M = 0 1 -k.sin(
![Page 39: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/39.jpg)
Matrizes de projeções pseudo-isométricas
x
y
z
(1,1,1)
x
y
1
M
T(1,0,0) = (cos 30 ,-sin 30)
T(0,1,0) = (0,1)
T(0,0,1) = (-cos 30, -sin 30) cos30 0 -cos30M = -sin30 1 -sin30
ip
i
j jp
kkp
![Page 40: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/40.jpg)
Projeção cônica simples
xe
ye
ze
P
Pp
xez e
d = ny e
z e
xe
xp
ye
yp
-ze
xe
xp d-ze
=
xexp -ze=
ye
yp d-ze
=
d yeyp -ze=
zp = -d
d
d
e
e
e
z
y
x
P
d
y
x
P p
p
p
![Page 41: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/41.jpg)
Projeção cônica simples
xe
ye
ze
P
Ppd yeyp -ze
=
zp = -d
xexp -ze= d
xp
yp
zp
1
d
0
0
0
0
d
0
0
0
0
d
-1
0
0
0
0
ye
ze
1
d xe
d ye
d ze
-ze
(d/-ze) xe
(d/-ze) ye
-d
1
xe
= ==
ww
![Page 42: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/42.jpg)
Simplificação da projeção cônica
plano de projeçãoeye
Projeção cônica
plano de projeção
direção de projeção
Projeção ortográfica
![Page 43: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/43.jpg)
xe
ye
ze
Distorce o frustum de visão para o espaço da tela
[ P ] =
n000
0n00
00-1
000
ze = -n ze = -f
xe
ye
ze
ze = -n
ze = -f
d = nd = n
![Page 44: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/44.jpg)
Uma equação para profundidade
zze
nn
Ptos no near (z=-n):
ff
Ptos no far (z=-f):
nf
nf
[ P ] =n000
0n00
00
n+f-1
00
n Ÿ f0
![Page 45: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/45.jpg)
xe
ye
ze
Translada o paralelepípedo de visão para origem
[ T ] =
0010
1000
0100
-(r+l)/2-(t+b)/2+(f+n)/2
1
xe
ye
ze
lr
b
t
-(r-l)/2(r-l)/2
-(t-b)/2
(t-b)/2
(f-n)/2 -(f-n)/2
![Page 46: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/46.jpg)
Escala o paralelepípedo de visão no cubo [-1,1]x[-1,1]x[-1,1]
[S] =
xe
ye
ze
-(r-l)/2(r-l)/2
-(t-b)/2
(t-b)/2
(f-n)/2 -(f-n)/22/(r-l)
000
0001
02/(t-b)
00
00
-2/(f-n)0
xd
yd
zd
111
-1-1-1
near
far
near far
![Page 47: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/47.jpg)
Matriz Frustum do OpenGL
[ P ] =
n000
0n00
00
n+f-1
00
n Ÿ f0
[ T ] =
0010
1000
0100
-(r+l)/2-(t+b)/2+(f+n)/2
1
[S] =
2/(r-l)000
0001
02/(t-b)
00
00
-2/(f-n)0
20 0
02
0
0 02
0 0 1 0
n
r l
r l
r ln
t b
t b
t bf n
f n
fn
f n
( )[S T P ] =
OpenGL Spec
![Page 48: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/48.jpg)
Projeção Cônica (Frustum)
far
left
righ
t
xeze
near
top
bott
om
yeze
camera (eye)
view frustum
xe
ye
ze
void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_, GLdouble far_ );
Obs.: near e far são distâncias( > 0)
Plano de projeção
![Page 49: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/49.jpg)
Projeção Cônica (Perspective)
aspect = w/h
xe
ye
ze
void glPerspective( GLdouble fovy, GLdouble aspect, GLdouble near_, GLdouble far_ );
near
far
w
h
xeze
fovy
![Page 50: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/50.jpg)
Matriz Ortho do OpenGL
[ T ] =
0010
1000
0100
-(r+l)/2-(t+b)/2+(f+n)/2
1
[S] =
2/(r-l)000
0001
02/(t-b)
00
00
-2/(f-n)0
OpenGL Spec
![Page 51: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/51.jpg)
xe
ye
ze
Projeção Paralela(Ortho)
leftright
bottom
top near far
A
nearbottomleftA
fartoprightB
void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_, GLdouble far_ );void gluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top );
![Page 52: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/52.jpg)
Glu Look At
Dados: eye, ref, up (definem o sistema de coordenadas do olho)
Determine a matriz que leva do sistema de Coordenadas dos Objetospara o sistema de Coordenadas do Olho
eye
center
up
Coordenadas dosObjetos
Coordenadas doOlho
void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz);
![Page 53: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/53.jpg)
Calcula o sistema - xe ye ze
center
ze
eye
vup
z0
y0
x0
view
ze = – view / ||view||ze = – view / ||view||
vup
center
eye
z0
y0
x0
view
dados:eye, center, up
dados:eye, center, up
view = center - eyeview = center - eye
![Page 54: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/54.jpg)
Calcula o sistema - xe ye ze
xe = (vup x ze) / ||vup x ze||xe = (vup x ze) / ||vup x ze||
center
eye
vup
z0
y0
x0
view
zexe
ye = ze x xeye = ze x xe
center
eye
vup
z0
y0
x0
view
zexe
ye
eye
vup ze
xe
ye
view
![Page 55: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/55.jpg)
1 0 0 -eyex
0 1 0 -eyey
0 0 1 -eyez
0 0 0 1
[ T ] =
Translada o eye para origem
center
eye
z0
y0
x0
zexe
ye
z0
y0
x0
center
eye
zexe
ye
![Page 56: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/56.jpg)
[ R ] =
xex xey xez 0yex yey yez 0zex zey zez 00 0 0 1
Roda xe ye ze para xo yo zo
xe , xo
ye , yo
ze , zo
z0
y0
x0
center
eye
zexe
ye
![Page 57: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/57.jpg)
Matriz Look At do OpenGL
1 0 0 -eyex
0 1 0 -eyey
0 0 1 -eyez
0 0 0 1
[ T ] =
[ R ] =
xex xey xez 0yex yey yez 0zex zey zez 00 0 0 1
ze = – view / ||view||ze = – view / ||view||
xe = (vup x ze) / ||vup x ze||xe = (vup x ze) / ||vup x ze||
ye = ze x xeye = ze x xe
[ R T ] =?
![Page 58: Transformações Geométricas Rodrigo de Toledo UFRJ, CG1, 2010.2](https://reader035.vdocuments.com.br/reader035/viewer/2022081507/552fc130497959413d8d4c80/html5/thumbnails/58.jpg)
Concatenação das transformações
xe
ye
ze
xe
ye
ze
xe
ye
ze[ T ]
[ R ]
[ P ]
[ T2 ]
[ S ]
xe
ye
ze
111
-1-1-1
near
far
[ T ]
[ R ]
[ P ]
[ T2 ]
[ S ]
center
eye
z0
y0
x0
zexe
ye
z0
y0
x0
center
eye
zexe
ye