在画的线上标记一个位置

在画的线上标记一个位置

我正在尝试标记我所绘制的轨迹线上的位置。标记应大致位于相同的位置,例如线长度的 X%。

我当前的代码

\begin{tikzpicture}
    \definecolor{edge}{RGB}{135,206,250}
    \definecolor{asphalt}{RGB}{153,153,153}
    \definecolor{marker}{RGB}{144,238,144}
    

    \coordinate (step_right) at (1.5,0);
    \coordinate (step_up) at (0,0.5);
    \coordinate (car_height) at (0,0.3);
    
    \coordinate (E0) at (2,1.5);
    \coordinate (E1) at ($(E0) + 2*(step_right)$);
    \coordinate (E11) at ($(E1) + (step_up)$);
    \coordinate (E12) at ($(E1) - (step_up)$);£
    \coordinate (E2) at ($(E1) + 2*(step_right)$);
    \coordinate (E21) at ($(E2) + (step_up)$);
    \coordinate (E22) at ($(E2) - (step_up)$);
    \coordinate (E3) at ($(E2) + 2*(step_right)$);
    
    
    \fill[asphalt] (0,0) rectangle ++(15,3);
    

    \draw[edge, ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E1) - (step_right)$) .. (E1);
    \draw[edge, ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E11) - (step_right)$) .. (E11);
    \draw[edge, ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E12) - (step_right)$) .. (E12);
    
    \draw[edge, ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E2) - (step_right)$) .. (E2);
    \draw[edge, ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E21) - (step_right)$) .. (E21);
    \draw[edge, ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E22) - (step_right)$) .. (E22);
    
    \node[inner sep=0pt] (ego) at ($(E0) - (car_height)$) {\includegraphics[width=.05\textwidth, angle=-90, origin=c]{images/methodology/car_blue}};
    %\draw (E) -- (E1) node [circle, midway, fill=white] {};    
    
\end{tikzpicture}

生成:

当前数字

我想要这样的东西:

期望身材

标记的外观并不那么严格,我很乐意进行调整。但它们必须标记一个具体的位置。我尝试过使用定位的标签midway来实现这一点,但我不知道它是否可以应用于我正在使用的样条曲线。

此外,我想添加白色和红色条纹边界,就像他们有的一样一级方程式赛车。我不确定解决这个问题的最佳方法是什么。

提前感谢你的帮助!

答案1

一个简单的解决方案是使用decorations.markings带有箭头尖装饰的库,位置为 0.75。

线上的标记

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,decorations.markings}

\tikzset{mymark/.style={
            decoration={ markings,mark=at position 0.75 with{\arrow[blue,line width=1.5pt]{|}};}},
        markedsegment/.style={mymark,postaction={decorate}}}
    
\begin{document}

\begin{tikzpicture}
    \definecolor{edge}{RGB}{135,206,250}
    \definecolor{asphalt}{RGB}{153,153,153}
    \definecolor{marker}{RGB}{144,238,144}
    

    \coordinate (step_right) at (1.5,0);
    \coordinate (step_up) at (0,0.5);
    \coordinate (car_height) at (0,0.3);
    
    \coordinate (E0) at (2,1.5);
    \coordinate (E1) at ($(E0) + 2*(step_right)$);
    \coordinate (E11) at ($(E1) + (step_up)$);
    \coordinate (E12) at ($(E1) - (step_up)$);
    \coordinate (E2) at ($(E1) + 2*(step_right)$);
    \coordinate (E21) at ($(E2) + (step_up)$);
    \coordinate (E22) at ($(E2) - (step_up)$);
    \coordinate (E3) at ($(E2) + 2*(step_right)$);
    
    
    \fill[asphalt] (0,0) rectangle ++(15,3);
    
    
    \draw[edge, ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E1) - (step_right)$) .. (E1);
    \draw[edge, markedsegment,ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E11) - (step_right)$) .. (E11);
    \draw[edge, markedsegment,ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E12) - (step_right)$) .. (E12);
    
    \draw[edge, ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E2) - (step_right)$) .. (E2);
    \draw[edge, markedsegment,ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E21) - (step_right)$) .. (E21);
    \draw[edge, markedsegment,ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E22) - (step_right)$) .. (E22);
    
   
    
\end{tikzpicture}

如果你想留下自己的印记飞行中,你可以像这样修改一下你的 tikzstyle:

\tikzset{mymark/.style={
            decoration={ markings,mark=at position #1 with{\arrow[blue,line width=1.5pt]{|}};}},
        markedsegment/.style={mymark=#1,postaction={decorate}}}

像这样调用它:

    \draw[edge, ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E1) - (step_right)$) .. (E1);
    \draw[edge, markedsegment=0.75,ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E11) - (step_right)$) .. (E11);
    \draw[edge, markedsegment=0.5,ultra thick] (E0) .. controls ($(E0) + (step_right)$) and ($(E12) - (step_right)$) .. (E12);
    
    \draw[edge, ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E2) - (step_right)$) .. (E2);
    \draw[edge, markedsegment=0.85,ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E21) - (step_right)$) .. (E21);
    \draw[edge, markedsegment=0.9,ultra thick] (E1) .. controls ($(E1) + (step_right)$) and ($(E22) - (step_right)$) .. (E22);

由此产生了如下结果:

飞行中的标记

相关内容