tikz 中带有网格线的曲线表面

tikz 中带有网格线的曲线表面

在此处输入图片描述我想绘制一个具有网格线和单位向量的曲线表面的笛卡尔坐标系。绘图看起来如附图所示。我也尝试过绘图,但这不是最佳选择。

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{backgrounds,arrows.meta}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
%\tdplotsetmaincoords{60}{110}
\centering

\begin{tikzpicture}

\draw [ultra thick] [ ->] (-2, 0,0) --++ (14,0,0) node[anchor= west]{$T^{s}_{i}(t_1)$};
\draw [ultra thick] [ ->] (-2, 0,0) -- ++(0,10,0)node[anchor= south]{$T^{s}_{i}(t_N)$};
\draw [ultra thick] [-] (-2, 0,0) -- (0,0, -11.2);

%% Draw the manifold
\draw[very thick] (8,2,1) to [out=120,in=50] (-2.9, 2, -3);
\draw[very thick] (7.62,1.6,0) to [out=80,in=140] (6.5, 1.4, -9.65) ;
\draw[very thick] (6.6,1.4,-9.5) to [out=130,in=5] (2.5, 6.59, -3.0) ;
\draw[very thick] (-2.5, 2.4,-2.0) to [out=70,in=185] (0, 3.67, -10.7) ;
%\draw[step=10mm, black] (8,2,1) to (-2.9,2,-3) grid (4,4);

% Draw Grid Lines 
\draw[very thick] (6.8,2.05,-0.8) to [out=80,in=140] (5.97, 1.7, -10) ;
\draw[very thick] (6.1,2.45,-1.23) to [out=80,in=135] (5.1, 1.8, -11) ;
\draw[very thick] (5.6,2.95,-1.1) to [out=80,in=140] (5.1, 2.6, -9.8) ;
\draw[very thick] (5.1,3.4,-.9) to [out=80,in=145] (5.1, 3.3, -8.8) ;
\draw[very thick] (4.7, 3.8,-.6) to [out=75,in=185] (4.3, 4.1, -8.2) ;
\draw[very thick] (4.3, 4.15,-.3) to [out=75,in=190] (4.0, 4.58, -7.5) ;
\draw[very thick] (4, 4.6,0.3) to [out=80,in=190] (3.6, 4.9, -7) ;
\draw[very thick] (3.5, 4.7,.3) to [out=80,in=190] (3.2, 5.4, -6) ;
\draw[very thick] (3.1, 5,.7) to [out=85,in=180] (3, 5.6, -5.6) ;
\draw[very thick] (2.7, 5.15, 1) to [out=85,in=175] (2.5, 5.59, -5.7) ;
\draw[very thick] (2.3, 5.2, 1.2) to [out=90,in=180] (2.1, 5.81, -5.1) ;
\draw[very thick] (1.8, 5.25, 1.4) to [out=90,in=185] (1.6, 6.0, -4.31) ;
\draw[very thick] (1.3, 5.25, 1.6) to [out=95,in=190] (1.2, 6.0, -4.0) ;
\draw[very thick] (0.8, 5.1, 1.6) to [out=100,in=190] (1.2, 6.0, -3.9) ;
\draw[very thick] (0.3, 4.9, 1.6) to [out=100,in=195] (1.2, 6.03, -3.9) ;
\draw[very thick] (-0.35, 4.5, 1.6) to [out=85,in=200] (1, 6.0, -3.8) ;

%% Draw Grid lines
\draw[very thick] (7.8,2.5,0) to [out=120,in=65] (-2.8, 2.18, -2.9);
\draw[very thick] (7.8,3,-0.7) to [out=130,in=45] (-2.6, 3.05, -4);
\draw[very thick] (7.8,3.4,-1.2) to [out=130,in=35] (-2.2, 3.75, -4.6);
\draw[very thick] (7.8,3.7,-2) to [out=130,in=40] (-2, 4, -5);
\draw[very thick] (8,4,-2.6) to [out=130,in=40] (-1.5, 4.4, -5.3);
\draw[very thick] (8.5,4.35,-2.5) to [out=130,in=-10] (2.5, 5.24, -6.6);

\end{tikzpicture}
\end{document}

答案1

pgfplots欢迎!这展示了如何在 3d 中使用非线性变换。我无法判断这是否是最好的方法(相对于使用网格图而言)。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usepgflibrary{fpu}
\usepgfmodule{nonlineartransformations} 
\newcommand{\PgfmathsetmacroFPU}[2]{\begingroup% https://tex.stackexchange.com/a/503835
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}%
\makeatletter
\def\fancyspheretransformation{% similar to the pgfmanual section 103.4.2
\PgfmathsetmacroFPU{\XYTwo}{\pgf@x*\pgf@x+\pgf@y*\pgf@y}%
\PgfmathsetmacroFPU{\zvalue}{(1.2*\XYTwo)/(\XYTwo/\spradius+4*\spradius)}%
\PgfmathsetmacroFPU{\xvalue}{(2*\spradius+\zvalue)/(2*\spradius)*\pgf@x}%
\PgfmathsetmacroFPU{\yvalue}{(2*\spradius+\zvalue)/(2*\spradius)*\pgf@y}%
\PgfmathsetmacroFPU{\myx}{cos(\tdplotmainphi)*\xvalue+sin(\tdplotmainphi)*\yvalue}%
\PgfmathsetmacroFPU{\myy}{-cos(\tdplotmaintheta)*sin(\tdplotmainphi)*\xvalue+cos(\tdplotmaintheta)*cos(\tdplotmainphi)*\yvalue-sin(\tdplotmaintheta)*\zvalue}%
\pgf@y=\myy pt% \typeout{z=\zvalue,x=\xvalue,y=\yvalue}%
\pgf@x=\myx pt%
} 
\makeatother
\begin{document}
\begin{tikzpicture}
 \def\spradius{4cm} %<- maybe not a good practice
 \tdplotsetmaincoords{70}{110}
 \begin{scope}[tdplot_main_coords,canvas is xy plane at z=-4]
  \draw (-3,-3) grid (3,3);
 \end{scope}
 \begin{scope}[transform shape nonlinear=true,]
  \pgftransformnonlinear{\fancyspheretransformation}
  \draw (-3,-3) grid (3,3);
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容