![Page 1: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/1.jpg)
Institut für Kartographie und GeoinformationProf. Dr. Lutz Plümer
Diskrete Mathematik I
Vorlesung 3
28.10.99
-Arrays-
![Page 2: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/2.jpg)
2
Übersicht
• Arrays (am Beispiel von Java)• Unterschiede in der Verwendung primitiver Datentypen/Arrays• Arrays - beachte• Zugriff• Beispiele
– Skalarprodukt
– Multiplikation von Matrizen
• Punkte als Arrays• Transformationen• Homogene Koordinaten
– Transformationen
![Page 3: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/3.jpg)
3
Arrays (am Beispiel von Java)
Unterscheidungen• primitive Datentypen:
– booleanchar byte short int long float1 2 1 2 4 8 4Byte
– Größe steht von vorneherein fest
• Referenztypen– Arrays– Strings– Objekte– Größe erst zur Laufzeit bekannt
![Page 4: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/4.jpg)
4
Unterschiede in der Verwendung primitiver Typen / Arrays
Primitive Typen
int i, j; // Deklaration
i = 0; // Initialisierung
j = 1;
oder:
int i = 0, j = 1;
/* Deklaration und Initialisierung gleichzeitig */
Arrays
int a[], b[]; // int - Array
float v[], w[]; // float- Array
float m1[][];// float - Matrix
a = new int[5]; // Erzeugungw = new float[3];m1 = new float[3][3];
oder:int b[] = {1,2,3,4,5};/* Deklaration, Erzeugung und Initialisierung gleichzeitig */
![Page 5: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/5.jpg)
5
Arrays - beachte:
• 3 Schritte– Deklarieren– Erzeugen (Instanz bilden, Instanziieren)– Initialisierungen
• Im Unterschied zu Pascal– die Größe n des Arrays wird erst zum Zeitpunkt der
Erzeugung (new double[3] ) festgelegt
• Die Indizierung läuft von 0 ... n - 1
0 n -1
![Page 6: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/6.jpg)
6
Zugriff
int a[][] = new int[2][3];
a[0][0] = 1;
a[0][1] = 2;
a[0][2] = 3;
a[1][0] = 4;
a[1][1] = 5;
a[1][2] = 6;
654
321
![Page 7: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/7.jpg)
7
Beispiel: Skalarprodukt
int v[], w[];
v = {1,2,3};
w = {4,5,6};
int iprod = 0;
for (int i = 0; i < 3; i++)
iprod = iprod + v[i] * w[i];
for-Schleife
for(init; test; update)
i++ i = i + 1
![Page 8: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/8.jpg)
8
222120
121110
020100
222120
121110
020100
bbb
bbb
bbb
aaa
aaa
aaa
01c
=c[i,k]= a[i,j]*b[j,k]
Beispiel: Multiplikation von Matrizen
![Page 9: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/9.jpg)
9
float a[][], b[][], c[][];
..
float c[][] = {{0,0,0}, {0,0,0}, {0,0,0}};
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
c[i][j] = c[i][j] +
a[i][k] *
b[k][j];
Beispiel: Multiplikation von Matrizen
![Page 10: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/10.jpg)
10
Px
y
Punkte als Arrays
P p x yx
y: ( )
![Page 11: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/11.jpg)
11
Verschiebung (Translation)
t
Px
y
P p x yx
y: ( )
![Page 12: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/12.jpg)
12
P´
Verschiebung (Translation)
P
t
x
y
P p x yx
y': ' ( ' ')
'
'
![Page 13: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/13.jpg)
13
Verschiebung (Translation)
P´
Px
y
tyt
tx
p p t
x
y
x
y
t
t
x t
y tx
y
x
y'
'
'
![Page 14: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/14.jpg)
14
P
Drehung (um den Ursprung)
x
y
![Page 15: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/15.jpg)
15
P´
Drehung (um den Ursprung)
P
x
y
![Page 16: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/16.jpg)
16
Drehung (um den Ursprung)
cossin
sincos
cossin
sincos
'
'
yx
yx
y
x
y
x
P´
P
x
y
p R p'
![Page 17: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/17.jpg)
17
2 8
2
6
Scherung (Zoom in, Zoom out)
P
x
y
![Page 18: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/18.jpg)
18
3
9
4 16
P´
Scherung (Zoom in, Zoom out)
sx x
ysy
p S p
x
y
s
s
x
y
s x
s yx
y
x
y'
'
'
0
0
![Page 19: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/19.jpg)
19
P
homogene Koordinaten
Homogene Koordinaten
Px
y:
P
x
y:
1
x
y
![Page 20: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/20.jpg)
20
Translation in homogenen Koordinaten
100
10
01
: y
x
t
t
T
P´
Px
y
tyt
tx
t
t
tx
y:
![Page 21: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/21.jpg)
21
11100
10
01
1
'
'
y
x
y
x
ty
tx
y
x
t
t
y
x
Translation in homogenen Koordinaten
P´
Px
y
tyt
tx
![Page 22: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/22.jpg)
22
Drehung in homogenen Koordinaten
R:cos sin
sin cos
100
0cossin
0sincos
:
R
P´
P
x
y
![Page 23: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/23.jpg)
23
x
y
x
y
x y
x y
'
'
cos sin
sin cos
cos sin
sin cos
1
0
0
0 0 1 1 1
P´
P
x
y
Drehung in homogenen Koordinaten
![Page 24: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/24.jpg)
24
Scherung in homogenen Koordinaten
y
x
s
sS
0
0 :
100
00
00
: y
x
s
s
S
sx P´
x
ysy
![Page 25: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/25.jpg)
25
Scherung in homogenen Koordinaten
11100
00
00
1
'
'
ys
xs
y
x
s
s
y
x
y
x
y
x
sx P´
x
ysy
![Page 26: Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung 3 28.10.99 -Arrays-](https://reader035.vdokument.com/reader035/viewer/2022070310/55204d6649795902118bbb83/html5/thumbnails/26.jpg)
Homogene Koordinaten
• Repräsentation in homogenen Koordinaten führt zu „homogener“ Modellierung der Operationen
• Implementierung der Matrizenmultiplikation in Hardware bringt Effizienz
2D 3 x 3 - Matrix
3D 4 x 4 - Matrix