线积分的应用

线积分的应用

我是硕士生,刚开始接触 LaTeX,前两天想画一张图,但不知道怎么画,我试了很多次。我试着像附图这样画。

这是我尝试过的另一个代码,但这个图表太小了。

\documentclass[a4paper, oneside]{standalone}
\usepackage{tikz}







\begin{document}
\begin{pgfpicture}
    \pgfsetcornersarced{\pgfpoint{5pt}{5pt}}
    \pgfpathmoveto{\pgfpointpolar{340}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{10}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{20}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{30}{0.4cm}}
%   \pgfpathlineto{\pgfpointpolar{40}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{50}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{60}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{70}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{80}{1cm}}
    \pgfpathlineto{\pgfpointpolar{90}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{100}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{110}{0.5cm}}  
%   \pgfpathlineto{\pgfpointpolar{120}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{130}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{140}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{150}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{160}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{170}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{180}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{290}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{200}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{210}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{220}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{230}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{240}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{250}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{260}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{270}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{280}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{290}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{300}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{310}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{320}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{330}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{340}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{350}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{360}{1cm}}



%   \pgfpathlineto{\pgfpointpolar{115}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{135}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{145}{1cm}}




%   \pgfpathlineto{\pgfpointpolar{135}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{155}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{165}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{265}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{300}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{315}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{325}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{360}{1cm}}
    \pgfpathclose
    \pgfusepath{stroke}



    \begin{tikzpicture}[ thin]
    \draw[->] (-3.3,-0.3) -- (-2.1,-0.1);
%   \draw (-3.1,-2.2) -- (-2.1,-1.7);
    \draw (-3.2,-0.5) -- (-2.1,-0.3);
    \draw (-3.1,-0.7) -- (-2.1,-0.5);
    %\begin{scope}[thin]
    %\draw (-4,0.-3) -- (0,-1);
    %\draw (2,0) -- (2,1);
    %\end{scope}
    \draw (3,0) -- (3,1);
    \end{tikzpicture}





\end{pgfpicture}






%\begin{tikzpicture}[ultra thick]
%\draw (0,0) -- (0,1);
%\begin{scope}[thin]
%\draw (1,0) -- (1,1);
%\draw (2,0) -- (2,1);
%\end{scope}
%\draw (3,0) -- (3,1);
%\end{tikzpicture}

\end{document}





\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{figure}[h!]
  \begin{center}
    \begin{tikzpicture}
      \draw [thick] (-1,2) % Draws a line
      to [out=10,in=190] (1,4)
     % to [out=10,in=190] (1,3)
      to [out=10,in=90] (6,0)

      to [out=-90,in=-30] (-1,2);    
    \end{tikzpicture}
    \caption{fig 2.}
  \end{center}
\end{figure}
\end{document}

答案1

我只画了第二张图。

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\tikzset {b/.code = {\pgfsetadditionalshadetransform{ \pgftransformshift{\pgfpoint{0 bp } { 0 bp }  }  \pgftransformrotate{0 }  \pgftransformscale{2 }  }}}
\pgfdeclarehorizontalshading{a}{150bp}{rgb(0bp)=(1,1,1);
rgb(37.5bp)=(1,1,1);
rgb(45.427829197474885bp)=(0.88,0.88,0.88);
rgb(50bp)=(0.95,0.95,0.95);
rgb(62.5bp)=(0.96,0.96,0.96);
rgb(100bp)=(0.96,0.96,0.96)}
\tikzset{every picture/.style={line width=0.75pt}}
\begin{document}

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
\draw    (180,111) -- (112,172) ;
\draw [shift={(112,172)}, rotate = 318.26] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.3)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw    (180,111) -- (180,12) ;
\draw [shift={(180,12.32)}, rotate = 450] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw    (180,111.32) -- (315,112) ;
\draw [shift={(315,112)}, rotate = 180.42] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\path  [shading=a,b] (208,68) .. controls (228,58) and (318,48) .. (298,68) .. controls (278,88) and (278,98) .. (298,128) .. controls (318,158) and (228,158) .. (208,128) .. controls (188,98) and (188,78) .. (208,68) ;  
 \draw   (208,68) .. controls (228,58) and (318,48) .. (298,68) .. controls (278,88) and (278,98) .. (298,128) .. controls (318,158) and (228,158) .. (208,128) .. controls (188,98) and (188,78) .. (208,68) ; 
