坐标系索引中的节点数

坐标系索引中的节点数

我遇到了一个不那么简单的问题:)首先我要给你看一张图片来更好地解释我想要什么。

局部坐标系

在该图片中,我希望坐标系的索引号显示实际节点号。例如,节点 5 处的上部局部坐标系应具有 F5y 和 F5x。我的实际代码如下所示:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,decorations.markings}
\usepackage{tikz}
\tikzset{>=latex}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}

\begin{tikzpicture}[scale=1.3,inner sep=0pt,thick,dot/.style={draw,circle,minimum size=4pt},
put coord sys/.style={
decoration={markings,
mark= at position 0.5
with
{
\draw[-latex,ultra thin,blue!80!black] (2pt,2pt) -- ++(5mm,0) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle x$};
\draw[-latex,ultra thin,green!80!black] (2pt,2pt) -- ++(0,5mm) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle y$};
}
},
postaction=decorate},
lokalekraft/.style={
decoration={markings,
mark= at position 0.5
with
{
\draw[-latex,ultra thin,blue!80!black] (2pt,2pt) -- ++(5mm,0) node[above right,rotate=\pgfdecoratedangle]  {$\scriptstyle F_{1x}$};
\draw[-latex,ultra thin,green!80!black] (2pt,2pt) -- ++(0,5mm) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle F_{1y}$};
}
},
postaction=decorate}]


%Knotennummern
%\node[dot] (2) at (0,0) [label={[label distance=1mm]270:2}] {};
\node[dot] (3) at (0,2) [label={[label distance=1mm]180:3}] {};
%\node[dot] (1) at (0,4) [label={[label distance=1mm]90:1}] {};
%\node[dot] (4) at (3,2) [label={[label distance=1mm]0:4}] {};
\node[dot] (5) at (2.5,4) [label={[label distance=1mm]45:5}] {};


%Elementenummern
%\draw  (2) -- (3) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,midway,sloped,above,yshift=.5mm] {3};
%\draw  (3) -- (4) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,midway,above,sloped,yshift=.5mm] {4};     
%\draw  (2) -- (4) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,midway,above,sloped,yshift=.5mm] {6};     
%\draw  (3) -- (1) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,midway,above,sloped,yshift=.5mm] {2}; 
%\draw  (1) -- (5) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,pos=0.4,above,sloped,yshift=.5mm] {1};    
\draw   (3) -- (5) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,pos=0.4,above,sloped,yshift=.5mm] {5};    
%\draw  (4) -- (5) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,midway,above,sloped,yshift=.5mm] {7};     

%Längenangaben in mm
%\draw (2) -- (3) node [font=\tiny,yshift=-.5mm,midway,sloped,below] {2000 mm}; 
%\draw (3) -- (4) node [font=\tiny,yshift=-.5mm,midway,sloped,below] {3000 mm};
%%\draw (2) -- (4) node [yellow,font=\tiny,yshift=-.5mm,midway,sloped,below] {xxmm};
%\draw (3) -- (1) node [font=\tiny,yshift=-.5mm,midway,sloped,below] {2000 mm}; 
%\draw (1) -- (5) node [font=\tiny,yshift=-.5mm,midway,sloped,below] {2500 mm}; 
%%\draw (3) -- (5) node [yellow,font=\tiny,yshift=-.5mm,midway,sloped,below] {xxmm};    
%%\draw (4) -- (5) node [yellow,font=\tiny,yshift=-.5mm,midway,sloped,below] {xxmm};        

%Lokale Koordinatensysteme          
%\draw[put coord sys]   (2) -- (3);
%\draw[put coord sys]   (3) -- (4);      
%\draw[put coord sys]   (2) -- (4);  
%\draw[put coord sys]   (1) -- (3);
%\draw[put coord sys]   (1) -- (5);
%\draw[put coord sys]   (4) -- (5);
\draw[put coord sys]   (3) -- (5);
\draw[lokalekraft] (0,2) ;          
\draw[lokalekraft] (2.5,4);

\end{tikzpicture}
\end{document}

然后我需要沿着线对齐两个坐标系,就像中间的坐标系一样。

此外,我需要类似这样的坐标系:

当地流离失所

答案1

通过一些样式和一些辅助样式,您可以对每种样式重复使用相同的标记。

@create coord system键安装coord system type具有针对装饰(例如raise),线条(例如箭头设置)和其中的节点(接受一个参数的代码键)的特定设置。

coord system以 的形式采用其参数,<position>:<text>其中是可选的,如果省略,则使用<position>:的值。用作节点键的参数(此处:和)。coord system position<text>35

代码

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{decorations.markings}
\tikzset{>=latex}
\makeatletter
\tikzset{
  @create coord system/.style n args={6}{
    coord system type/#1/.style={
      /pgf/decoration/coord system@/.style={#2},
      coord system x/.style={#3},coord system y/.style={#4},
      @coord system x/.code={#5},@coord system y/.code={#6}
    }
  },
  coord system type/.is choice,
  @create coord system={normal}      {raise=+2pt}{->}{->}{x}       {y},
  @create coord system={lokalekraft} {raise=+0pt}{->}{->}{F_{##1x}}{F_{##1y}},
  @create coord system={lokalekraft*}{raise=+1pt}{<-}{<-}{u_{##1}} {v_{##1}},
  coord system/.code=%
    \pgfutil@in@{:}{#1}
    \ifpgfutil@in@
      \pgfkeysalso{@coord system={#1}}%
    \else
      \pgfkeysalso{@coord system={\pgfkeysvalueof{/tikz/coord system position}:#1}}%
    \fi,
  @coord system/.style args={#1:#2}{
    decoration={
      name=markings,
      coord system@,
      mark=at position #1 with {%
        \draw[every coord system, every coord system x, coord system x] (+0pt,+0pt) -- ++(+5mm,+0pt) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle\tikzset{@coord system x={#2}}$};
        \draw[every coord system, every coord system y, coord system y] (+0pt,+0pt) -- ++(+0pt,+5mm) node[above right,rotate=\pgfdecoratedangle] {$\scriptstyle\tikzset{@coord system y={#2}}$};
      },
    },
    postaction=decorate
  },
  % a few default settings:
  coord system type=normal,
  every coord system/.style={line cap=rect, ultra thin},
  every coord system x/.style={blue!80!black},
  every coord system y/.style={green!80!black},
  coord system position/.initial=+.5,
  coord system/.default={},
  % a few short-cuts:
  put coord sys/.style={coord system type=coord system,coord system={#1}},
  lokalekraft/.style={coord system type=lokalekraft,coord system={#1}},
  lokalekraft*/.style={coord system type=lokalekraft*,coord system={#1}},
  put coord sys/.default={},lokalekraft/.default={},lokalekraft*/.default={},
}
\makeatother
\begin{document}

\begin{tikzpicture}[scale=1.3,inner sep=0pt,thick,dot/.style={draw,circle,minimum size=4pt}]

\node[dot] (3) at (0,2) [label={[label distance=1mm]180:3}] {};
\node[dot] (5) at (2.5,4) [label={[label distance=1mm]45:5}] {};

\draw[coord system]   (3) -- (5) node [draw,minimum width=2mm,minimum height=2mm,ultra thin,font=\tiny,blue,pos=0.4,above,sloped,yshift=.5mm] {5};

\tikzset{coord system type=lokalekraft}

\path[coord system=3] (3.center);
\path[coord system=5] (5.center);

\tikzset{coord system type=lokalekraft*}
\path[coord system=0:5,
      coord system=1:3] (5.south east) -- (3.south east);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容