我怎样才能准确地画出这个圆锥体?

我怎样才能准确地画出这个圆锥体?

我想画这个圆锥体,在此处输入图片描述 其中 SO = a,OA = 2a,AB=2a*sqrt(3)。这是我在 Geospacw 中绘制的图片。

经过一些计算,我们得到AOB=120 degreesH是线段的中点SM

这是我的代码

\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{60}
\pgfmathsetmacro\az{110}
\tdplotsetmaincoords{\th}{\az}
%parameters of the cone
\pgfmathsetmacro\R{3} %radius of base
\pgfmathsetmacro\v{1.8} %hight of cone
\begin{tikzpicture} [scale=1.5, tdplot_main_coords, axis/.style={blue,thick}]
\path
coordinate (O) at (0,0,0)
coordinate (B) at (0,\R,0)
coordinate (A) at ($(O) + (-30:{\R} and {\R})$)
%coordinate (A) at (\R/2,0.8660254038*\R,0)
coordinate (S) at (0,0,\v)
coordinate (C) at  ($(O)-(A)$)
coordinate (M) at ($(A)!.5!(B)$)
coordinate (H) at ($(M)!1/2!(S)$)
;

\foreach \v/\position in { B/below,O/left,A/below,S/above,M/below,H/right} {\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)  (O)--(A) (O) -- (M) (S) -- (M) (O)--(B) (O)--(H);
%\tkzMarkRightAngle[size = 0.15](S,O,A)
%\tkzMarkRightAngle[size = 0.15](S,M,A)
%\tkzMarkRightAngle[size = 0.15](O,M,B)
%\tkzMarkRightAngle[size = 0.15](O,H,M)


\tkzMarkSegment[color=black,pos=0.5,mark=||](A,M)
\tkzMarkSegment[color=black,pos=0.5,mark=||](B,M)

%\draw [fill opacity=0.4,fill=green!80!blue] (S) -- (A) -- (C) -- cycle;
% % computation of tangential points
\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);

% % displaying original surface of the cone (rotated)

\end{tikzpicture}

\end{document}

在此处输入图片描述 我的问题是:如何放置OA = 2 OS\R = 2\v

答案1

根据 JohnKormylo 的评论和使用\pgfmathsetmacro\th{70},我解决了我的问题。

\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{70}
\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 (B) at (0,\R,0)
coordinate (A) at ($(O) + (-30:{\R} and {\R})$)
%coordinate (A) at (\R/2,0.8660254038*\R,0)
coordinate (S) at (0,0,\v)
coordinate (C) at  ($(O)-(A)$)
coordinate (M) at ($(A)!.5!(B)$)
coordinate (H) at ($(M)!1/2!(S)$)
;
\foreach \v/\position in { B/below,O/left,A/below,S/above,M/below,H/right} {\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)  (O)--(A) (O) -- (M) (S) -- (M) (O)--(B) (O)--(H);
\tkzMarkSegment[color=black,pos=0.5,mark=||](A,M)
\tkzMarkSegment[color=black,pos=0.5,mark=||](B,M)

%\draw [fill opacity=0.4,fill=green!80!blue] (S) -- (A) -- (C) -- cycle;
% % computation of tangential points
\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);

% % displaying original surface of the cone (rotated)
    \end{tikzpicture}
    \end{document}

在此处输入图片描述

答案2

以下是元帖子,展示了一种寻找椭圆切点的方法,遵循传统建筑而不是用三角函数计算。与普通 MP 一样,这是“假 3D”,而不是真正的三维绘图。

在此处输入图片描述

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}

% find one focus of an ellipse E:
% the intersection of (a circle with diameter = major axis shifted to the "top" of
% the ellipse) and (the major axis)

vardef focus(expr E) = 
    fullcircle scaled abs(point 0 of E-point 4 of E) shifted point 2 of E
    intersectionpoint
    (point 0 of E -- point 4 of E)
enddef;

% find the "time" round an ellipse E of the first tangent point
% to the external point P.  Will fail if P is inside E.
% See http://wiki.dtonline.org/index.php/Tangents_and_Normals for details.

vardef tangent_time(expr E, P) = 
    save f;
    pair f, f';
    f = focus(E);
    f' = f reflectedabout(point 2 of E, point 6 of E);
    xpart (E intersectiontimes (f' -- 
    (fullcircle scaled 2 abs(P-f) shifted P intersectionpoint
    fullcircle scaled 2 abs(point 4 of E - point 0 of E) shifted f')))
enddef;

% decorate a path P with N slightly oblique marks at point R of P

vardef mark_along(expr P, R, N) = 
    for i=1 upto N:
        draw (down--up) scaled 3 rotated -5 shifted (i-N/2,0) 
                        rotated angle direction R of P shifted point R of P;
    endfor
enddef;

beginfig(1);

    % an ellipse
    path base;
    base = fullcircle xscaled 233 yscaled 144;

    % some pairs 
    pair A, B, S, O, M, H;
    O = origin;
    A = point 5.1 of base;
    B = point 7.9 of base;
    S = 144 up;
    M = 1/2[A,B];
    H = 1/2[S,M];

    % the two tangent "times" along base
    numeric t, u;
    t = tangent_time(base, S);
    u = 4-t;

    % draw some dashed lines
    drawoptions(dashed evenly scaled 1/2);
    draw subpath (t,u) of base withcolor 1/2 white;
    draw A--O--B--cycle;
    draw S--O--M--cycle;
    draw O--H;

    % mark equality 
    drawoptions(withcolor 2/3 red);
    mark_along(A--M, 1/2, 2);
    mark_along(M--B, 1/2, 2);

    % draw some solid lines
    drawoptions();
    draw S -- subpath (u,8+t) of base -- cycle;
    draw A--S--B;

    % label the points
    dotlabel.ulft("O", O);
    dotlabel.llft("A", A);
    dotlabel.lrt ("B", B);
    dotlabel.lrt ("M", M);
    dotlabel.urt ("H", H);
    dotlabel.top ("S", S);

endfig;
\end{mplibcode}
\end{document}

这是包含在内luamplib以便编译lualatex,或者适应普通 MP 等。

笔记

  • 这些建筑来自这个有用的网站

  • 这里的椭圆周围有 8 个点,因为我从 继承了它们fullcircle

  • 在 MP 中制作椭圆的正常方法是使用路径fullcircle,并使用 将其拉伸至长轴,使用xscaled将其拉伸至短轴yscaled

  • focus函数假定您已像这样排列椭圆,以便长轴从点 0 延伸到点 4,短轴从点 2 延伸到点 6。

  • focus函数仅返回其中一个焦点。另一个焦点将关于短轴对称。

  • tangent_time函数返回沿椭圆路径的第一切点到外部点的时间。另一条切线将关于从椭圆中心到外部点的线对称。这里我知道外部点就在正上方,所以我可以作弊并用 得到第二个点u=4-t

  • 注意两个不同的 MP 命令intersectionpointintersectiontimes手册对它们进行更多的解释。

相关内容