我在球形帽上画圆弧时遇到了麻烦。如果有人能帮助我,我将不胜感激。以下是输出图像:
这是我目前拥有的代码:
\documentclass[letter, 10pt]{article}
% Mathematics
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{physics}
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{esvect} % Use \hat{} for vectors
% Fonts
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
% Graphics
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots} % Allows for plots/graphs
\usepackage{xcolor}
% Other
\usepackage{epstopdf}
\usepackage{float}
\usepackage{array}
\usepackage{hhline}
\usepackage{arydshln}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{framed}
\usepackage{mdframed}
\usepackage{multicol}
\usepackage{enumitem}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[font=\tiny]
% Coordinate System
\draw[dashed, line width=0.1pt] (0,-3) -- (0,3) ;
\draw[dashed, line width=0.1pt] (3,0) -- (-3,0) ;
\draw[dashed, line width=0.1pt] (0,0) -- (30:2.5) ;
\draw[dashed, line width=0.1pt] (0,0) -- (30:-2.5) ;
% Top cap
\draw (-1,2) arc (180:360:1 and 0.35) ;
\draw (1,2) arc (0:180:1 and 0.35) ;
\fill (0,2.25) circle (0.5pt);
% A bad attempt to draw arcs...
\draw[line width=0.1pt] (0,2.25) arc (90:15:0.69);
\draw[line width=0.1pt] (0,2.25) arc (90:60:2);
\draw[line width=0.1pt] (0,2.25) arc (90:70:2.85);
% Bottom cap
\draw (-0.5,1) arc (180:360:0.5 and 0.175) ;
\draw[dashed] (0.5,1) arc (0:180:0.5 and 0.175) ;
\fill (0,1.125) circle (0.5pt);
% Cone structure
\draw[dashed] (0,0) -- (0.505,1);
\draw[dashed] (0,0) -- (-0.505,1);
\draw (0.505,1) -- (1,1.97);
\draw (-0.505,1) -- (-1,1.97);
\end{tikzpicture}
\end{figure}
\end{document}
PS 如果有其他(“更酷”)的方法来做到这一点,也许使用阴影而不是线条来绘制 3D 球形盖,我很乐意看到它实现。
答案1
仅供入门。您可以执行以下操作。在等距 3D 中更容易(但需要进行一些三角计算)。如果您使用选项,Tikz 会为您绘制椭圆弧rotate around z
。只需这个和一些\foreach
命令,您就可以拥有它。
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{3d,calc}
\def\ch{3.75} % cone height
\def\cv{2} % cone visibility height
\def\ph{20} % cone angle
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\pgfmathsetmacro\cr {\ch*tan(\ph)} % cone radius
\pgfmathsetmacro\cg {\ch/cos(\ph)} % cone generatrix
\pgfmathsetmacro\crv{\cv*tan(\ph)} % cone radius (not visible part)
\pgfmathsetmacro\cgv{\cv/cos(\ph)} % cone generatrix (not visible part)
\pgfmathsetmacro\gs{sqrt((2*\ch*\ch-\cr*\cr)/(3*\cr*\cr))} % generatrix slope
\pgfmathsetmacro\xt{sqrt(6)*\gs*\ch/(1+3*\gs*\gs)} % tangent point x
\pgfmathsetmacro\yt{\gs*\xt} % tangent point y
\pgfmathsetmacro\aa{(\ch*\zz-\yt)/\xy/2-\xt/\xx/2} % coordinate x in xy plane
\pgfmathsetmacro\bb{(\ch*\zz-\yt)/\xy/2+\xt/\xx/2} % coordinate y in xy plane
\pgfmathsetmacro\at{atan(\bb/\aa)+180} % angle to the tangent point
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}]
\begin{scope}[canvas is xy plane at z=\ch]
\draw (0,0) circle (\cr);
\end{scope}
\draw ($(\at:\cr)+(0,0,\ch)$) -- ($(\at:\crv)+(0,0,\cv)$) arc (\at:90-\at:\crv) -- ($(90-\at:\cr)+(0,0,\ch)$);
\draw[dashed] (0,0,0) -- ($(\at:\crv)+(0,0,\cv)$) arc (\at:450-\at:\crv) -- cycle;
% meridians
\foreach \a in {0,30,...,179}
{%
\begin{scope}[rotate around z=\a, canvas is xz plane at y=0]
\draw[red] (0,0) ++ (90-\ph:\cg) arc (90-\ph:90+\ph:\cg);
\draw[red] (0,0) ++ (90-\ph:\cgv) arc (90-\ph:90+\ph:\cgv);
\end{scope}
}
% parallels
\foreach \i in {1,2} \foreach \j in {\cg,\cgv}
{%
\pgfmathsetmacro\a{\i*\ph/3}
\begin{scope}[canvas is xy plane at z={\j*cos(\a)}]
\draw[red] (0,0) circle ({\j*sin(\a)} );
\end{scope}
}
\end{tikzpicture}
\end{document}