Tikz/PGF 上的函數 3D 曲線

Tikz/PGF 上的函數 3D 曲線

所以,我是 Tikz/PGF 的新手,我正在嘗試繪製一張圖像,顯示速度隨時間和距離的變化。

藍線顯示物體首先具有到達某一點的線速度(函數 υ=χ*τ)。紅線顯示物件以常數 a=1 減速(函數 x= υ0t - ½ αt^2)。當我實現減速函數時,紅色曲線不沿著時間軸移動 t(或 y 軸),儘管它會改變速度(應該趨向於 0)和距離(會增長)。我究竟做錯了什麼?預先感謝您的提示和解決方案!

\documentclass[border=45pt]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{pgfmath}
\usepackage{amsmath}
\usepackage{tikz-3dplot}
\pgfplotsset{compat=newest}

\begin{document}    
\begin{tikzpicture} [ 
    % Define Time with Constant Speed Function 
    declare function={
        linear(\x,\u,\t)= \x / \u;},
     %Define Breaking / Deceleration Function with a=1
    declare function={
        curve(\x,\u,\t)= (\u * \t -(1/2 * 1 * \t^2));}
            ]
    
    \begin{axis}[
        %view={90}{60},
        no markers,
        zmin=0, zmax=10,
        xmin=0, xmax=10,
        ymin=0,ymax=10,
        xtick={3},
        xticklabels={$u_0$},
        ytick={2},
        yticklabels={$t_{safe}$},           
        ztick={6},
        zticklabels={$x_{MP}$},         
        axis lines=middle,
        zlabel=$x$, zlabel style={at={(rel axis cs:0,0,1)}, anchor=east},
        xlabel=$u$, xlabel style={at={(rel axis cs:1,0,0)}, anchor=west},
        ylabel=$t$, ylabel style={at={(rel axis cs:0,1,0)}, anchor=south west}  
         ]



        %dashed Tsafe 
          \draw[dashed] (6,2,0)--(0,2,0); % change middle variable = y to move line on y = t                         axis, also move ticks on above set


       %grayrectangle on Tsafe
        \fill[fill=gray!13,opacity=0.8] (0,2,0) -- (6,2,0) -- (6,2,6) -- (0,2,6) -- (0,2,0); % change middle variable = y to adjust plane on tsafe axis

       %grayrectangle on Xmp
         \fill[fill=gray!15, opacity=0.8] (0,0,6) -- (0,4,6) -- (6,4,6)-- (6,0,6) --   (0,0,6); % if MP point changes, change right variable = z to move plane on z = x axis, also move    ticks on above set

           \addplot3 [blue!50!black, thick,domain=0:1] (3,x, {linear(x,3,0)}); %point         (x,u,t) = (3m,3m/s,1s)
           \addplot3 [red!50!black,thick,domain=0:3] (3-y,1,{curve(3,5,y)});


    
          \end{axis}
         \end{tikzpicture}
       \end{document}

相關內容