이 그림과 같이 점선을 그리는 방법은 무엇입니까?

이 그림과 같이 점선을 그리는 방법은 무엇입니까?

아래 그림과 같이 점선을 그리고 싶습니다.

여기에 이미지 설명을 입력하세요

나는 지금까지 다음을 달성했습니다.

여기에 이미지 설명을 입력하세요

MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
  \coordinate (c) at (0,-2);
  \coordinate (d) at (4,-2);
  \coordinate (e) at (2,-4);
  \draw[thick,red,zigzag] (-2,0) coordinate(a) -- (2,0) coordinate(b);
  \draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- (c);
  \draw[thick] (a) -- (c);
  \draw[thick,red,dashed] (0.8,0.08) -- (0,-0.8);
\end{tikzpicture}
\end{document} 

답변1

다음과 같은 작업은 그리 어렵지 않습니다 decorations.markings.

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{decorations.pathmorphing,decorations.markings}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
\coordinate (c) at (0,-2);
\coordinate (d) at (4,-2);
\coordinate (e) at (2,-4);
\draw[thick,red,zigzag,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (x);
    },
    decorate
}] (-2,0) coordinate(a) -- (2,0) coordinate(b);
\draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- cycle;
\draw[thick,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (y);
    },
    decorate
}] (a) -- (c);
\draw[dashed,red,thick] (x)--(y);
\end{tikzpicture}
\end{document} 

여기에 이미지 설명을 입력하세요

보너스

전체 수치:

\documentclass[tikz,margin=3mm]{standalone}
\usepackage{mathrsfs}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,calc,positioning}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
\coordinate (c) at (0,-2);
\coordinate (d) at (4,-2);
\coordinate (e) at (2,-4);
\draw[thick,red,zigzag,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (x);,
        mark=at position 0.5 with \coordinate (singularity);
    },
    decorate
}] (-2,0) coordinate(a) -- (2,0) coordinate(b);
\draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- cycle;
\draw[thick,postaction={
    decoration={
        markings,
        mark=at position 0.7 with \coordinate (y);
    },
    decorate
}] (a) -- (c);
\draw[dashed,red,thick] (x)--(y);
\node[below left=1em and 1em of y,align=right,red] (es) {excision\\surface};
\draw[red,->] (es)--($(y)+(-.1,-.1)$);
\node[above=10ex of singularity,red] (sn) {singularity};
\draw[red,->] (sn)--($(singularity)+(0,1)$);
\node[below left=.5ex and 2ex of b] {$\mathcal{H}^+$};
\path (b) -- (d) node[midway,above right] {$\mathcal{I}^+$};
\path (d) -- (e) node[midway,below right] {$\mathcal{I}^-$};
\path (e) -- (c) node[midway,below left] {$\mathcal{H}^-$};
\node[right=0pt of d] {$i^0$};
\draw[postaction={
    decoration={
        markings,
        mark=at position 0.15 with \coordinate (enblue);
    },
    decorate
},thick,blue] (d) to[out=-150,in=-30] (c);
\draw[<-,thick,blue] (enblue)--($(enblue)+(-60:1)$)--($(enblue)+(-60:1)+(.2,0)$) node[right,align=left] {$t$ = constant\\in Schwarzschild\\coordinates};
\path[postaction={
    decoration={
        markings,
        mark=at position 0.35 with \coordinate (engren);
    },
    decorate
}] (c)--(b);
\draw[thick,green!50!black,postaction={
    decoration={
        markings,
        mark=at position 0.6 with \coordinate (enargr);
    },
    decorate
}] (d) to[out=180,in=-30] (engren);
\draw[thick,dashed,green!50!black] (engren)--($(engren)+(150:0.7)$);
\draw[<-,thick,green!50!black] (enargr)--($(enargr)+(60:0.75)$)--($(enargr)+(60:0.75)+(2,0)$) node[right,align=left] {$\tau$ = constant\\in Kerr-Schild\\coordinates};
\end{tikzpicture}
\end{document} 

여기에 이미지 설명을 입력하세요

답변2

intersections두 경로의 교차점을 계산할 수 있는 라이브러리를 사용할 수 있습니다 . 여기에 zigzag경로와 dashed경로가 있습니다.

점선 평행선을 그리기 위해 calc라이브러리를 사용했습니다.

원칙. 나는 당신의 길을 유지했으며 \draw[thick,red,dashed] (0.8,0.08) -- (0,-0.8);올바른 교차점을 찾기 위해 시행 착오를 거쳐 시작점을 오른쪽으로 이동했습니다.

i이 경로와 의 이름이 붙은 교차점을 계산했습니다 zigzag. 그런 다음 나는평행한dash이 지점을 통해 호출되는 경로입니다 .

새로운 버전

파란색 사각형은 직각을 가지므로 평행선을 그리기 위해 측면 i에 점을 직각으로 투영합니다 ac.

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
  \coordinate (c) at (0,-2);
  \coordinate (d) at (4,-2);
  \coordinate (e) at (2,-4);
  \draw[name path=zz,thick,red,zigzag] (-2,0) coordinate(a) -- (2,0) coordinate(b);
  \draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- (c);
  \draw[thick,name path=ac] (a) -- (c);
  \path[name path=trans] (.9,0.08) -- (0,-0.8);
  \coordinate [name intersections={of= zz and trans,by={i}}];
  % orthogonal projection of (i) on (a)--(c)
  \coordinate (l) at ($(a)!(i)!(c)$);
  \draw [thick,red,dashed] (i) -- (l);
\end{tikzpicture}
\end{document} 

