Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 5

02 Mär '14, 21:05

esdd's gravatar image

esdd
17.8k304257

Problem mit for bzw. foreach -Schleife bei Knotenpunkte (nodes)

Dies ist der bisherige Quelltext für jenes (stark erweiterte) Trapez: Bisher klappt es ganz gut, nur wie man die letzten inneren Schnittpunkte in einer Schleife reinpackt, um diese ellenlange Schreiberei sich zu ersparen, will noch nicht so recht funktionieren. Mein Versuch steht vor Beginn der Liste in Kommentaren gesetzt. \documentclass[margin=5pt,tikz]{standalone} \usetikzlibrary{calc,intersections} \begin{document} \begin{tikzpicture}[every node/.append style={minimum width=1cm, minimum height=1cm}] % Eckpunkte \node (1) at (16,16) {1}; \node (2) at (1,16) {2}; \node (3) at (2,0) {3}; \node (4) at (9,0) {4}; % Gitterpunkte der oberen und unteren Seite: \def \s{7} % Zwischenspaltenanzahl (Senkrechten) \foreach \n in {1, ..., \s} { \node (O\n) at ($ (1) !.{(1 / (\s + 1)) * \n}! (2) $) {O\n}; \node (U\n) at ($ (4) !.{(1 / (\s + 1)) * \n}! (3) $) {U\n}; } % Gitterpunkte der linken und rechten Seite: \def \w{6} % Zwischenzeilenanzahl (Waagerechten) \foreach \n in {1, ..., \w} { \node (L\n) at ($ (2) !.{(1 / (\w + 1)) * \n}! (3) $) {L\n}; \node (R\n) at ($ (1) !.{(1 / (\w + 1)) * \n}! (4) $) {R\n}; } % Festlegung senkrechter und waagerechter Reihen: \foreach \n in {1, ..., \s} \path [name path global/.expanded=O\n--U\n] (O\n) -- (U\n); \foreach \n in {1, ..., \w} \path [name path global/.expanded=L\n--R\n] (L\n) -- (R\n); % Schnittpunkte der senkrechen mit den waagerechten Reihen als neue Gitterpunkte: % \def \i{1} % \foreach \n in {1, ..., \s} % { % \path [name intersections = {of=O\n--U\n and L\i--R\i, by=\n\i}]; \node at (\n\i) {\n\i}; % } \path [name intersections = {of=O1--U1 and L1--R1, by=11}]; \node at (11) {11}; \path [name intersections = {of=O2--U2 and L1--R1, by=21}]; \node at (21) {21}; \path [name intersections = {of=O3--U3 and L1--R1, by=31}]; \node at (31) {31}; \path [name intersections = {of=O4--U4 and L1--R1, by=41}]; \node at (41) {41}; \path [name intersections = {of=O5--U5 and L1--R1, by=51}]; \node at (51) {51}; \path [name intersections = {of=O6--U6 and L1--R1, by=61}]; \node at (61) {61}; \path [name intersections = {of=O7--U7 and L1--R1, by=71}]; \node at (71) {71}; \path [name intersections = {of=O1--U1 and L2--R2, by=12}]; \node at (12) {12}; \path [name intersections = {of=O2--U2 and L2--R2, by=22}]; \node at (22) {22}; \path [name intersections = {of=O3--U3 and L2--R2, by=32}]; \node at (32) {32}; \path [name intersections = {of=O4--U4 and L2--R2, by=42}]; \node at (42) {42}; \path [name intersections = {of=O5--U5 and L2--R2, by=52}]; \node at (52) {52}; \path [name intersections = {of=O6--U6 and L2--R2, by=62}]; \node at (62) {62}; \path [name intersections = {of=O7--U7 and L2--R2, by=72}]; \node at (72) {72}; \path [name intersections = {of=O1--U1 and L3--R3, by=13}]; \node at (13) {13}; \path [name intersections = {of=O2--U2 and L3--R3, by=23}]; \node at (23) {23}; \path [name intersections = {of=O3--U3 and L3--R3, by=33}]; \node at (33) {33}; \path [name intersections = {of=O4--U4 and L3--R3, by=43}]; \node at (43) {43}; \path [name intersections = {of=O5--U5 and L3--R3, by=53}]; \node at (53) {53}; \path [name intersections = {of=O6--U6 and L3--R3, by=63}]; \node at (63) {63}; \path [name intersections = {of=O7--U7 and L3--R3, by=73}]; \node at (73) {73}; \path [name intersections = {of=O1--U1 and L4--R4, by=14}]; \node at (14) {14}; \path [name intersections = {of=O2--U2 and L4--R4, by=24}]; \node at (24) {24}; \path [name intersections = {of=O3--U3 and L4--R4, by=34}]; \node at (34) {34}; \path [name intersections = {of=O4--U4 and L4--R4, by=44}]; \node at (44) {44}; \path [name intersections = {of=O5--U5 and L4--R4, by=54}]; \node at (54) {54}; \path [name intersections = {of=O6--U6 and L4--R4, by=64}]; \node at (64) {64}; \path [name intersections = {of=O7--U7 and L4--R4, by=74}]; \node at (74) {74}; \path [name intersections = {of=O1--U1 and L5--R5, by=15}]; \node at (15) {15}; \path [name intersections = {of=O2--U2 and L5--R5, by=25}]; \node at (25) {25}; \path [name intersections = {of=O3--U3 and L5--R5, by=35}]; \node at (35) {35}; \path [name intersections = {of=O4--U4 and L5--R5, by=45}]; \node at (45) {45}; \path [name intersections = {of=O5--U5 and L5--R5, by=55}]; \node at (55) {55}; \path [name intersections = {of=O6--U6 and L5--R5, by=65}]; \node at (65) {65}; \path [name intersections = {of=O7--U7 and L5--R5, by=75}]; \node at (75) {75}; \path [name intersections = {of=O1--U1 and L6--R6, by=16}]; \node at (16) {16}; \path [name intersections = {of=O2--U2 and L6--R6, by=26}]; \node at (26) {26}; \path [name intersections = {of=O3--U3 and L6--R6, by=36}]; \node at (36) {36}; \path [name intersections = {of=O4--U4 and L6--R6, by=46}]; \node at (46) {46}; \path [name intersections = {of=O5--U5 and L6--R6, by=56}]; \node at (56) {56}; \path [name intersections = {of=O6--U6 and L6--R6, by=66}]; \node at (66) {66}; \path [name intersections = {of=O7--U7 and L6--R6, by=76}]; \node at (76) {76}; \end{tikzpicture} \end{document}
Klicke auf Einblenden/Ausblenden von Überarbeitungen 4
Code ergänzt, Tag geändert

