"Stanli"에서 참조 점 사용

Oct 24 2020

"Stanli"패키지를 사용할 때 서로 솟아 오르는 여러 개의 패러 그램을 그리기 위해 오프셋 값을 설정했습니다. 표시된 MWE의 경우 각 다이어그램의 원점은 다음과 같이 설정됩니다.

  • \ point {a-LD} {0} {22.5};
  • \ point {a-FBD} {0} {22.5-6};
  • \ point {a-SFD} {0} {22.5-14};

그림과 같이 X 좌표는 각 다이어그램의 원점에 대해 동일합니다. 그러나 서로 아래에 배치하기 위해 Y 좌표를 따라 오프셋을 설정했습니다. 오프셋 값은 첫 번째 다이어그램의 경우 (-6)이고 두 번째 다이어그램의 경우 (-14)입니다. 이 그림에만 위치하도록 tikz 환경 내에서 2 개의 오프셋을 정의 할 수 있습니다. 여기서 다음과 같이 점 좌표를 입력 할 수 있습니다.

Y1 = -6

Y2 = -14

  • \ point {a-LD} {0} {22.5};
  • \ point {a-FBD} {0} {22.5-Y1};
  • \ point {a-SFD} {0} {22.5-Y2};

오프셋은 한 번만 입력하고 여러 번 입력해야하므로 한 번만 변경해야하므로 변경시 여러 번이 아닌 한 번만 변경해야합니다.

\documentclass{article}
\usepackage{amsmath} 
\usepackage{stanli}

\begin{document}

\begin{center}
\begin{tikzpicture}

\draw[help lines,step=0.5](0,0) grid(15,24);


%%%%%%%%%%%%%%%%%%%%%%%%Loading%%%%%%%%%%%%%%%%

\point{a-LD}{0}{22.5};
\point{b-LD}{10}{22.5};
\point{su-LD}{2}{22.5+1.5};
\point{s-LD}{2}{22.5};
\point{sl-LD}{2}{22.5-0.5};
\point{TL-LD}{10}{22.5+2};
\point{CAP-LD}{10/2}{22.5-2.5};

% Elements

\beam{4}{a-LD}{b-LD};

%Supports

\support {1}{a-LD};
\support {2}{b-LD};


%Loads

\lineload{1}{a-LD}{b-LD}[0][2][0.035]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%First diagram%%%%%%%%%%%%%%%%%%

\point{a-FBD}{0}{22.5-6};
\point{b-FBD}{10}{22.5-6};
\point{TL-FBD}{2*10/3}{22.5-6};
\point{TLA-FBD}{2*10/3}{22.5-6+1.75};
\point{HR}{0-1.5}{22.5-6};
\point{VRA}{0}{22.5-6-1};
\point{VRB}{10}{22.5-6-1};
\point{CAP-FBD}{10/2}{22.5-6-3.5};

% Elements

\beam{4}{a-FBD}{b-FBD};




%%%%%%%%%%%%%%%%%Second diagram%%%%%%%%%%%%%%%%%%

\internalforces{a-FBD}{b-FBD}{-3}{6}[0][red]%[0]


\point{a-SFD}{0}{22.5-14};
\point{b-SFD}{10}{22.5-14};
\point{TL-SFD}{2*10/3}{22.5-14};
\point{TLA-SFD}{2*10/3}{22.5-14+1.75};
\point{VRA}{0}{22.5-14-1};
\point{VRB}{10}{22.5-14-1};
\point{CAP-SFD}{10/2}{22.5-14-3.5};

% Elements

\beam{4}{a-SFD}{b-SFD};

\internalforces{a-SFD}{b-SFD}{-3}{6}[3][red]%[0]


\end{tikzpicture}
\end{center}

\end{document}

답변

3 UlrichDiez Oct 25 2020 at 02:13

당신이 원하는 경우 Y1와 Y2상수로, 당신이 사용할 수있는 \pgfmathdeclarefunction인수를 처리하고 단지 상수의 값을 제공하지 않는 기능로 선언합니다.

아래 예제에서는 \pgfkeys매크로 \DeclareConstant및 \DeclareConstants.

\DeclareConstant{⟨name of constant⟩}{⟨value of constant⟩} 단일 상수를 선언하는 데 사용됩니다.

다음을 통해 여러 상수를 선언 할 수 있습니다 \DeclareConstants.

\DeclareConstants쉼표로 구분 된- 쌍 목록을 처리합니다.⟨name of constant⟩=⟨value of constant⟩

\DeclareConstants{
                   ⟨name of constant 1⟩=⟨value of constant 1⟩,
                   ⟨name of constant 2⟩=⟨value of constant 2⟩,
                                      ...
                   ⟨name of constant k⟩=⟨value of constant k⟩,
                 }

상수 자체의 값에 쉼표가 포함되어있는 경우, 예를 들어 다른 pgfmath-function의 인수 / 피연산자의 구분 기호로 해당 값은 중괄호로 중첩 될 수 있습니다.

⟨name of constant 2⟩={⟨value of constant 2⟩},

foobar={mod(-100,30)},

(상수 foobar값은 -10입니다. 다음 토큰 은 값을 할당하는 과정에서 =전달되고 -calculations의 \pgfmathparse결과로 생성되는 토큰 \pgfmathparse은 상수 값으로 전달되는 것을 형성합니다. 이렇게하면 계산이 반복되지 않습니다. 해당 상수가 사용됩니다.)

!!!!! 함께 있음을 알고 있어야 \DeclareConstant하고 \DeclareConstants쉽게 기존 pgfmath-기능을 대체 할 수 있습니다. !!!!!