구 버전

이 경로와 반대쪽(측면 ac)의 교차점을 계산하고 평행선을 그립니다 (i)--(l).

\documentclass[tikz,border=5mm]{standalone}

%\usepackage{xcolor}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\tikzset{zigzag/.style={decorate,decoration=zigzag}}
\begin{document}
\begin{tikzpicture}
  \coordinate (c) at (0,-2);
  \coordinate (d) at (4,-2);
  \coordinate (e) at (2,-4);
  \draw[name path=zz,thick,red,zigzag] (-2,0) coordinate(a) -- (2,0) coordinate(b);
  \draw[thick,fill=blue!20] (c) -- (b) -- (d) -- (e) -- (c);
  \draw[thick,name path=ac] (a) -- (c);
  \path[name path=trans] (.9,0.08) -- (0,-0.8);
  \coordinate [name intersections={of= zz and trans,by={i}}];
  \coordinate (j) at ($(i)+(c)-(b)$);
  \coordinate(k) at ($(i)+(b)-(c)$);
  \path[name path=dash](j)--(k);
  \path[name intersections={of= ac and dash,by={l}}];
  \draw [thick,red,dashed] (i) -- (l);
\end{tikzpicture}
\end{document} 

스크린샷

답변3

다른 두 점 사이의 중간 지점이 어디에 있는지 쉽게 계산할 수 있습니다.

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{decorations.pathmorphing,calc}
\tikzset{
    zigzag/.style={
        decorate,
        decoration={
            zigzag,
            amplitude=2.5pt,
            segment length=2.5mm
        }
    }
}
\begin{document}
    \def\position{0.6}
    \begin{tikzpicture}[thick]
        \coordinate (c) at (0,-2);
        \coordinate (d) at (4,-2);
        \coordinate (e) at (2,-4);
        \draw[red, zigzag] (-2,0) coordinate(a) -- (2,0) coordinate(b);
        \draw[fill=blue!20] (c) -- (b) -- (d) -- (e) -- (c);
        \draw (a) -- (c);
        \draw[red, densely dashed, shorten >=0.5pt] ($(a)!\position!(c)$) -- ($(a)!\position!(b)$);
    \end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

답변4

실수로 동일한 다이어그램에 대한 코드를 찾았습니다.TeXample.net. 소스 코드에 작성된 코드 작성자는 Jonah Miller입니다. 그래서 나는 그것을 CW로 게시하기로 결정했습니다.

% Horizon penetrating coordinates (vs. Schwarzschild coordinates)
% for a black hole spacetime, with excision
% Author: Jonah Miller
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.pathmorphing}

\tikzset{zigzag/.style={decorate, decoration=zigzag}}
\def \L {2.}

% fix for bug in color.sty
% see: http://tex.stackexchange.com/questions/274524/definecolorset-of-xcolor-problem-with-color-values-starting-with-f
\makeatletter
\def\@hex@@Hex#1%
 {\if a#1A\else \if b#1B\else \if c#1C\else \if d#1D\else
  \if e#1E\else \if f#1F\else #1\fi\fi\fi\fi\fi\fi \@hex@Hex}
\makeatother

% Define a prettier green
\definecolor{darkgreen}{HTML}{006622}

\begin{document}
\begin{tikzpicture}

  % causal diamond
  \draw[thick,red,zigzag] (-\L,\L) coordinate(stl) -- (\L,\L) coordinate (str);
  \draw[thick,black] (\L,-\L) coordinate (sbr)
    -- (0,0) coordinate (bif) -- (stl);
  \draw[thick,black,fill=blue, fill opacity=0.2,text opacity=1] 
    (bif) -- (str) -- (2*\L,0) node[right] (io) {$i^0$} -- (sbr);

  % null labels
  \draw[black] (1.4*\L,0.7*\L) node[right]  (scrip) {$\mathcal{I}^+$}
               (1.5*\L,-0.6*\L) node[right] (scrip) {$\mathcal{I}^-$}
               (0.2*\L,-0.6*\L) node[right] (scrip) {$\mathcal{H}^-$}
               (0.5*\L,0.85*\L) node[right] (scrip) {$\mathcal{H}^+$};

  % singularity label
  \draw[thick,red,<-] (0,1.05*\L) 
    -- (0,1.2*\L) node[above] {\color{red} singularity};
  % Scwharzschild surface
  \draw[thick,blue] (bif) .. controls (1.*\L,-0.35*\L) .. (2*\L,0);
  \draw[thick,blue,<-] (1.75*\L,-0.1*\L)  -- (1.9*\L,-0.5*\L)
    -- (2*\L,-0.5*\L) node[right,align=left]
    {$t=$ constant\\in Schwarzschild\\coordinates};
  % excision surface
  \draw[thick,dashed,red] (-0.3*\L,0.3*\L) -- (0.4*\L,\L);
  \draw[thick,red,<-] (-0.33*\L,0.3*\L) 
    -- (-0.5*\L,0.26*\L) node[left,align=right] {excision\\surface};
  % Kerr-Schild surface
  \draw[darkgreen,thick] (0.325*\L,0.325*\L) .. controls (\L,0) .. (2*\L,0);
  \draw[darkgreen,dashed,thick] (0.325*\L,0.325*\L) -- (-0.051*\L,0.5*\L);
  % Kerr-Schild label
  \draw[darkgreen,thick,<-] (0.95*\L,0.15*\L) -- (1.2*\L,0.5*\L)
    -- (2*\L,0.5*\L) node[right,align=left]
    {$\tau=$ constant\\in Kerr-Schild\\coordinates};
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보