Wie kann ich veclen weiterverwenden? Etwa Benennung in \Laenge geht nicht.

Öffne in Overleaf
Code, hier editierbar zum Übersetzen:
\path (A) let \p1 = ($ (B) - (A) $), \n1 = {veclen(\x1,\y1)}
in -- (B) node[draw, yshift=-1cm] {AB :\n1};
%\pgfmathsetmacro{\Laenge}{\n1} % Geht nicht!
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Ganzes Beispiel:

alt text

Öffne in Overleaf
Code, hier editierbar zum Übersetzen:
\documentclass[margin=5mm, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{patterns}
\usetikzlibrary{calc}
\pgfmathsetmacro{\Radius}{3}
\pgfmathsetmacro{\bH}{2}
\begin{document}
\begin{tikzpicture}[every node/.style={black,above right}]
\path[name path=line 2] (-1.1*\Radius,-\bH) -- (1.1*\Radius,-\bH);
\path[name path=line 1] (-1.1*\Radius,\bH) -- (1.1*\Radius,\bH);
\draw[name path=Circle] (0,0) circle[radius=\Radius];
\fill[] (0,0) circle[radius=2pt];
\fill[red,name intersections={of=line 1 and Circle,total=\t}]
\foreach \s in {1,...,\t}{(intersection-\s) circle (2pt) node {}};
\path[red] (intersection-1) coordinate (C) -- (intersection-2) coordinate (D) ;
\fill[red,name intersections={of=line 2 and Circle,total=\t}]
\foreach \s in {1,...,\t}{
(intersection-\s) circle (2pt) node (P-\s) {}};
\path[red] (intersection-1) coordinate (A) -- (intersection-2) coordinate (B) ;
\draw[red, pattern=north west lines, pattern color=red] (A) rectangle (C);
% Berechnungen
\path (A) let \p1 = ($ (B) - (A) $), \n1 = {veclen(\x1,\y1)}
in -- (B) node[draw, yshift=-1cm] {AB :\n1};
%\pgfmathsetmacro{\Laenge}{\n1} % Geht nicht!
\path (B) let \p1 = ($ (C) - (B) $), \n1 = {veclen(\x1,\y1)}
in -- (B) node[draw] {BC :\n1};
%\pgfmathsetmacro{\Breite}{\n1}
\pgfmathsetmacro{\Flaeche}{\Laenge*\Breite}
\node[red] at (0,4) {Fl\"ache=?};
\end{tikzpicture}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

gefragt 07 Jul '18, 17:21

cis's gravatar image

cis
9.6k103460491
Akzeptiert-Rate: 29%


Statt mit \xdef zu arbeiten, könnte man sich auch ein \globalpgfmathsetmacro definieren, beispielsweise:
\newcommand*{\globalpgfmathsetmacro}[2]{% \pgfmathsetmacro{#1}{#2}% \global\let#1#1 }
und dann \pgfextra{\globalpgfmathsetmacro{\Laenge}{\n1}} schreiben. Um das \pgfextra kommt man aber nicht herum.

Permanenter link

beantwortet 09 Jul '18, 09:14

gast3's gravatar image

gast3
(ausgesetzt)
Akzeptiert-Rate: 53%

Hab es rausgefunden; es geht mit pgfextra und xdef:

Öffne in Overleaf
Code, hier editierbar zum Übersetzen:
\path (A) let \p1 = ($ (B) - (A) $), \n1 = {veclen(\x1,\y1)}
in -- (B) node[draw, yshift=-1cm] {AB :\n1} \pgfextra{\xdef\Laenge{\n1}};
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Permanenter link

beantwortet 07 Jul '18, 18:01

cis's gravatar image

cis
9.6k103460491
Akzeptiert-Rate: 29%

bearbeitet 07 Jul '18, 18:02

Ja, das mache ich auch meistens so... es ist aber ein wenig gefährlich, das pgfmanual sagt: "Note that this operation should only be used by real experts and should only be used deep inside clever macros, not on normal paths.".

(07 Jul '18, 20:15) Community
1

Die Aussage bezieht sich wohl auf \pgfextra{}. Ich wüsste gar nicht, wie man es anders machen kann.

(07 Jul '18, 23:11) cis
Deine Antwort
[Vorschau ausblenden]

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Frage-Themen:

×731
×16

gestellte Frage: 07 Jul '18, 17:21

Frage wurde gesehen: 7,312 Mal

zuletzt geändert: 09 Jul '18, 23:06

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×