그래서 상수 선언하지 마십시오 sin또는 cos같은 또는를. ;-)

TikZ 및 pgf 매뉴얼 인 pgfmanual.pdf 의 "97 수학적 엔진 사용자 지정"섹션 에서는 함수 이름에 대해 설명합니다.

함수 이름은 대문자 또는 소문자, 숫자 또는 밑줄로 구성 될 수 있습니다 _. 많은 프로그래밍 언어에 따라 함수 이름은 숫자로 시작하거나 공백을 포함 할 수 없습니다 .

( "다음으로 구성 될 수 있음"이라는 문구 바로 뒤에있는 가짜 쉼표가 설명서에 있습니다. 정확히 인용하기 위해 제거하지 않았습니다.)

예를 들어 상수 / 함수를 Y1정의 할 수 있지만 상수 / 함수를 정의 할 수는 없습니다 1Y.

\documentclass{article}
\usepackage{amsmath} 
\usepackage{stanli}

\newcommand\DeclareConstant[2]{%
  \pgfkeys{/MyStuff/declare constant={#1}{#2}}%
}%
\newcommand\DeclareConstants[1]{\pgfkeys{/MyStuff/.cd,#1,}}%
\newcommand\exchangeargs[2]{#2#1}%
\makeatletter
\pgfkeys{%
  /MyStuff/.unknown/.code=\pgfkeys{/MyStuff/declare constant={\pgfkeyscurrentname}{#1}},
  /MyStuff/declare constant/.code 2 args=%
  \begingroup
  \pgfmathparse{#2}%
  \ifcat$\detokenize{#1}$\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
  {%
    \GenericError{\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces}%
                 {Constant declaration error: Name of constant not specified}%
                 {\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces You cannot declare a constant without\MessageBreak specifying its name.}%
                 {You need some sort of identifier for referencing the constant.}%
    \ifcat$\detokenize\expandafter{\pgfmathresult}$\expandafter\@firstofone\else\expandafter\@gobble\fi
    {%
      \GenericError{\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces}%
                   {Constant declaration error: Value of constant not specified}%
                   {\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces You cannot declare a constant without\MessageBreak specifying its value.}%
                   {Which aspect of a constant could be constant if not its value?\MessageBreak So there must be a value!}%
    }%
    \endgroup
  }{%
    \ifcat$\detokenize\expandafter{\pgfmathresult}$\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
    {%
      \GenericError{\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces}%
                   {Constant declaration error: Value of constant not specified}%
                   {\space\space\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces You cannot declare a constant without\MessageBreak specifying its value.}%
                   {Which aspect of a constant could be constant if not its value?\MessageBreak So there must be a value!}%
      \endgroup
    }{%
      \expandafter\endgroup
      \expandafter\exchangeargs\expandafter{\expandafter{%
        \expandafter\def
        \expandafter\pgfmathresult
        \expandafter{\pgfmathresult}%
      }}{\pgfmathdeclarefunction*{#1}{0}}%
    }%
  },%
  /MyStuff/declare constant/.value required,%
}%
\makeatother


\begin{document}

\begin{center}
\begin{tikzpicture}

% \DeclareConstant{Y1}{-3-3};
% \DeclareConstant{Y2}{-14};
\DeclareConstants{
  Y1=-3-1-2,              % yields Y1=-6
  Y2={mod(-114,-100)},    % yields Y2=-14
  % Y3=...,
  % Y4=...,
  % foobar=...,
  % ...
};

\draw[help lines,step=0.5](0,0) grid(15,24);


%%%%%%%%%%%%%%%%%%%%%%%%Loading%%%%%%%%%%%%%%%%

\point{a-LD}{0}{22.5};
\point{b-LD}{10}{22.5};
\point{su-LD}{2}{22.5+1.5};
\point{s-LD}{2}{22.5};
\point{sl-LD}{2}{22.5-0.5};
\point{TL-LD}{10}{22.5+2};
\point{CAP-LD}{10/2}{22.5-2.5};

% Elements

\beam{4}{a-LD}{b-LD};

%Supports

\support {1}{a-LD};
\support {2}{b-LD};


%Loads

\lineload{1}{a-LD}{b-LD}[0][2][0.035]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%First diagram%%%%%%%%%%%%%%%%%%

\point{a-FBD}{0}{22.5+Y1};
\point{b-FBD}{10}{22.5+Y1};
\point{TL-FBD}{2*10/3}{22.5+Y1};
\point{TLA-FBD}{2*10/3}{22.5+Y1+1.75};
\point{HR}{0-1.5}{22.5+Y1};
\point{VRA}{0}{22.5+Y1-1};
\point{VRB}{10}{22.5+Y1-1};
\point{CAP-FBD}{10/2}{22.5+Y1-3.5};

% Elements

\beam{4}{a-FBD}{b-FBD};




%%%%%%%%%%%%%%%%%Second diagram%%%%%%%%%%%%%%%%%%

\internalforces{a-FBD}{b-FBD}{-3}{6}[0][red]%[0]


\point{a-SFD}{0}{22.5+Y2};
\point{b-SFD}{10}{22.5+Y2};
\point{TL-SFD}{2*10/3}{22.5+Y2};
\point{TLA-SFD}{2*10/3}{22.5+Y2+1.75};
\point{VRA}{0}{22.5+Y2-1};
\point{VRB}{10}{22.5+Y2-1};
\point{CAP-SFD}{10/2}{22.5+Y2-3.5};

% Elements

\beam{4}{a-SFD}{b-SFD};

\internalforces{a-SFD}{b-SFD}{-3}{6}[3][red]%[0]


\end{tikzpicture}
\end{center}

\end{document}