我看到为球体添加角度画一个 3D 圆锥体。我试过
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{sansmath}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,backgrounds,quotes,angles,calc,patterns}
\begin{document}
\tdplotsetmaincoords{80}{0}
\begin{tikzpicture}[tdplot_main_coords]
\pgfmathsetmacro{\R}{4} % radius
\pgfmathsetmacro{\myang}{150} % latitude angle of the red circle
\coordinate (O) at (0,0,0);
\begin{scope}[canvas is xy plane at z={-\R*sin(\myang)},transform shape]
% \angVis from https://tex.stackexchange.com/a/49589/121799
\pgfmathsetmacro\angVis{atan(sin(\myang)*cos(\tdplotmaintheta)/sin(\tdplotmaintheta))}
\begin{scope}[on background layer]
\draw[] (\angVis:{\R*cos(\myang)}) arc (\angVis:180-\angVis:{\R*cos(\myang)});
\end{scope}
\draw[dashed] (180-\angVis:{\R*cos(\myang)}) arc (180-\angVis:360+\angVis:{\R*cos(\myang)});
\path (0:{\R*cos(\myang)}) coordinate (R)
(180:{\R*cos(\myang)}) coordinate (L);
\end{scope}
\begin{scope}[on background layer]
\coordinate (H) at ($ (L)!0.5!(R) $);
\draw[] (L) -- (O) (R) -- (O) ;
\draw[dashed] (H) -- (O) (L) -- (R);
\end{scope}
\fill (O) circle[radius=1pt] node[above] {$O$};
\fill (L) circle[radius=1pt] node[above] {$L$};
\fill (R) circle[radius=1pt] node[above] {$R$};
\end{tikzpicture}
\end{document}
我有:
我感觉边缘OR
不太OL
好看。我该如何修复?
答案1
你的圆锥体有和R= 4
,\myang = 150
那么圆锥体的高度等于r*sin(\myang) = 2
。我在这里使用了这个问题的代码
我怎样才能准确地画出这个圆锥体?
画出你的圆锥体
\documentclass[border=2mm,tikz]{standalone}
\usepackage{fouriernc}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,backgrounds}
\usepackage{tkz-euclide,amsmath}
\usetkzobj{all}
\usepackage{pgfplots}
\begin{document}
%polar coordinates of visibility
\pgfmathsetmacro\th{65}
\pgfmathsetmacro\az{110}
\tdplotsetmaincoords{\th}{\az}
%parameters of the cone
\pgfmathsetmacro\R{4} %radius of base
\pgfmathsetmacro\v{2} %hight of cone
\begin{tikzpicture} [scale=1, tdplot_main_coords, axis/.style={blue,thick}]
\path
coordinate (O) at (0,0,0)
coordinate (A) at ($(O) + (-70:{\R} and {\R})$)
coordinate (B) at ($ (O) - (A) $)
coordinate (S) at (0,0,\v)
;
\foreach \v/\position in { B/right,O/below,A/left,S/above} {\draw[draw =black, fill=black] (\v) circle (1pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (S) -- (A) (S) -- (B);
\draw[dashed] (A) -- (B) (S)--(O) ;
\pgfmathsetmacro\cott{{cot(\th)}}
\pgfmathsetmacro\fraction{\R*\cott/\v}
\pgfmathsetmacro\fraction{\fraction<1 ? \fraction : 1}
\pgfmathsetmacro\angle{{acos(\fraction)}}
% % angles for transformed lines
\pgfmathsetmacro\PhiOne{180+(\az-90)+\angle}
\pgfmathsetmacro\PhiTwo{180+(\az-90)-\angle}
% % coordinates for transformed surface lines
\pgfmathsetmacro\sinPhiOne{{sin(\PhiOne)}}
\pgfmathsetmacro\cosPhiOne{{cos(\PhiOne)}}
\pgfmathsetmacro\sinPhiTwo{{sin(\PhiTwo)}}
\pgfmathsetmacro\cosPhiTwo{{cos(\PhiTwo)}}
% % angles for original surface lines
\pgfmathsetmacro\sinazp{{sin(\az-90)}}
\pgfmathsetmacro\cosazp{{cos(\az-90)}}
\pgfmathsetmacro\sinazm{{sin(90-\az)}}
\pgfmathsetmacro\cosazm{{cos(90-\az)}}
% % draw basis circle
\tdplotdrawarc[tdplot_main_coords,thick]{(O)}{\R}{\PhiOne}{360+\PhiTwo}{anchor=north}{}
\tdplotdrawarc[tdplot_main_coords,dashed,thick]{(O)}{\R}{\PhiTwo}{\PhiOne}{anchor=north}{}
% % displaying tranformed surface of the cone (rotated)
\draw[thick] (0,0,\v) -- (\R*\cosPhiOne,\R*\sinPhiOne,0);
\draw[thick] (0,0,\v) -- (\R*\cosPhiTwo,\R*\sinPhiTwo,0);
\end{tikzpicture}
\end{document}
根据薛定谔的猫的答案 在 Latex 中绘制与平面相交的圆锥体您可以使用
\documentclass[tikz,border=1mm,12pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords,declare function={h=2;R=4;},
hidden/.style={dashed}]
\pgfmathsetmacro{\alphacrit}{90-acos(R*cos(\tdplotmaintheta)/h)}
\pgfmathsetmacro{\AngleOne}{\tdplotmainphi+180-\alphacrit)}
\pgfmathsetmacro{\AngleTwo}{\tdplotmainphi+360+\alphacrit}
\path
({R*cos(\AngleOne)},{R*sin(\AngleOne)} ) coordinate (bl)
({R*cos(\AngleTwo)},{R*sin(\AngleTwo)} ) coordinate (br)
(0,0,0) coordinate (O)
(0,0,h) coordinate (S)
({R*cos(-70)}, {R*sin(-70)},0) coordinate (A)
({R*cos(110)}, {R*sin(110)},0) coordinate (B)
;
\begin{scope}[canvas is xy plane at z=0]
\draw[hidden] (bl) arc[start angle=\AngleOne,
end angle=\tdplotmainphi+\alphacrit,radius=R];
\draw (bl) arc[start angle=\AngleOne,
end angle=\AngleTwo,radius=R];
\end{scope}
\draw (S) -- (bl) (S) -- (br) ;
\draw[dashed] (S) -- (O) (A) -- (B);
\foreach \p in {S,A,O,B}
\draw[fill=black] (\p) circle (1.5 pt);
\foreach \p/\g in {S/90,A/180,O/-90,B/0}
\path (\p)+(\g:3mm) node{$\p$};
\end{tikzpicture}
\end{document}