Skip to content
Snippets Groups Projects
Verified Commit fa91c405 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

typo

parent a12d9e83
Branches
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ Son équivalent tri-dimensionnel est l'octree (chaque nœud a 8 enfants ou aucun ...@@ -55,7 +55,7 @@ Son équivalent tri-dimensionnel est l'octree (chaque nœud a 8 enfants ou aucun
. . . . . .
Image 64 pixels, arbre 25 neouds. Image 64 pixels, arbre 25 nœuds.
:::: ::::
...@@ -452,63 +452,6 @@ node *matrix_to_qt(int nb_li, int nb_co, int matrix[nb_li][nb_co], int depth) ...@@ -452,63 +452,6 @@ node *matrix_to_qt(int nb_li, int nb_co, int matrix[nb_li][nb_co], int depth)
``` ```
<!--
Deja fait plus haut
# La profondeur?
## Comment implémenter la fonction profondeur?
* Quelle signature?
. . .
```C
entier profondeur(arbre)
```
* Quel pseudo-code (3min, matrix)?
. . .
```C
entier profondeur(arbre)
profondeurs = [0, 0, 0, 0];
si est_feuille(arbre)
retourne 0
sinon
pour i 0 à 3
profondeurs[i] = 1 + profondeur(arbre.enfant[i])
retourne max(p)
```
# La profondeur en C?
## Implémentation (5min, matrix)
. . .
```C
int max(int x, int y) {
return (x >= y ? x : y);
}
int max_depth(int depths[4]) {
int m = depths[0];
for (int i = 1; i < 4; ++i) {
m = max(m, depths[i]);
}
return m;
}
int depth(node *qt) {
int depths[] = {0, 0, 0, 0};
if (is_leaf(qt)) {
return 0;
} else {
depths[i] = 1 + depth(qt->child[i]);
return max_depth(depths);
}
}
``` -->
# Remplir la matrice # Remplir la matrice
## A partir de l'arbre (pseudo-code, 3min, matrix)? ## A partir de l'arbre (pseudo-code, 3min, matrix)?
...@@ -541,156 +484,3 @@ void qt_to_matrix(node *qt, int nb_li, int nb_co, int matrix[nb_li][nb_co]) ...@@ -541,156 +484,3 @@ void qt_to_matrix(node *qt, int nb_li, int nb_co, int matrix[nb_li][nb_co])
} }
} }
``` ```
# Transformations avec un arbre quaternaire
## A faire
* Symétrie axiale (horizontale/verticale).
* Rotation quart de cercle (gauche/droite).
* Compression.
# La symétrie verticale
## Que donne la symétrie verticale de
```
SG=0 | SD=1
21 | 12 | 4 | 4
9 | 7 | 4 | 4
-----------------
1 | 1 | 0 | 31
1 | 1 | 3 | 27
IG=2 | ID=3
```
. . .
```
SG=0 | SD=1
4 | 4 | 12 | 21
4 | 4 | 7 | 9
------------------
31 | 0 | 1 | 1
27 | 3 | 1 | 1
IG=2 | ID=3
```
# La symétrie d'axe vertical
## Comment faire sur une matrice (3min, matrix)?
. . .
\footnotesize
```C
matrice symétrie(matrice)
pour i de 0 à nb_colonnes(matrice) / 2
pour j de 0 à nb_lignes(matrice)
échanger(matrice[i][j], matrice[nb_colonnes(matrice)-1-i][j])
retourne matrice
```
# La symétrie d'axe vertical
## Comment faire sur un arbre?
* Faire un dessin de l'arbre avant/après (5min, matrix)
```
SG=0 | SD=1 SG=0 | SD=1
21 | 12 | 4 | 4 4 | 4 | 12 | 21
9 | 7 | 4 | 4 4 | 4 | 7 | 9
----------------- => ----------------
1 | 1 | 0 | 31 31 | 0 | 1 | 1
1 | 1 | 3 | 27 27 | 3 | 1 | 1
IG=2 | ID=3 IG=2 | ID=3
```
* Écrire le pseudo-code (3min, matrix)
. . .
\footnotesize
```C
arbre symétrie(arbre)
si !est_feuille(arbre)
échanger(arbre.enfant[0], arbre.enfant[1])
échanger(arbre.enfant[2], arbre.enfant[3])
pour i de 0 à 3
symétrie(arbre.enfant[i])
retourne arbre
```
# La symétrie d'axe horizontal
* Trivial de faire l'axe horizontal (exercice à la maison)
# Rotation d'un quart de cercle
## Comment faire sur un arbre?
* Faire un dessin de l'arbre avant/après (5min, matrix)
```
SG=0 | SD=1 SG=0 | SD=1
21 | 12 | 4 | 4 4 | 4 | 31 | 27
9 | 7 | 4 | 4 4 | 4 | 0 | 3
----------------- => -----------------
1 | 1 | 0 | 31 12 | 7 | 1 | 1
1 | 1 | 3 | 27 21 | 9 | 1 | 1
IG=2 | ID=3 IG=2 | ID=3
```
* Écrire le pseudo-code (3min, matrix)
. . .
```C
rien rotation_gauche(arbre)
si !est_feuille(arbre)
échange_cyclique_gauche(arbre.enfant)
pour i de 0 à 3
rotation_gauche(arbre.enfant[i])
```
# Rotation d'un quart de cercle
\footnotesize
## Comment faire sur un arbre?
```
SG=0 | SD=1 SG=0 | SD=1
21 | 12 | 4 | 4 4 | 4 | 31 | 27
9 | 7 | 4 | 4 4 | 4 | 0 | 3
----------------- => -----------------
1 | 1 | 0 | 31 12 | 7 | 1 | 1
1 | 1 | 3 | 27 21 | 9 | 1 | 1
IG=2 | ID=3 IG=2 | ID=3
```
* Écrire le vrai (5min, matrix)
. . .
```C
void rotate(node *qt) {
if (!is_leaf(qt)) {
node *tmp = qt->child[2];
qt->child[2] = qt->child[0];
qt->child[0] = qt->child[1];
qt->child[1] = qt->child[3];
qt->child[3] = tmp;
for (int i=0;i < 4; i++) {
rotate(qt->child[i]);
}
}
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment