我制作了以下代码:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage[english]{babel}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\shade[ball color=red] (0,0,0) circle (2cm);
\fill[opacity=0.5,blue] (-3,0,1) -- (-1,2,1) -- (5,2,1) -- (3,0,1) -- cycle;
\end{tikzpicture}
\end{document}
我改编自这个帖子(非常感谢!)。并产生:
但我想要做的是这样的:
问题:我该怎么做路口球面与平面的关系?
答案1
这是使用 Asymptote 的解决方案:
生成它的代码:
\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=SphereAndPlane}
settings.outformat = "png";
settings.render = 8;
size(10cm, 0); // Final image will be 10cm wide, unlimited height.
import three; // Enable three-dimensional functionality.
currentprojection = orthographic(2,5,1);
draw(unitsphere, red);
draw(surface((-2,-2,0) -- (-2,2,0) -- (2,2,0) -- (2,-2,0) -- cycle), blue + opacity(0.5));
\end{asypicture}
\end{document}
% file: foo.tex
% to compile: pdflatex --shell-escape foo
%
% For MikTeX users: Asymptote requires a separate program that cannot be installed
% by the package manager. You can get the installation file from
% https://sourceforge.net/projects/asymptote/files/2.35/
% (specifically, the file ending in setup.exe).
如果你使用的是 MacTeX 的较新版本(或者,我猜是 TeX Live),并且已完整安装,那么这应该可以正常工作。如果你使用的是 MikTeX,则需要安装渐近线计划正如之后的评论所述\end{document}
。
答案2
这里有一个想法:“假”3D 绘制两个平面,一个在球的“后面”,一个在球的“前面”。3D 效果是通过切掉半个椭圆来实现的。“不太假”的 3D 方法使用pgf图首先绘制下半球,然后绘制表面,然后绘制上半球。可能有人会上传一个普斯特里克解决方案,因为它在 3D 方面具有极大的优势。
代码
\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\fill[blue!50!gray, opacity=0.7] (0,0) -- (5,0) -- (4,2) -- (1,2) -- cycle;
\shade[ball color=red] (2.5,0) circle (1);
\fill[blue!50!gray, opacity=0.7] (0,0) -- (1.5,0) arc (180:360:1 and 0.5) -- (5,0) -- (6,-2) -- (-1,-2) -- cycle;
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}
[ axis equal,
hide axis,
view={30}{30},
z buffer=sort,
]
\addplot3
[ domain=0:360,
y domain=0:180,
surf,
shader=flat,
red,
opacity=0.5
] ({sin(y)*cos(x)},{sin(y)*sin(x)},{cos(y)});
\addplot3
[ domain=-2:2,
y domain=-2:2,
surf,
shader=flat,
blue,
opacity=0.5,
] (x,y,0);
\addplot3
[ domain=0:360,
y domain=0:90,
surf,
shader=flat,
red,
opacity=0.5,
] ({sin(y)*cos(x)},{sin(y)*sin(x)},{cos(y)});
\end{axis}
\end{tikzpicture}
\end{document}
输出
答案3
运行xelatex
\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=50 0 10 rtp2xyz,Decran=70,lightsrc=80 20 70,
linewidth=0.001pt,action=none}
\begin{pspicture}[solidmemory](-4,-2)(4,2)
%\axesIIID(3,3,6)
\psSolid[object=plan,definition=equation,args={[0 0 1 0]},
base=-3 3 -2 2,ngrid=20 20,fillcolor=red!30,name=B1]
\psSolid[object=sphere,r=1,fillcolor=cyan,ngrid=18 36,
name=C1,action=none]
\psSolid[object=fusion,base=B1_s C1,action=draw**]
\end{pspicture}
\end{document}