commit 5eb7f92f4deb07d587dfdbf3e3a07dba76ee90e7
parent a32ec00566fe6d7d151c3f3c3bf001b9bb7a1cbd
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Wed, 15 Dec 2010 03:29:52 +0100
Figures zig-zag.
Diffstat:
| M | rapport.tex | | | 416 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- |
| M | test.tex | | | 236 | +++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- |
2 files changed, 542 insertions(+), 110 deletions(-)
diff --git a/rapport.tex b/rapport.tex
@@ -984,46 +984,208 @@ Il ne serait pas du tout utile de commencer par tous les couples $(0,y_{i})$ te
Une solution, pour tous les nombres naturels, serait de parcourir un graphe comme suit:
\begin{figure}[h!]
+ %% «Paramètres»
+ \xdef\maxdots{23}
+ \xdef\maxdotsX{5}
+ \xdef\maxdotsY{5}
+ \xdef\maxnums{20}
+ \xdef\maxcoordsX{3}
+ \xdef\maxcoordsY{3}
+
+ %% ===== Code is below =====
+
+ %% Macros crades
+ \makeatletter
+ \def\myadv#1#2{%
+ \xdef\incr@backup{\the\@tempcnta}%
+ \@tempcnta=#1{}%
+ \advance\@tempcnta by #2{}%
+ \xdef#1{\the\@tempcnta}%
+ \@tempcnta=\incr@backup{}%
+ }
+ \def\incr#1{%
+ \myadv#1{1}%
+ }
+ \def\decr#1{%
+ \myadv#1{-1}%
+ }
+ \makeatother
\centering
\begin{tikzpicture}[
- dot/.style = {
- circle,
- fill=black,
- inner sep=0.5pt
- },
- arc/.style = {
- ->,
- >=stealth
- }
+ scale=1.4,
+ dot/.style={
+ circle,
+ inner sep=0.7pt,
+ fill=black
+ },
+ dotphantom/.style={
+ circle,
+ inner sep=3pt,
+ fill=none,
+ draw=none
+ },
+ numero/.style={rectangle, fill=white, inner sep=2pt, text=red!50!black},
+ coord/.style={darkgray, scale=.8},
+ %
+ bigarrow/.style={
+ ->,
+ thick,
+ draw=green!50!black
+ },
+ constatation1/.style={
+ circle,
+ inner sep=1.5pt,
+ outer sep=0.8pt,
+ fill=white,
+ text=red,
+ anchor=south,
+ rotate around={45:(0,0)}
+ },
+ constatation2/.style={
+ text=green!50!black,
+ node distance=0.6cm
+ }
]
- \foreach \xpos in {0, ..., 4} {
- \foreach \ypos in {0, ..., 4} {
- \node[dot] at (\xpos,-\ypos) {};
+
+ % %% Digonale
+ % \draw[bigarrow,red] (0,0) -- (.5*7.5,-.5*7.5);
+
+ % Définitions pour le code ci-dessous.
+ \xdef\i{0}
+ \xdef\x{0}
+ \xdef\y{0}
+ \xdef\corner{3}
+ \xdef\sidelen{0}
+ \xdef\nextsidelen{1}
+ \xdef\direction{3}
+ \incr\maxnums
+ \incr\maxcoordsX
+ \incr\maxcoordsY
+
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {1,...,\maxcoordsY} {
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{0}
}
}
- \draw[arc] (0,-0) -- (1,-0);
+ \def\reallysmallcheat#1{%
+ \ensuremath{\hphantom{\vphantom{X}}_{\hphantom{\vphantom{X}}_{#1}}}
+ }
+ \def\drawnode{%
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ \node[dotphantom] (phantom-\x-\y) at (\x,-\y) {};
+ \ifnum\maxnums>\i
+ % \ifnum\corner=0 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\corner=1 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=2 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=3 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\direction=0 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \else
+ % \ifnum\direction=2 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \fi\fi\fi\fi\fi\fi
+ \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i};
+ \fi
+ \ifnum\maxcoordsX>\x
+ \ifnum\maxcoordsY>\y
+ % \ifnum\corner=0 \node[coord,anchor=south east] at (dot-\x-\y.north west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=1 \node[coord,anchor=north east] at (dot-\x-\y.south west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=2 \node[coord,anchor=north west] at (dot-\x-\y.south east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=3 \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=0 \node[coord,anchor=east] at (dot-\x-\y.west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=1 \node[coord,anchor=north] at (dot-\x-\y.south) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=2 \node[coord,anchor=west] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=3 \node[coord,anchor=south] at (dot-\x-\y.north) {\reallysmallcheat{(\x, \y)}}; \fi\fi\fi\fi\fi\fi\fi\fi
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{1}
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
+ \fi
+ \fi
+ }
+ \def\drawlinknode{%
+ \drawnode%
+ \draw[->] (phantom-\oldx-\oldy) -- (phantom-\x-\y);%
+ }
+ \def\mystep{%
+ \incr\i%
+ \xdef\oldx{\x}%
+ \xdef\oldy{\y}%
+ }
+ \def\changedir#1{%
+ \xdef\direction{#1}%
+ \xdef\corner{#1}%
+ }
- \draw[arc] (1,-0) -- (0,-1);
- \draw[arc] (0,-1) -- (0,-2);
+ \drawnode
+ \mystep \incr\x
+ \xdef\cornerc{0}
+
+ \foreach \pos in {1,...,\maxdots} {
+ % Detect when we are at the end of this edge.
+ \ifnum\sidelen=0
+ \ifnum\direction=0 \changedir{1} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=1 \changedir{2} \xdef\sidelen{\nextsidelen} \else
+ \ifnum\direction=2 \changedir{3} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=3 \changedir{0} \xdef\sidelen{\nextsidelen} \fi\fi\fi\fi% Brin d'acier
+
+ \fi
+ % Draw node and link to previous, step counters
+ \drawlinknode \mystep
+ %% Se déplacer vers ↙↓↗→
+ \ifnum\direction=0 \incr\y \decr\x \fi
+ \ifnum\direction=1 \incr\y \fi
+ \ifnum\direction=2 \decr\y \incr\x \fi
+ \ifnum\direction=3 \incr\x \fi
+ \decr\sidelen
+ \xdef\corner{4}%% 4 == pas de coin-coin.
+ }
- \draw[arc] (0,-2) -- (1,-1);
- \draw[arc] (1,-1) -- (2,-0);
- \draw[arc] (2,-0) -- (3,-0);
+ \foreach \x in {0,...,\maxdotsX} {
+ \foreach \y in {1,...,\maxdotsY} {
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ }
+ }
+ \decr\maxcoordsX
+ \decr\maxcoordsY
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {0,...,\maxcoordsY} {
+ \node[dot,fill=none] (fakedot-\x-\y) at (\x,-\y) {};
+ \expandafter\ifnum\csname dotxypresent-\x-\y\endcsname=0
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (fakedot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (fakedot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
+ \fi
+ }
+ }
- \draw[arc] (3,-0) -- (2,-1);
- \draw[arc] (2,-1) -- (1,-2);
- \draw[arc] (1,-2) -- (0,-3);
- \draw[arc] (0,-3) -- (0,-4);
+ % \foreach \i in {1, ...,6}{
+ % \node[constatation1] at (.5*\i,-.5*\i) {\i};
+ % }
+ % \node[constatation1] at (.5*7,-.5*7) {\vdots};
- \draw[arc] (0,-4) -- (1,-3);
- \draw[arc,dashed] (1,-3) -- (2,-2);
+ % \node[coordinate] (fake0-0) at (0,0) {};
+ % \node[coordinate] (fake1-0) at (1,0) {};
+ % \node[coordinate] (fake3-0) at (3,0) {};
+ % \node[coordinate] (fake5-0) at (5,0) {};
+ % \node[coordinate] (fake0-2) at (0,-2) {};
+ % \node[coordinate] (fake0-4) at (0,-4) {};
+ % \node[coordinate] (fake0-6) at (0,-6) {};
+ % \node[constatation2, above left of=fake0-0] {0};
+ % \node[constatation2, above of=fake1-0] {1};
+ % \node[constatation2, above of=fake3-0] {6};
+ % \node[constatation2, above of=fake5-0] {15};
+ % \node[constatation2, left of=fake0-2] {3};
+ % \node[constatation2, left of=fake0-4] {10};
+ % \node[constatation2, left of=fake0-6] {21};
\end{tikzpicture}
- \caption{Codage d'un couple d'entiers naturels}% TODO : caption
+ \caption{Codage d'un couple d'entiers relatifs}%% TODO : caption
\label{fig:codage-zigzag}
\end{figure}
%% TODO: Il faudrait ajouter les coordonnées (0,0), (1,0), (0,1), et les codes correspondants au graphe ci-dessus, etc. VOIR LES DIAGRAMMES QUE J'AI DONNE A BERTRAND
+%% TODO : Réponse georges : c'est fait.
Dans la figure \ref{fig:codage-zigzag}, on commence par le couple $(0,0)$, puis on procède aux couples $(1,0)$, $(0,1)$, $(0,2)$, $(1,1)$, $(2,0)$, $(3,0)$, $(2,1)$, $(1,2)$, $(0,3)$, $(0,4)$\ldots L'algorithme pour simplement parcourir les couples de cette façon consisterait tout d'abord de déclarer et d'intialiser trois variables globales~: le point de départ, \lstinline!*current*!, et les valeurs maximales courantes de $x$ et de $y$, c'est-à-dire \lstinline!*max-x*! et \lstinline!*max-y*!. En LISP, ceci pourrait être codé comme suit~:
@@ -1136,7 +1298,209 @@ Voici une trace de cette fonction en passant \lstinline!*current*! égal à \lst
Donner les fonctions de codage et de décodage $f_1(z)\rightarrow x$ et $f_2(z)\rightarrow y$.
\end{enonce}
-TODO: Même figure que la précédente, mais avec les 'constatations' ajoutées (je ferai un diagramme papier pour qu'on sache ce que je veux ici)
+\begin{figure}[h!]
+ %% «Paramètres»
+ \xdef\maxdots{23}
+ \xdef\maxdotsX{5}
+ \xdef\maxdotsY{5}
+ \xdef\maxnums{20}
+ \xdef\maxcoordsX{3}
+ \xdef\maxcoordsY{3}
+
+ %% ===== Code is below =====
+
+ %% Macros crades
+ \makeatletter
+ \def\myadv#1#2{%
+ \xdef\incr@backup{\the\@tempcnta}%
+ \@tempcnta=#1{}%
+ \advance\@tempcnta by #2{}%
+ \xdef#1{\the\@tempcnta}%
+ \@tempcnta=\incr@backup{}%
+ }
+ \def\incr#1{%
+ \myadv#1{1}%
+ }
+ \def\decr#1{%
+ \myadv#1{-1}%
+ }
+ \makeatother
+ \centering
+ \begin{tikzpicture}[
+ scale=1.4,
+ dot/.style={
+ circle,
+ inner sep=0.7pt,
+ fill=black
+ },
+ dotphantom/.style={
+ circle,
+ inner sep=3pt,
+ fill=none,
+ draw=none
+ },
+ numero/.style={rectangle, fill=white, inner sep=2pt, text=red!50!black},
+ coord/.style={darkgray, scale=.8},
+ %
+ bigarrow/.style={
+ ->,
+ thick,
+ draw=green!50!black
+ },
+ constatation1/.style={
+ circle,
+ inner sep=1.5pt,
+ outer sep=0.8pt,
+ fill=white,
+ text=red,
+ anchor=south,
+ rotate around={45:(0,0)}
+ },
+ constatation2/.style={
+ text=green!50!black,
+ node distance=0.6cm
+ }
+ ]
+
+ %% Digonale
+ \draw[bigarrow,red] (0,0) -- (.5*7.5,-.5*7.5);
+
+ % Définitions pour le code ci-dessous.
+ \xdef\i{0}
+ \xdef\x{0}
+ \xdef\y{0}
+ \xdef\corner{3}
+ \xdef\sidelen{0}
+ \xdef\nextsidelen{1}
+ \xdef\direction{3}
+ \incr\maxnums
+ \incr\maxcoordsX
+ \incr\maxcoordsY
+
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {1,...,\maxcoordsY} {
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{0}
+ }
+ }
+
+ \def\reallysmallcheat#1{%
+ \ensuremath{\hphantom{\vphantom{X}}_{\hphantom{\vphantom{X}}_{#1}}}
+ }
+ \def\drawnode{%
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ \node[dotphantom] (phantom-\x-\y) at (\x,-\y) {};
+ \ifnum\maxnums>\i
+ % \ifnum\corner=0 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\corner=1 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=2 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=3 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\direction=0 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \else
+ % \ifnum\direction=2 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \fi\fi\fi\fi\fi\fi
+ \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i};
+ \fi
+ \ifnum\maxcoordsX>\x
+ \ifnum\maxcoordsY>\y
+ % \ifnum\corner=0 \node[coord,anchor=south east] at (dot-\x-\y.north west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=1 \node[coord,anchor=north east] at (dot-\x-\y.south west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=2 \node[coord,anchor=north west] at (dot-\x-\y.south east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=3 \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=0 \node[coord,anchor=east] at (dot-\x-\y.west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=1 \node[coord,anchor=north] at (dot-\x-\y.south) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=2 \node[coord,anchor=west] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=3 \node[coord,anchor=south] at (dot-\x-\y.north) {\reallysmallcheat{(\x, \y)}}; \fi\fi\fi\fi\fi\fi\fi\fi
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{1}
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
+ \fi
+ \fi
+ }
+ \def\drawlinknode{%
+ \drawnode%
+ \draw[->] (phantom-\oldx-\oldy) -- (phantom-\x-\y);%
+ }
+ \def\mystep{%
+ \incr\i%
+ \xdef\oldx{\x}%
+ \xdef\oldy{\y}%
+ }
+ \def\changedir#1{%
+ \xdef\direction{#1}%
+ \xdef\corner{#1}%
+ }
+
+ \drawnode
+ \mystep \incr\x
+ \xdef\cornerc{0}
+
+ \foreach \pos in {1,...,\maxdots} {
+ % Detect when we are at the end of this edge.
+ \ifnum\sidelen=0
+ \ifnum\direction=0 \changedir{1} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=1 \changedir{2} \xdef\sidelen{\nextsidelen} \else
+ \ifnum\direction=2 \changedir{3} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=3 \changedir{0} \xdef\sidelen{\nextsidelen} \fi\fi\fi\fi% Brin d'acier
+
+ \fi
+ % Draw node and link to previous, step counters
+ \drawlinknode \mystep
+ %% Se déplacer vers ↙↓↗→
+ \ifnum\direction=0 \incr\y \decr\x \fi
+ \ifnum\direction=1 \incr\y \fi
+ \ifnum\direction=2 \decr\y \incr\x \fi
+ \ifnum\direction=3 \incr\x \fi
+ \decr\sidelen
+ \xdef\corner{4}%% 4 == pas de coin-coin.
+ }
+
+ \foreach \x in {0,...,\maxdotsX} {
+ \foreach \y in {1,...,\maxdotsY} {
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ }
+ }
+ \decr\maxcoordsX
+ \decr\maxcoordsY
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {0,...,\maxcoordsY} {
+ \node[dot,fill=none] (fakedot-\x-\y) at (\x,-\y) {};
+ \expandafter\ifnum\csname dotxypresent-\x-\y\endcsname=0
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (fakedot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (fakedot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
+ \fi
+ }
+ }
+
+ \foreach \i in {1, ...,6}{
+ \node[constatation1] at (.5*\i,-.5*\i) {\i};
+ }
+ \node[constatation1] at (.5*7,-.5*7) {\vdots};
+
+ \node[coordinate] (fake0-0) at (0,0) {};
+ \node[constatation2, coordinate, above of=fake0-0] (fake0-0-bis) {};
+ \node[coordinate] (fake1-0) at (1,0) {};
+ \node[coordinate] (fake3-0) at (3,0) {};
+ \node[coordinate] (fake5-0) at (5,0) {};
+ \node[coordinate] (fake0-2) at (0,-2) {};
+ \node[coordinate] (fake0-4) at (0,-4) {};
+ \node[coordinate] (fake0-6) at (0,-6) {};
+ \node[constatation2, left of=fake0-0-bis] {0};
+ \node[constatation2, above of=fake1-0] {1};
+ \node[constatation2, above of=fake3-0] {6};
+ \node[constatation2, above of=fake5-0] {15};
+ \node[constatation2, left of=fake0-2] {3};
+ \node[constatation2, left of=fake0-4] {10};
+ \node[constatation2, left of=fake0-6] {21};
+ \end{tikzpicture}
+ \caption{Codage d'un couple d'entiers relatifs}%% TODO : caption
+ \label{fig:codage-nat-avec-constatation}
+\end{figure}
+%% TODO: Même figure que la précédente, mais avec les 'constatations' ajoutées (je ferai un diagramme papier pour qu'on sache ce que je veux ici)
+%% TODO : Réponse georges, c'est bon ?
En reprenant la figure ??? ci-dessus, on peut faire plusieurs constatations~:
diff --git a/test.tex b/test.tex
@@ -50,9 +50,12 @@
\begin{figure}[h!]
%% «Paramètres»
- \xdef\maxdots{81}
- \xdef\maxnums{56}
- \xdef\maxcoords{20}
+ \xdef\maxdots{23}
+ \xdef\maxdotsX{5}
+ \xdef\maxdotsY{5}
+ \xdef\maxnums{20}
+ \xdef\maxcoordsX{3}
+ \xdef\maxcoordsY{3}
%% ===== Code is below =====
@@ -72,9 +75,9 @@
\myadv#1{-1}%
}
\makeatother
- % \centering
- \hskip -21mm%% Hack-o-matic to get the picture more or less centered…
+ \centering
\begin{tikzpicture}[
+ scale=1.4,
dot/.style={
circle,
inner sep=0.7pt,
@@ -86,97 +89,82 @@
fill=none,
draw=none
},
- numero/.style={circle, fill=white, inner sep=0.2pt, text=red, scale=.75},
- coord/.style={darkgray, scale=.6},
+ numero/.style={rectangle, fill=white, inner sep=2pt, text=red!50!black},
+ coord/.style={darkgray, scale=.8},
%
bigarrow/.style={
->,
thick,
draw=green!50!black
+ },
+ constatation1/.style={
+ circle,
+ inner sep=1.5pt,
+ outer sep=0.8pt,
+ fill=white,
+ text=red,
+ anchor=south,
+ rotate around={45:(0,0)}
+ },
+ constatation2/.style={
+ text=green!50!black,
+ node distance=0.6cm
}
]
- % Diagonales
- \node[dotphantom] (pre-phantom-0-0) at (0,0) {};
- \node[dotphantom] (pre-phantom-1-0) at (1,0) {};
-
- % Top right
- \node[inner sep=0.1pt] (tr-start) at (4,4) {};
- \xdef\previous{tr-start}
- \foreach \pos/\content in {0/$1\times 2=2$,1/$3\times 4=12$,2/$5\times 6=30$,3/$7\times 8=56$,4/$\vphantom{X}\dots$}{
- \node[anchor=south] (tr-temp-\pos) at (intersection cs: first line={(\previous.north west)--(\previous.north east)}, second line={(0,0)--(6,6)}) {\phantom{\content}};
- \node[anchor=north west] (tr-\pos) at (intersection cs: first line={(tr-temp-\pos.north west)--(tr-temp-\pos.north east)}, second line={(0,0)--(6,6)}) {\content};
- \xdef\previous{tr-\pos}
- }
- \draw[bigarrow] (pre-phantom-0-0) -- (intersection cs: first line={(\previous.north west)--(\previous.south west)}, second line={(0,0)--(6,6)});
-
- % Top left
- \node[inner sep=0.1pt] (tl-start) at (-4,4) {};
- \xdef\previous{tl-start}
- \foreach \pos/\content in {0/$0^2=0$,1/$2^2=4$,2/$6^2=36$,3/$8^2=64$,4/$\vphantom{X}\dots$}{
- \node[anchor=south] (tl-temp-\pos) at (intersection cs: first line={(\previous.north west)--(\previous.north east)}, second line={(0,0)--(-6,6)}) {\phantom{\content}};
- \node[anchor=north east] (tl-\pos) at (intersection cs: first line={(tl-temp-\pos.north west)--(tl-temp-\pos.north east)}, second line={(0,0)--(-6,6)}) {\content};
- \xdef\previous{tl-\pos}
- }
- \draw[bigarrow] (pre-phantom-0-0) -- (intersection cs: first line={(\previous.north east)--(\previous.south east)}, second line={(0,0)--(-6,6)});
+ % %% Digonale
+ % \draw[bigarrow,red] (0,0) -- (.5*7.5,-.5*7.5);
- % Bottom left
- \node[inner sep=0.1pt] (bl-start) at (-4,-4) {};
- \xdef\previous{bl-start}
- \foreach \pos/\content in {0/$0\times 1=0$,1/$2\times 3=6$,2/$4\times 5=20$,3/$6\times 7=42$,4/$\vphantom{X}\dots$}{
- \node[anchor=north] (bl-temp-\pos) at (intersection cs: first line={(\previous.south west)--(\previous.south east)}, second line={(0,0)--(-6,-6)}) {\phantom{\content}};
- \node[anchor=south east] (bl-\pos) at (intersection cs: first line={(bl-temp-\pos.south west)--(bl-temp-\pos.south east)}, second line={(0,0)--(-6,-6)}) {\content};
- \xdef\previous{bl-\pos}
- }
- \draw[bigarrow] (pre-phantom-0-0) -- (intersection cs: first line={(\previous.north east)--(\previous.south east)}, second line={(0,0)--(-6,-6)});
-
- % Bottom right
- \node[inner sep=0.1pt] (br-start) at (5,-4) {};
- \xdef\previous{br-start}
- \foreach \pos/\content in {0/$1^2=1$,1/$3^2=9$,2/$5^2=25$,3/$7^2=49$,4/$\vphantom{X}\dots$}{
- \node[anchor=north] (br-temp-\pos) at (intersection cs: first line={(\previous.south west)--(\previous.south east)}, second line={(1,0)--(6,-5)}) {\phantom{\content}};
- \node[anchor=south west] (br-\pos) at (intersection cs: first line={(br-temp-\pos.south west)--(br-temp-\pos.south east)}, second line={(1,0)--(6,-5)}) {\content};
- \xdef\previous{br-\pos}
- }
- \draw[bigarrow] (pre-phantom-1-0) -- (intersection cs: first line={(\previous.north west)--(\previous.south west)}, second line={(1,0)--(6,-5)});
- % Fin diagonales
-
% Définitions pour le code ci-dessous.
\xdef\i{0}
\xdef\x{0}
\xdef\y{0}
- \xdef\corner{4}
+ \xdef\corner{3}
\xdef\sidelen{0}
\xdef\nextsidelen{1}
\xdef\direction{3}
\incr\maxnums
- \incr\maxcoords
+ \incr\maxcoordsX
+ \incr\maxcoordsY
+
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {1,...,\maxcoordsY} {
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{0}
+ }
+ }
\def\reallysmallcheat#1{%
\ensuremath{\hphantom{\vphantom{X}}_{\hphantom{\vphantom{X}}_{#1}}}
}
\def\drawnode{%
- \node[dot] (dot-\x-\y) at (\x,\y) {};
- \node[dotphantom] (phantom-\x-\y) at (\x,\y) {};
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ \node[dotphantom] (phantom-\x-\y) at (\x,-\y) {};
\ifnum\maxnums>\i
- \ifnum\corner=0 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \else
- \ifnum\corner=1 \node[numero,anchor=south west] at (dot-\x-\y.north east) {\i}; \else
- \ifnum\corner=2 \node[numero,anchor=south east] at (dot-\x-\y.north west) {\i}; \else
- \ifnum\corner=3 \node[numero,anchor=north east] at (dot-\x-\y.south west) {\i}; \else
- \ifnum\direction=0 \node[numero,anchor=west] at (dot-\x-\y.east) {\i}; \else
- \ifnum\direction=1 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
- \ifnum\direction=2 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
- \ifnum\direction=3 \node[numero,anchor=north] at (dot-\x-\y.south) {\i}; \fi\fi\fi\fi\fi\fi\fi\fi
+ % \ifnum\corner=0 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\corner=1 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=2 \node[numero,anchor=east] at (dot-\x-\y.west) {\i}; \else
+ % \ifnum\corner=3 \node[numero,anchor=south] at (dot-\x-\y.north) {\i}; \else
+ % \ifnum\direction=0 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \else
+ % \ifnum\direction=2 \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i}; \fi\fi\fi\fi\fi\fi
+ \node[numero,anchor=north west] at (dot-\x-\y.south east) {\i};
+ \fi
+ \ifnum\maxcoordsX>\x
+ \ifnum\maxcoordsY>\y
+ % \ifnum\corner=0 \node[coord,anchor=south east] at (dot-\x-\y.north west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=1 \node[coord,anchor=north east] at (dot-\x-\y.south west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=2 \node[coord,anchor=north west] at (dot-\x-\y.south east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\corner=3 \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=0 \node[coord,anchor=east] at (dot-\x-\y.west) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=1 \node[coord,anchor=north] at (dot-\x-\y.south) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=2 \node[coord,anchor=west] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}}; \else
+ % \ifnum\direction=3 \node[coord,anchor=south] at (dot-\x-\y.north) {\reallysmallcheat{(\x, \y)}}; \fi\fi\fi\fi\fi\fi\fi\fi
+ \expandafter\xdef\csname dotxypresent-\x-\y\endcsname{1}
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
\fi
- \ifnum\maxcoords>\i
- \ifnum\corner=0 \node[coord,anchor=south east] at (dot-\x-\y.north west) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\corner=1 \node[coord,anchor=north east] at (dot-\x-\y.south west) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\corner=2 \node[coord,anchor=north west] at (dot-\x-\y.south east) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\corner=3 \node[coord,anchor=south west] at (dot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\direction=0 \node[coord,anchor=east] at (dot-\x-\y.west) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\direction=1 \node[coord,anchor=north] at (dot-\x-\y.south) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\direction=2 \node[coord,anchor=west] at (dot-\x-\y.east) {\reallysmallcheat{(\x, \y)}}; \else
- \ifnum\direction=3 \node[coord,anchor=south] at (dot-\x-\y.north) {\reallysmallcheat{(\x, \y)}}; \fi\fi\fi\fi\fi\fi\fi\fi
\fi
}
\def\drawlinknode{%
@@ -200,25 +188,105 @@
\foreach \pos in {1,...,\maxdots} {
% Detect when we are at the end of this edge.
\ifnum\sidelen=0
- \ifnum\direction=0 \changedir{1} \incr\nextsidelen \else
- \ifnum\direction=1 \changedir{2} \else
- \ifnum\direction=2 \changedir{3} \incr\nextsidelen \else
- \ifnum\direction=3 \changedir{0} \fi\fi\fi\fi% Brin d'acier
- \xdef\sidelen{\nextsidelen}
+ \ifnum\direction=0 \changedir{1} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=1 \changedir{2} \xdef\sidelen{\nextsidelen} \else
+ \ifnum\direction=2 \changedir{3} \incr\nextsidelen \xdef\sidelen{1} \else
+ \ifnum\direction=3 \changedir{0} \xdef\sidelen{\nextsidelen} \fi\fi\fi\fi% Brin d'acier
+
\fi
% Draw node and link to previous, step counters
\drawlinknode \mystep
- %% Se déplacer vers ↑←↓→
- \ifnum\direction=0 \incr\y \fi
- \ifnum\direction=1 \decr\x \fi
- \ifnum\direction=2 \decr\y \fi
- \ifnum\direction=3 \incr\x \fi
+ %% Se déplacer vers ↙↓↗→
+ \ifnum\direction=0 \incr\y \decr\x \fi
+ \ifnum\direction=1 \incr\y \fi
+ \ifnum\direction=2 \decr\y \incr\x \fi
+ \ifnum\direction=3 \incr\x \fi
\decr\sidelen
\xdef\corner{4}%% 4 == pas de coin-coin.
}
+
+ \foreach \x in {0,...,\maxdotsX} {
+ \foreach \y in {1,...,\maxdotsY} {
+ \node[dot] (dot-\x-\y) at (\x,-\y) {};
+ }
+ }
+ \decr\maxcoordsX
+ \decr\maxcoordsY
+ \foreach \x in {0,...,\maxcoordsX} {
+ \foreach \y in {0,...,\maxcoordsY} {
+ \node[dot,fill=none] (fakedot-\x-\y) at (\x,-\y) {};
+ \expandafter\ifnum\csname dotxypresent-\x-\y\endcsname=0
+ \ifnum\y=0
+ \node[coord,anchor=south west] at (fakedot-\x-\y.north east) {\reallysmallcheat{(\x, \y)}};
+ \else
+ \node[coord,anchor=west,xshift=0.2] at (fakedot-\x-\y.east) {\reallysmallcheat{(\x, \y)}};
+ \fi
+ \fi
+ }
+ }
+
+ % \foreach \i in {1, ...,6}{
+ % \node[constatation1] at (.5*\i,-.5*\i) {\i};
+ % }
+ % \node[constatation1] at (.5*7,-.5*7) {\vdots};
+
+ % \node[coordinate] (fake0-0) at (0,0) {};
+ % \node[coordinate] (fake1-0) at (1,0) {};
+ % \node[coordinate] (fake3-0) at (3,0) {};
+ % \node[coordinate] (fake5-0) at (5,0) {};
+ % \node[coordinate] (fake0-2) at (0,-2) {};
+ % \node[coordinate] (fake0-4) at (0,-4) {};
+ % \node[coordinate] (fake0-6) at (0,-6) {};
+ % \node[constatation2, above left of=fake0-0] {0};
+ % \node[constatation2, above of=fake1-0] {1};
+ % \node[constatation2, above of=fake3-0] {6};
+ % \node[constatation2, above of=fake5-0] {15};
+ % \node[constatation2, left of=fake0-2] {3};
+ % \node[constatation2, left of=fake0-4] {10};
+ % \node[constatation2, left of=fake0-6] {21};
\end{tikzpicture}
- \caption{Codage d'un couple d'entiers relatifs}
- \label{fig:codage-rel}
+ \caption{Codage d'un couple d'entiers relatifs}%% TODO : caption
+ \label{fig:codage-nat-sans-constatation}
\end{figure}
+% \begin{figure}[h!]
+% \centering
+% \begin{tikzpicture}[
+% dot/.style = {
+% circle,
+% fill=black,
+% inner sep=0.5pt
+% },
+% arc/.style = {
+% ->,
+% >=stealth
+% }
+% ]
+% \foreach \xpos in {0, ..., 4} {
+% \foreach \ypos in {0, ..., 4} {
+% \node[dot] at (\xpos,-\ypos) {};
+% }
+% }
+
+% \draw[arc] (0,-0) -- (1,-0);
+
+% \draw[arc] (1,-0) -- (0,-1);
+% \draw[arc] (0,-1) -- (0,-2);
+
+% \draw[arc] (0,-2) -- (1,-1);
+% \draw[arc] (1,-1) -- (2,-0);
+% \draw[arc] (2,-0) -- (3,-0);
+
+% \draw[arc] (3,-0) -- (2,-1);
+% \draw[arc] (2,-1) -- (1,-2);
+% \draw[arc] (1,-2) -- (0,-3);
+% \draw[arc] (0,-3) -- (0,-4);
+
+% \draw[arc] (0,-4) -- (1,-3);
+% \draw[arc,dashed] (1,-3) -- (2,-2);
+% \end{tikzpicture}
+% \caption{Codage d'un couple d'entiers relatifs}
+% \label{fig:codage-rel}
+% \end{figure}
+
\end{document}
\ No newline at end of file