使用TikZ绘制球体和曲面

使用TikZ绘制球体和曲面

我想画这幅画,有人可以帮我完成吗?

我的照片

\documentclass[a4paper,11pt]{article}
                 
\usepackage{tikz} 

\begin{document}
    \begin{tikzpicture}
        \shade[ball color = brown, opacity=0.7] (0,0) circle (2cm);
        \draw (0,0) circle (2cm);
        \draw[thick, -latex] (-130:1cm) -- (-130:3.5cm) node [below] {$ x $}; % x axis
        \draw[thick, -latex] (-20:1cm) -- (-20:3.5cm) node [right] {$ y $}; % y axis
        \draw[thick, -latex] (90:1cm) -- (90:3.5cm) node [above] {$ z $}; % z axis
        \draw (60:1.5cm) -- (60:3.5cm) node [anchor=south west, xshift=-2em]
        {$ x^2 + y^2 + z^2 - a^2 = 0 $};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

我在这里采用 3d 方法。我认为它几乎一样简单,但看起来更好一些。我为你留下了标签。

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{3d}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x={(-0.3590cm,-0.4278cm)},y={(0.9333cm,-0.1646cm)},z={(0cm,0.8887cm)}]
  % coordinates
  \coordinate (A1) at ({-3+2*cos(60)}, 1.75,{ 2*sin(60)});
  \coordinate (C1) at ({-3+2*cos(60)},-1.75,{-2*sin(60)});
  \coordinate (A2) at ({ 3-2*cos(60)}, 1.75,{ 2*sin(60)});
  \coordinate (C2) at ({ 3-2*cos(60)},-1.75,{-2*sin(60)});
  % cylinder behind
  \begin{scope}[canvas is xz plane at y=-1.75]
    \shade [opacity=0.5,left color=blue!10,right color=blue!70,shading angle=0]
      (A1) arc (60:-60:2) -- (C1) arc (-60:60:2) -- cycle;
  \end{scope}
  % sphere
  \shade[draw,ball color=brown!70] (0,0,0) circle (1cm);
  % y,z axis
  \draw [-latex] (0,1,0) -- (0,3,0) node [right] {$y$};
  \draw [-latex] (0,0,1) -- (0,0,3) node [above] {$z$};
  % front cylinder 
  \begin{scope}[canvas is xz plane at y=-1.75]
    \shade [opacity=0.5,left color=green!10,right color=green!70,shading angle=0]
      (A2) arc (120:240:2) -- (C2) arc (240:120:2) -- cycle;
  \end{scope}
  % little dot and x axis
  \draw [fill=red] (1,0,0) circle (0.025 cm);
  \draw [-latex]   (1.025,0,0) -- (3,0,0) node [left]  {$x$};
\end{tikzpicture}
\end{document}

结果如下: 在此处输入图片描述

答案2

该图适用于 3D 渐近线:一个椭圆圆柱和一个球体。椭圆圆柱可以通过和x^2-z^2=1参数化。x=cosh(t)y=sinh(t)

在此处输入图片描述

unitsize(1cm);
import graph3;
currentprojection=orthographic(3,2,3,zoom=.9);
draw(unitsphere,yellow);
real a=3;
draw(Label("$x$",EndPoint),O--a*X,Arrow3());
draw(Label("$y$",EndPoint),O--a*Y,Arrow3());
draw(Label("$z$",EndPoint),O--a*Z,Arrow3());

// parabolic cylinder x^2 - z^2 = 1
triple f(pair M) {
real t=M.x, y=M.y;  
real x=sinh(t);
real z=cosh(t);
return (x,y,z);
}
triple g(pair M) {
real t=M.x, y=M.y;  
real x=-sinh(t);
real z=-cosh(t);
return (x,y,z);
}

real tmax = 1, tmin =-1;
real ymax = 2, ymin =-2;
surface elliptic_cylinder1=surface(f,(tmin,ymin),(tmax,ymax),Spline);
surface elliptic_cylinder2=surface(g,(tmin,ymin),(tmax,ymax),Spline);

draw(parabolic_cylinder1,cyan+opacity(.7));
draw(parabolic_cylinder2,cyan+opacity(.7));

相关内容