02 Mär '14, 21:05

esdd's gravatar image

esdd
17.8k304257

Problem mit for bzw. foreach -Schleife bei Knotenpunkte (nodes)

Dies ist der bisherige Quelltext für jenes (stark erweiterte) Trapez: Bisher klappt es ganz gut, nur wie man die letzten inneren Schnittpunkte in einer Schleife reinpackt, um diese ellenlange Schreiberei sich zu ersparen, will noch nicht so recht funktionieren. Mein Versuch steht vor Beginn der Liste in Kommentaren gesetzt. \documentclass[margin=5pt,tikz]{standalone} \usetikzlibrary{calc,intersections} \begin{document} \begin{tikzpicture}[every node/.append style={minimum width=1cm, minimum height=1cm}] % Eckpunkte \node (1) at (16,16) {1}; \node (2) at (1,16) {2}; \node (3) at (2,0) {3}; \node (4) at (9,0) {4}; % Gitterpunkte der oberen und unteren Seite: \def \s{7} % Zwischenspaltenanzahl (Senkrechten) \foreach \n in {1, ..., \s} { \node (O\n) at ($ (1) !.{(1 / (\s + 1)) * \n}! (2) $) {O\n}; \node (U\n) at ($ (4) !.{(1 / (\s + 1)) * \n}! (3) $) {U\n}; } % Gitterpunkte der linken und rechten Seite: \def \w{6} % Zwischenzeilenanzahl (Waagerechten) \foreach \n in {1, ..., \w} { \node (L\n) at ($ (2) !.{(1 / (\w + 1)) * \n}! (3) $) {L\n}; \node (R\n) at ($ (1) !.{(1 / (\w + 1)) * \n}! (4) $) {R\n}; } % Festlegung senkrechter und waagerechter Reihen: \foreach \n in {1, ..., \s} \path [name path global/.expanded=O\n--U\n] (O\n) -- (U\n); \foreach \n in {1, ..., \w} \path [name path global/.expanded=L\n--R\n] (L\n) -- (R\n); % Schnittpunkte der senkrechen mit den waagerechten Reihen als neue Gitterpunkte: % \def \i{1} % \foreach \n in {1, ..., \s} % { % \path [name intersections = {of=O\n--U\n and L\i--R\i, by=\n\i}]; \node at (\n\i) {\n\i}; % } \path [name intersections = {of=O1--U1 and L1--R1, by=11}]; \node at (11) {11}; \path [name intersections = {of=O2--U2 and L1--R1, by=21}]; \node at (21) {21}; \path [name intersections = {of=O3--U3 and L1--R1, by=31}]; \node at (31) {31}; \path [name intersections = {of=O4--U4 and L1--R1, by=41}]; \node at (41) {41}; \path [name intersections = {of=O5--U5 and L1--R1, by=51}]; \node at (51) {51}; \path [name intersections = {of=O6--U6 and L1--R1, by=61}]; \node at (61) {61}; \path [name intersections = {of=O7--U7 and L1--R1, by=71}]; \node at (71) {71}; \path [name intersections = {of=O1--U1 and L2--R2, by=12}]; \node at (12) {12}; \path [name intersections = {of=O2--U2 and L2--R2, by=22}]; \node at (22) {22}; \path [name intersections = {of=O3--U3 and L2--R2, by=32}]; \node at (32) {32}; \path [name intersections = {of=O4--U4 and L2--R2, by=42}]; \node at (42) {42}; \path [name intersections = {of=O5--U5 and L2--R2, by=52}]; \node at (52) {52}; \path [name intersections = {of=O6--U6 and L2--R2, by=62}]; \node at (62) {62}; \path [name intersections = {of=O7--U7 and L2--R2, by=72}]; \node at (72) {72}; \path [name intersections = {of=O1--U1 and L3--R3, by=13}]; \node at (13) {13}; \path [name intersections = {of=O2--U2 and L3--R3, by=23}]; \node at (23) {23}; \path [name intersections = {of=O3--U3 and L3--R3, by=33}]; \node at (33) {33}; \path [name intersections = {of=O4--U4 and L3--R3, by=43}]; \node at (43) {43}; \path [name intersections = {of=O5--U5 and L3--R3, by=53}]; \node at (53) {53}; \path [name intersections = {of=O6--U6 and L3--R3, by=63}]; \node at (63) {63}; \path [name intersections = {of=O7--U7 and L3--R3, by=73}]; \node at (73) {73}; \path [name intersections = {of=O1--U1 and L4--R4, by=14}]; \node at (14) {14}; \path [name intersections = {of=O2--U2 and L4--R4, by=24}]; \node at (24) {24}; \path [name intersections = {of=O3--U3 and L4--R4, by=34}]; \node at (34) {34}; \path [name intersections = {of=O4--U4 and L4--R4, by=44}]; \node at (44) {44}; \path [name intersections = {of=O5--U5 and L4--R4, by=54}]; \node at (54) {54}; \path [name intersections = {of=O6--U6 and L4--R4, by=64}]; \node at (64) {64}; \path [name intersections = {of=O7--U7 and L4--R4, by=74}]; \node at (74) {74}; \path [name intersections = {of=O1--U1 and L5--R5, by=15}]; \node at (15) {15}; \path [name intersections = {of=O2--U2 and L5--R5, by=25}]; \node at (25) {25}; \path [name intersections = {of=O3--U3 and L5--R5, by=35}]; \node at (35) {35}; \path [name intersections = {of=O4--U4 and L5--R5, by=45}]; \node at (45) {45}; \path [name intersections = {of=O5--U5 and L5--R5, by=55}]; \node at (55) {55}; \path [name intersections = {of=O6--U6 and L5--R5, by=65}]; \node at (65) {65}; \path [name intersections = {of=O7--U7 and L5--R5, by=75}]; \node at (75) {75}; \path [name intersections = {of=O1--U1 and L6--R6, by=16}]; \node at (16) {16}; \path [name intersections = {of=O2--U2 and L6--R6, by=26}]; \node at (26) {26}; \path [name intersections = {of=O3--U3 and L6--R6, by=36}]; \node at (36) {36}; \path [name intersections = {of=O4--U4 and L6--R6, by=46}]; \node at (46) {46}; \path [name intersections = {of=O5--U5 and L6--R6, by=56}]; \node at (56) {56}; \path [name intersections = {of=O6--U6 and L6--R6, by=66}]; \node at (66) {66}; \path [name intersections = {of=O7--U7 and L6--R6, by=76}]; \node at (76) {76}; \end{tikzpicture} \end{document}
Klicke auf Einblenden/Ausblenden von Überarbeitungen 3

02 Mär '14, 19:40

rix's gravatar image

rix
39081823

Klicke auf Einblenden/Ausblenden von Überarbeitungen 2
markdown statt html

02 Mär '14, 16:16

cgnieder's gravatar image

cgnieder
22.1k253463

Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

02 Mär '14, 16:14

rix's gravatar image

rix
39081823