\draw    (243.5,76.47) -- (289,32.47) ;
\draw [shift={(289,32.47)}, rotate = 495.96] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw  [dash pattern={on 0.85pt off 2.50pt}]  (204,113) -- (244,77) ;
\draw    (163,150) -- (200,117);
\draw    (181,171) -- (217.6,138) ;
\draw    (171,161) -- (208,128) ;
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (224,133.2) -- (264,96) ;
\draw    (263.5,96.47) -- (309,52.47) ;
\draw [shift={(309,53)}, rotate = 496] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw  [dash pattern={on 0.84pt off 2.51pt}]  (214.6,123.19) -- (254.5,86.47) ;
\draw    (254.5,86) -- (300,42) ;
\draw [shift={(300,43)}, rotate = 496] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw    (199,74) -- (200,6.46) ;
\draw [shift={(200,6.46)}, rotate = 450.85] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (11,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw    (199,74) -- (233,47) ;
\draw [shift={(233,47)}, rotate = 500] [color=black ]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw (135,170) node [scale=0.8]  {$x$};
\draw (331,116) node [scale=0.8]  {$y$};
\draw (166,28) node [scale=0.8]  {$z$};
\draw (306,150) node [scale=0.8]  {$C$};
\draw (315,37) node [color=black ,opacity=0.7]  {$I$};
\draw (210,29) node [scale=0.8]  {$\mathbf{B}$};
\draw (246,43) node [scale=0.8]  {d$\overline{r}$};


\end{tikzpicture}

\end{document}

答案2

所有这些\pgfpathlineto坐标等在原则上都是可行的,但只有当您想要发明新的装饰等时才真正有用。但是,如果您想制作一些类似 3D 的图片,我建议您使用 tikz-3dplot。这里有两个简单的例子,希望它们足够简单和不言自明,以便您可以根据需要进行调整。

在此处输入图片描述

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=latex,tdplot_main_coords]
\draw[->] (0,0,0) -- (3,0,0)node[below]{$x$};
\draw[->] (0,0,0) -- (0,3,0)node[below]{$y$};
\draw[->] (0,0,0) -- (0,0,3)node[left]{$z$};
\draw [fill] (0,0,0) circle (0.5pt) node[below]{0};
\draw[thick] (0,0,1) to[out=80,in=165] (1,1,2) coordinate(X) to[out=-15,in=150] (1,2.5,1);
\draw[->] (0,0,0) -- (X) node[midway,right]{$\vec r$};
\draw[->] (X) --++(0.1,0.4,0.) node[above] {d$\vec r$};
\end{tikzpicture}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle,tdplot_main_coords]
\draw[-latex] (0,0,0) -- (0,0,3)node[left]{$B$};
\foreach \X in {1,2,3}
\draw[very thick,->] (1,{0.5*\X},0) -- ++(0,1,3);
\begin{scope}
\clip plot [smooth cycle] coordinates {(0,0,1) (1,2,2)  (1,2.5,1)
(0.1,2,0.2)};
\fill[white] plot [smooth cycle] coordinates {(0,0,1) (0,1,1)  (1,2.5,0.8)
(0.1,2,0)};
\end{scope}
\draw[thick] plot [smooth cycle] coordinates {(0,0,1) (1,2,2)  (1,2.5,1)
(0.1,2,0.2)};
\node at (1,2.6,0.5) {$C$};
\end{tikzpicture}
\end{document}

相关内容