7

I've got a not so simple problem :) First I am going to show you a picture to explain better what I want.

local coordinate system

In that picture I want to have the index numbers of the coordinate system to show the actual node numbers. For example the upper local coordinate system at node 5 should have F5y and F5x. My actual code for that looks like this:

\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}

Then I need to align the two coordinate systems along the line, like the one in the middle.

Furthermore I need something like a coordinate system which looks like this:

local displacements

  • To summarize, you need three kind of coordinate systems? The one along the path that is only labeled x and y, one at the nodes that are labeled F_{<number>x} and F_{<number>y} and a third that is placed at the nodes but rotated along the path with inverted arrows and labeled u<number> and v<number>? – Qrrbrbirlbel Jun 19 '13 at 19:30
2

With a few styles and a few auxiliary styles you can re-use the same marking for every style.

The @create coord system key installs a coord system type that has specific settings for the decoration (e.g. raise), the lines (e.g. arrows settings) and the node within (a code key that takes one argument).

The coord system key takes its argument in the form of <position>:<text> where <position>: is optional, the value of coord system position is used if it is omitted. <text> is used as an argument to the node key (here: 3 and 5).

Code

\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}

Output

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.