(9) rendering-pipeline bv vs. cg - uni-koblenz.decg/ws0910/tmp/09_bv_versus_cg.pdf ·...
TRANSCRIPT
![Page 1: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/1.jpg)
(9) Rendering-PipelineBV vs. CG
Vorlesung„CV-Integration“
U N I V E R S I T Ä TKOBLENZ · LANDAU
„CV-Integration“S. Müller
![Page 2: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/2.jpg)
zyw
zxv
zzv
sxv
szv
syv
spv
ztv
O
T
Wiederholung 1zy
wzx
v
zzv
sxv
szv
syv
spv
stv
O
T
� Projektion� Achsen des Zielkoordinaten-
� Linearkombination� Achsen des Startkoordi-
sz ppvv ⋅= M
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 2 -
( )ssz tppvvv −⋅= R zsz tpp
vvv +⋅= R
� Achsen des Zielkoordinaten-systems und dessen Ursprung in Startkoordinaten gegeben
� Achsen des Startkoordi-natensystems und dessen Ursprung in Zielkoordinaten gegeben
( ) ( ) ssss
zz pzyxtTpvvvvvv ⋅⋅=( ) ss
Tz
Tz
Tz
z ptT
z
y
x
pvv
v
v
v
v ⋅−⋅
=
![Page 3: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/3.jpg)
Matrizen
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 3 -
![Page 4: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/4.jpg)
View-Transformation (Projektion)
� Vektor-Matrix-Notation:
� Matrix-Notation:
( )ww
Tcwc tpp
vvv −⋅= R
wz
y
x
zyx
zyx
zyx
wc pt
t
t
kkk
jjj
iii
ppvvv ⋅
−−−
⋅
=⋅=100
010
001
0
0
0
V
U N I V E R S I T Ä TKOBLENZ · LANDAU
ausmultipliziert
S. Müller - 4 -
zzyx
10001000
Formal handelt es sich bei dieser Gleichung um 4D Vektoren. Auf neue Bezeichner habe ich aber verzichtet…
( )( )( )
=
−−−
=
1010 T
Tw
cTw
Tw
Tww
Tw
wwTw
wwT
w
k
tj
i
ktk
jtj
iti
v
v
vv
v
v
v
ovv
vo
vv
vo
vv
V
![Page 5: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/5.jpg)
Transformationshierarchie (Linearkombination )
� Vektor-Matrix-Notation:
� Matrix-Notation:
wccww tpp
vvv +⋅= R
czzz
yyy
xxx
z
y
x
cw pkji
kji
kji
t
t
t
ppvvv ⋅
=⋅=0
0
0
100
010
001
M
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 5 -
ausmultipliziert
=
10Twwww tkji
v
vvvv
M
zzzz
10001000
Formal handelt es sich bei dieser Gleichung um 4D Vektoren. Auf neue Bezeichner habe ich aber verzichtet…
![Page 6: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/6.jpg)
Bedeutung
� Wenn für eine Koordinaten-transformation (Rotation und Translation) von einem Start (s)- in ein Zielkoordinaten-system (z) eine 4x4 Matrix gegeben ist:
� Dann gilt
( )sz
sz
sz
Tz
Tzs
Tzs
zyx
z
y
x
mmm
mmm
mmmvvv
v
v
v
=
=
852
741
Start-Achsen
Ziel-Achsen
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Und
S. Müller - 6 -
sz pmmmm
mmmm
mmmm
pvv ⋅
=
100012963
11852
10741
Tzszmmmv
963
−−−
=
=
szs
szs
szs
zz
yz
xz
tz
ty
tx
t
t
t
m
m
m
vo
v
vo
v
vo
v
,
,
,
12
11
10
TranslationsvektorIn Zielkoordinaten
Merke:Startachsen – SpalteZielachsen– Zeile
![Page 7: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/7.jpg)
Bsp. 11: Normale des Markers
xv
zv
yv
ctv
jv
T
iv
kv
O A
B
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 7 -
T
� Die Achsen des Weltkoordinatensystems werden durch den Marker wie gezeigt aufgespannt. Weiterhin ist die 4x4 View-Matrix bekannt.� Gesucht ist der Ursprung des Weltkoordinatensystems in
Kamerakoordinaten,� sowie die Normale des Markers in Kamerakoordinaten.
![Page 8: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/8.jpg)
Lösung
� Entsprechend Bsp. 6 gilt:
� In Matrixnotation:
cwwcc tpp
vvv +⋅= R
ccccjjj
iii
j
i
pptzyx
pzyx
zyx
t
t
pvv
v
vvvvvv ⋅=⋅
=⋅
= V0
0
010
001
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Dies entspricht der gegebenen View-Matrix (Abb. von Welt- in Kamerakoordinaten)
� Ursprung des WKS in Kamerakoordinaten: 4. Spalte von V� Normale des Markers in Kamerakoordinaten: 2. Spalte von V (y-
Achse des WKS)
S. Müller - 8 -
wwTwkkkk
c pppzyxt
p v ⋅=⋅
=⋅
= V10
1000
0
1000
100
![Page 9: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/9.jpg)
Bsp. 12: Szenengraph� In welcher Reihenfolge
stehen Translation/Rotation in einem Szenengraph?
Rechtes Vorderrad
Karosserie
7M
3M
( )( )
( )( )
RTM
TRM
TRM
⋅=⋅=
−⋅=
tc
tb
ta
v
v
v
v
)
)
)
L
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Wie ist die Reihenfolge der Gesamttransformation?
� Wie ist die entsprechende Reihenfolge der OpenGL-Kommandos?
S. Müller - 9 -
Vorderrad
37
73
)
)
MMM
MMM
⋅=⋅=
b
a
( )( ) RTM ⋅−= td
tcv
)
)
Lokale Geometrie
![Page 10: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/10.jpg)
Lösung
� Die richtige Reihenfolge:
� Die richtige Reihenfolge
� OpenGL:
glTranslatef(…t3…);
glRotatef(…R3…);
glTranslatef(…t7…);
glRotatef (…R7…);
( ) RTM ⋅= tcv
)
) MMM ⋅=a
U N I V E R S I T Ä TKOBLENZ · LANDAU
glRotatef (…R7…);
// DrawObjekt //
S. Müller - 10 -
73) MMM ⋅=a
![Page 11: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/11.jpg)
Geometrische Interpretation
� Transformationen hintereinander versucht man sich meist in einzelnen Schritten vorzustellen.
� Bsp.: Transformation von lokalen Koordinaten in Weltkoordinaten:
lw ppvv ⋅⋅⋅⋅= 1234 MMMM
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Interpretation in Einzelschritten bedeutet, dass man sich für die Schritte anfangs die Einheitsmatrix denkt:
� Danach wird Schritt für Schritt jede Einheitsmatrix durch die tatsächliche Matrix ersetzt.
� Es gibt 2 übliche Interpretationen:
S. Müller - 11 -
lw pp ⋅⋅⋅⋅= 1234 MMMM
lw ppvv ⋅⋅⋅⋅= EEEE
![Page 12: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/12.jpg)
Geometrische Interpretation
Weltkoordinaten: � man ersetzt von rechts� Interpretation: wir schieben das
Objekt durch die Welt, bzw. wir lesen das OpenGL Programm von unten nach oben.
� Alle Transformationen beziehen
Lokale Koordinatensysteme: � man ersetzt von links� Interpretation: wir verschieben
lokale Koordinatensysteme; bzw. wir lesen das OpenGLProgramm von oben nach unten.
� Alle Transformationen beziehen
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Alle Transformationen beziehen sich dabei auf das Weltkoordinatensystems
Anfangs ist das Objekt im Weltkoordinatensystem geben.
Dann wird M1 auf das Objekt angewandt.
Dann M2 bzgl. dem WKS etc..
� Alle Transformationen beziehen sich dabei auf das jeweilige lokale Koordinatensystem (LKS)
Anfangs ist das Koordinatensystem mit dem Weltkoordinatensystem identisch.
Dann wird M4 auf das LKS angewandt.
Dann M3 bzgl. dem LKS etc.
S. Müller - 12 -
lw ppvv ⋅⋅⋅⋅= 12 MMEE
lw ppvv ⋅⋅⋅⋅= EEEM4
lw ppvv ⋅⋅⋅⋅= EEEE
lw ppvv ⋅⋅⋅⋅= 1MEEE
lw ppvv ⋅⋅⋅⋅= EEEE
lw ppvv ⋅⋅⋅⋅= EEMM 34
![Page 13: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/13.jpg)
Bsp. 13: Geometrische Interpretation
� Als Beispiel verwenden folgenden Szenengraphen.
Karosserie
( )av
T
R
Auto
yv
yv
xv
zv
1C
bva
v
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 13 -
Rechtes Vorderrad
Lokale Geometrie
L
( ) ( ) 2pbapw
vvvv ⋅⋅⋅= TRT
( )bv
T
2pv
xv
zv
yv
xv
zv
2C
W
bva
R
![Page 14: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/14.jpg)
Weltkoordinaten
yv
zv
zv
W
yv
xv
zv
xv
bv
yv
zvW
xv
yv
R
av
yv
zvW
xv
yv
xv
zv
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 14 -
( ) 2pbpw
vvv ⋅⋅⋅= TEE
xv
zv
( ) 2pbpw
vvv ⋅⋅⋅= TRE( ) ( ) 2pbapw
vvvv ⋅⋅⋅= TRT
Das Objekt startet im Weltkoordinatensystem. Zuerst wird die Translation in Richtung b in Weltkoordinaten durchgeführt .
Es folgt die Rotation um den Ursprung des Weltkoordinaten-systems,
Als letztes folgt die Translation in Richtung a in Weltkoordi-naten. Damit ist das Objekt in seiner Zielposition.
Interpretationsrichtung
![Page 15: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/15.jpg)
Lokale Koordinatensystemeyv
xv
zv
av
Interpretationsrichtung
yv
zvW
xv
R
zv
yv
xv
bvz
v
yv
xv
zv
yv
xv
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 15 -
Interpretationsrichtung
( ) ( ) 2pbapw
vvvv ⋅⋅⋅= TRT( ) 2papw
vvv ⋅⋅⋅= ERT( ) 2papw
vvv ⋅⋅⋅= EET
Als letztes folgt die Translation in Richtung b in Bezug zum letzten LKS. Damit ist das LKS – und damit auch das Objekt –in seiner Zielposition.
Es folgt die Rotation um den Ursprung des LKS,
Anfangs ist das LKS mit dem Weltkoordinatensystem identisch. Zuerst wird es in Richtung a – in Bezug zum letzten LKS – verschoben.
![Page 16: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/16.jpg)
Bsp. 14: Transformationskette
e 1
xv
yv
sEinheitswürfel
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Ein Einheitswürfel soll mit Winkel s um die y-Achse gedreht werden. Darauf befindet sich ein weiterer Würfel, der sich mit dreht, aber zusätzlich noch um einen eigenen Winkel e gedreht werden soll.
� Geben sie die Reihenfolge der Transformationen für beide Würfel an.
S. Müller - 16 -
![Page 17: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/17.jpg)
Lösunge
s
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Unterer Würfel
� Oberer Würfel
S. Müller - 17 -
( )syR
( ) ( ) ( )es yyy RTR ⋅⋅ 1
hier_arm.vcproj
![Page 18: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/18.jpg)
Koordinatensysteme
BV versus CG
U N I V E R S I T Ä TKOBLENZ · LANDAU
![Page 19: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/19.jpg)
Ziel
� Das Ziel der folgenden Folien ist eine vereinheitlichte Sicht (CG und BV) der Transformation einer Weltkoordinate pw in eine Pixelkoordinate pp.
� Die Objekte liegen dabei bereits in Weltkoordinaten vor (keine Modeltransformation).
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Die Details zur Herleitung der Matrizen s. CG1
S. Müller - 19 -
![Page 20: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/20.jpg)
(diskrete) Pixelkoordinaten p
pxv
pyv
0 B
H
L
L
pxv
BVpy ,v
0 B
H
L
L
−=
yBV
x
y
x
pH
p
p
p
,
zv
zv
U N I V E R S I T Ä TKOBLENZ · LANDAU
� CG (OpenGL)� Ursprung unten links� Bildauflösung B und H (in
Pixeln)
� Blick entlang der z-Achse� Linkssystem
� BV (oftmals…)� Ursprung oben links� Bildauflösung B und H (in
Pixeln)
� Blick entlang der z-Achse� Rechtssystem
S. Müller - 20 -
x0 B BVpy ,v
![Page 21: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/21.jpg)
Kamerakoordinatensysteme c
� CG (OpenGL) � BV (oftmals…)
jv
iv
kv
O
O
BVjv
iv
BVkv
−−=
TBV
TBV
T
T
T
T
k
j
i
k
j
i
v
v
v
v
v
v
U N I V E R S I T Ä TKOBLENZ · LANDAU
� CG (OpenGL)� Kamera im Ursprung� x nach rechts� y nach oben� wir sehen entlang der
negativen z-Achse� Rechtssystem
� BV (oftmals…)� Kamera im Ursprung� x nach rechts� y nach unten� wir sehen entlang der
positiven z-Achse� Rechtssystem
S. Müller - 21 -
![Page 22: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/22.jpg)
Bsp. 1: View-Matrix aus BV-MatrixR
BVjv
iv
BVkv
xv
zv
yv
O
wpv
tv
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Die Kamera wird mit Hilfe eines BV-Tools beschrieben durch die Matrix R und den Vektor t mit
� Wie lautet die OpenGL Viewmatrix?
S. Müller - 22 -
zv
( )tpp wc
vvv −⋅= R
=
852
741
630
rrr
rrr
rrr
R
=
z
y
x
t
t
t
tv
![Page 23: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/23.jpg)
Lösung
� Es gilt:
� Daher:
=
=
=
=
z
y
x
wBV
wBVww
t
t
t
t
r
r
r
k
r
r
r
j
r
r
r
ivvvv
;;;
8
5
2
7
4
1
6
3
0
−−
=
−−
=
=210
;; r
r
kr
r
jr
r
ivvv
U N I V E R S I T Ä TKOBLENZ · LANDAU
� View-Matrix:
S. Müller - 23 -
−−=
−−=
=
8
5
7
4
6
3 ;;
r
rk
r
rj
r
ri www
vvv
( )( )( )
( )
++−−−++−−−++−
=
−−−
=
100010852852
741741
630630
rtrtrtrrr
rtrtrtrrr
rtrtrtrrr
ktk
jtj
iti
zyx
zyx
zyx
Tww
Tw
wwTw
wwT
w
v
v
ovv
vo
vv
vo
vv
V
![Page 24: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/24.jpg)
Projektion (BV)
U N I V E R S I T Ä TKOBLENZ · LANDAU
![Page 25: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/25.jpg)
Projektion
� Zur Definition der Projektion wird die Brennweite F verwendet.
1
0 F1
F
1
zv
0
iv
BVkv
1ixv
1
1−
1−
1
F1
F1
iyv
M
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Die Projektion geschieht durch Division durch die z-Koordinaten.
� Nach dem Strahlensatz entspricht dies der Projektion auf die z = 1 Ebene.
� Sie legt den Öffnungswinkel der Kamera fest.
� F ist die Distanz zur Bildfläche mit (halber) Höhe 1
� Genauer: der Bildausschnitt deckt (in Kamerakoordinaten) den Bereich von -1/F bis 1/F auf der z = 1 Ebene ab.
S. Müller - 25 -
BVjv
iv
![Page 26: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/26.jpg)
Bildkoordinaten i� Da die perspektivische Division
erst am Ende ausgeführt wird, werden die Koordinaten als homogene Koordinaten gekennzeichnet.
� Es gilt:
BVci pF
F
p ,00
00~ vv ⋅
=
0
iv
BVkv
1ixv
1
1−
1−
1
F1
F1
iyv
M
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Das Bildkoordinatensystem wird mit dem Buchstaben igekennzeichnet und hat seinen Ursprung in der Mitte.
� Anm.: manchmal wird auch nur die Einheitsmatrix quasi als didaktisches Konstrukt für die Projektion verwendet und F den weiteren Transformationen zugeordnet. Das i-Koordinaten-system entspricht dann dem Kamerakoordinatensystem mit Ursprung bei zc=1.
S. Müller - 26 -
100
BVjv
iv
![Page 27: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/27.jpg)
Kamera
mpv
cpv
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Original Frustum (außen). Die Kamera definiert daraus einen verschobenen, gescherten und skalierten Bereich.
� Das Bild der Kamera - auf einem normalen Bildschirm angezeigt -liefert ein verzerrtes Bild.
� Das Rendering muss genau diese Verzerrung für eine pixel-genaue Überlagerung erreichen
S. Müller - 27 -mc ppvv → :Gesucht
![Page 28: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/28.jpg)
Intrinsische Parameter
� Die Parameter der Kamera werden unterschieden in extrinsische (Lage und
Orientierung im Raum) und intrinsische Parameter.
� Üblich ist ein Kameramodell mit 6 intrinsischen
=100
0 yy
xx
hdF
hsdF
K
−
−−
=− 0
2
1
F
dh
F
d
hF
dsh
F
d
F
dsd
F
d
yyy
xyyxyxx
K
U N I V E R S I T Ä TKOBLENZ · LANDAU
mit 6 intrinsischen Parametern, die oft so beschrieben werden� Hauptpunkt hx und hy
� Brennweite F� Skew (Scherung) s� Breite und Höhe eines
Sensors dx, dy
� Die Abbildung von Kamera-in Pixelkoordinaten geschieht mit Hilfe der Matrix K.
S. Müller - 28 -
cyy
xx
m phdF
hsdF
pvv ⋅
=100
0~
−=
100
0FF
K
![Page 29: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/29.jpg)
Pixelkoordinaten m
� Oft verwendet:� Der Ursprung ist in der Mitte
des Bildes. � Die Ausdehnung ist im
Bereich von -1 bis 1
� Die Bildauflösung B x H spielt keine Rolle
mxv
1−
M
11−
U N I V E R S I T Ä TKOBLENZ · LANDAU
keine Rolle � sie taucht in der K-Matrix
auch nicht auf
� Die (diskreten) Pixelkoordi-naten p in einem gerasterten Bild erhält man durch die gleiche Viewporttrans-formation, wie in der CG (s. später)
� Dies entspricht dem kanonischen Volumen der CG (ohne die Tiefe), bzw. den normalized device coordinates
� Der Ursprung M liegt in Kamerakoordinaten bei
S. Müller - 29 -
1myv
( )100=cM
![Page 30: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/30.jpg)
Parameter (genauer) Frustum in Kamerakoordinaten (-1 bis 1)c
c
i
ixv
i Frustum in Bildkoordinaten (-1 bis 1)
m
mhv
m
mxv
yd
xd
myv
U N I V E R S I T Ä TKOBLENZ · LANDAU
� hx und hy ist die Verschiebung des Ursprungs des Pixelkoordinaten-systems m in den Ursprung des Bildkoordinatensystems i (in Pixelkoordinaten)
� dx und dy sind die halbe horizontale, bzw. vertikale Ausbreitung des Pixelkoordinatensystems (in Bildkoordinaten)
� s ist die Scherung als Abstand zur y-Achse des Kamerakoordinaten-systems bei yc = 1 (in Kamera-koordinaten)
S. Müller - 30 -
iyv
iyv
BVjv
Fdss y=′s
s′my
![Page 31: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/31.jpg)
Deutung von K
� Die K-Matrix
� entspricht einer Linear-kombination gem. Fall 4 � Die Spalten von K sind die
cyy
xx
m phdF
hsdF
pvv ⋅
=100
0~
c
m
cxv
cyv
mhv
myv
mxv
U N I V E R S I T Ä TKOBLENZ · LANDAU
kombination gem. Fall 4
� mit
� Die Spalten von K sind die Achsen des Kamera-koordinatensystems in Pixelkoordinaten.
S. Müller - 31 -
mccmm hpp
vvv +⋅= M
=
=0
;
0
0 ycm
xcm dF
s
y
dF
xvv
=
=1
;
100
00
0
y
x
my
xcm h
h
hdF
sdFv
M
![Page 32: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/32.jpg)
010
001
y
x
d
d
′
010
01 s
=100
10
01~
y
x
m h
h
pv ⋅ ⋅
cpF
Fv⋅
00
00⋅
Pixelkoordinaten
s′
hv
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 32 -
100
100
100
100
F1
Kamerakoordinaten (Inverse)
xd
yd
![Page 33: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/33.jpg)
100
010
001
y
x
d
d
′
100
010
01 s
=100
10
01~
y
x
m h
h
pv ⋅ ⋅
cpF
Fv⋅
100
00
00⋅
Objekt transformierenInterpretationsrichtung
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 33 -
100 100 100 100
Lok. Koordinatenachsen transformieren
Alle Matrizen: Identität Nur Translation Zusätzlich Scherung Zus. Skalierung Zus. Skalierung
Interpretationsrichtung
![Page 34: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/34.jpg)
Projektion (OpenGL)
(ideale Kamera – symmetrisches Frustum)
U N I V E R S I T Ä TKOBLENZ · LANDAU
![Page 35: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/35.jpg)
Koordinatensysteme
� und Bildschirmkoordinaten p� nach der Viewport-
Transformation� Diskrete Werte in der Dimension
der Bildauflösung� Linkssystem, y-Achse nach
oben, Blick entlang von z
0
jv
iv
kv
−
1
1−
1−
1
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Hier gibt es nur � Kamerakoordinaten c (Blick
entlang der neg. z-Achse, Rechtssystem)
� Normalized Device Coordinatesbzw. kanonisches Volumen (nach der perspektivischen Divison von -1 bis 1 in alle drei Raumrichtungen, Linkssystem)
S. Müller - 35 -
pxv
pyv
0 B
H
L
L
![Page 36: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/36.jpg)
Symmetrisches Frustum (OpenGL) f
n
kv
iv
O
θ
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Perspektive� Voller vertikaler Öffnungswinkel θ (in Grad!)
� Breiten-/Höhenverhältnis aus Bildauflösung B x H� near und far
S. Müller - 36 -
gluPerspective( θ, B/H, n, f)
![Page 37: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/37.jpg)
Projektion
� P setzt sich zusammen aus 3 Transformationen:� Spiegelung von Rechts- in
Linkssystem� Perspektivische Projektion� Orthographische Projektion
MMMP ⋅⋅=
iv
0
f
jv
zv
2/θ1
zv
0
n
F
B
1f
2/θ ′
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Die Bildebene ist bei z = 1 und hat (in Kamerakoordinaten)
die Ausdehnung
� Aus der Zeichnung ergibt sich:
S. Müller - 37 -
LRPERSPORTHO MMMP →⋅⋅=
F=2cotθ
0
H
B
1×HB FB
H ⋅=′ 2cotθ
2/θ ′
![Page 38: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/38.jpg)
Projektion
� Perspektivische Projektion
−+=
0100
00
0010
0001
fnfnPERSPM
Die z-Koordinaten wird abgebildet auf:
(nach der perspektivischen Division)
zz pfnfnp −+=′
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Orthographische Projektion
S. Müller - 38 -
+−⋅
−
⋅
=
10002
100
0010
0001
1000
02
00
000
000
nf
nf
F
FB
H
ORTHOM
Verschiebung und Skalierung in das kanonische Volumen
![Page 39: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/39.jpg)
Projektion
� Alles zusammen
−⋅
−+⋅
+
⋅
=
⋅⋅= →
0100
0010
0001
00
0010
0001
200
000
000
fnfnnfF
FB
H
P
MMMP LRPERSPORTHO
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 39 -
−
−+
−+
− 1000
0100
0100
00
1000
200 fnfn
fn
nf
nf
−−−
+
⋅
=
0100
200
000
000
fn
fn
fn
nfF
FB
H
PResultat vongluPerspective( θ, B/H, n, f)mit 2cotθ=F
![Page 40: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/40.jpg)
Identischer CodeGLfloat m[16] = {
(float)H/B*F, 0, 0, 0,
0, F, 0, 0,
0, 0, (f+n)/(n-f), -1,
0, 0, 2.0*f*n/(n-f), 0};
glMatrixMode( GL_PROJECTION);
glLoadIdentity ();
#define M_PI 3.1415926535897932384
#define RAD_DEG *180.0/M_PI
float th = 2*atan(1.0/F) RAD_DEG;
glMatrixMode( GL_PROJECTION);
glLoadIdentity ();
U N I V E R S I T Ä TKOBLENZ · LANDAU
glLoadIdentity ();
glMultMatrixf( m);
glLoadIdentity ();
gluPerspective(th,(float)B/H,n,f);
S. Müller - 40 -
![Page 41: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/41.jpg)
Gegenüberstellung
� Die ideale Kamera ist für manche Kameras bereits eine gute Abschätzung.
� Damit vereinfacht sich die K-Matrix zu:
=100
0 yy
xx
hdF
hsdF
K
′
′⋅
=100
00
00
F
FB
H
K
U N I V E R S I T Ä TKOBLENZ · LANDAU
eine gute Abschätzung.� Hier gilt:
� Hauptpunkt in der Mitte� Keine Scherung� Skalierung in y-Richtung und
in x-Richtung ergibt sich aus Bildauflösung
� Diese Projektion kann mit OpenGL direkt gerendert werden durch:
� wobei
S. Müller - 41 -
BHdd xy =
F
FdF y
′=
==′=
1arctan2
2tan1
2cot
θ
θθ
gluPerspective( θ, B/H, n, f)
![Page 42: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/42.jpg)
Bsp. 2: Symmetrisches Frustum
� Gegeben sind die 6 intrinsischen Parameter einer Kamera .
� Die Bildauflösung sei B x H.
Prüfen sie, ob es sich um eine ideale Kamera handelt .
yxyx hhddsF ,,,,,
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Prüfen sie, ob es sich um eine ideale Kamera handelt .
S. Müller - 42 -
![Page 43: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/43.jpg)
Lösung
� Der Hauptpunkt liegt in der Bildmitte:
� Keine Scherung
=100
0 yy
xx
hdF
hsdF
K
0;0 == yx hh
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Keine Scherung
� Skalierung in y-Richtung und in x-Richtung ergibt sich aus Bildauflösung
S. Müller - 43 -
0=s
B
H
d
d
x
y =
![Page 44: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/44.jpg)
Projektion (OpenGL)
Allgemeine K-Matrix
U N I V E R S I T Ä TKOBLENZ · LANDAU
![Page 45: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/45.jpg)
K-Matrix in OpenGL
� Dies ist die OpenGL-Projektionsmatrix aus den K-Matrix-Parametern.
−−
−−+−
−−
=
0100
200
00
0
nf
fn
nf
nfhdF
hsdF
yy
xx
P
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Dies ist die OpenGL-Projektionsmatrix aus den K-Matrix-Parametern.
GLfloat k[16]; /*K-Matrix*/
k[ 0] = F/dx; k[ 1] = 0; k[ 2] = 0; k[ 3] = 0;
k[ 4] = -skew; k[ 5] = F/dy; k[ 6] = 0; k[ 7] = 0;
k[ 8] = -hx; k[ 9] = hy; k[10] = -(f+n)/(f-n); k[11] = -1;
k[12] = 0; k[13] = 0; k[14] = -2.0*f*n/(f-n); k[15] = 0;
...
glMatrixMode( GL_PROJECTION);
glLoadIdentity();
glMultMatrixf( k);
S. Müller - 45 -
![Page 46: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/46.jpg)
Begründung
−−
⋅
−+⋅
−+
−⋅
−=
1000
0100
0010
0001
0100
00
0010
0001
1000
200
00
0
1000
0100
0010
0001
fnfnfn
fn
nf
hdF
hsdF
yy
xx
P
- Blick entlang pos. Z-Achse - y-Achse nach unten (BV)
Nicht-lineare Skalierung der Tiefenwerte
K-Matrix inkl. Verschiebung und Skalierung der
y-Achse wieder nach oben (CG)
U N I V E R S I T Ä TKOBLENZ · LANDAU S. Müller - 46 -
−−
−−+−
−−
=
0100
200
00
0
nf
fn
nf
nfhdF
hsdF
yy
xx
P
der Tiefenwerteund Skalierung der Tiefenwerte in das kanonische Volumen (vor persp. Division)
nach oben (CG)
![Page 47: (9) Rendering-Pipeline BV vs. CG - uni-koblenz.decg/ws0910/tmp/09_BV_versus_CG.pdf · Transformationshierarchie (Linearkombination ) Vektor-Matrix-Notation: Matrix-Notation: c w c](https://reader030.vdocuments.us/reader030/viewer/2022040701/5d5e008288c9932f2d8b7ea3/html5/thumbnails/47.jpg)
Viewport � Die Viewport-Transformation geschieht in der OpenGL-Pipeline explizit (also keine weitere Matrix).
� Dabei wird das kanonische Volumen (von -1 bis 1 in alle drei Raumrichtungen) auf die Bildschirmkoordinaten (von 0 bis H-1, bzw. von 0 bis B-1) px
v
pyv
0 B
H
L
L
U N I V E R S I T Ä TKOBLENZ · LANDAU
� Bild� Pixel im Mittelpunkt bei
� Bildauflösung B und H (in Pixeln)
bis H-1, bzw. von 0 bis B-1) und z auf den Bereich von 0 bis 1 abgebildet.
� Als Matrix wäre das
S. Müller - 47 -
pxv
0 B
( )5.05.0 ++ yx
glViewport(0, 0, B, H)
=
1000
212100
2020
2002
HH
BB
ViewportM