绘制椭圆轮廓

绘制椭圆轮廓

我正在尝试绘制一个椭圆体和一个立方体。以下是我所做的。 在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
    \tdplotsetmaincoords{75}{30}
    \begin{center}
        \begin{tikzpicture}[scale=3.5, tdplot_main_coords]

            \begin{scope}[canvas is zx plane at y=0]
                \draw[line width=0.3mm, black] (0,0) ellipse (1cm and 2cm); 
            \end{scope}
            
            
            \begin{scope}[scale=0.35]
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,-0.5,-0.5) -- (0.5,0.5,-0.5) -- (-0.5,0.5,-0.5) -- (-0.5,-0.5,-0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,0.5,-0.5) -- (-0.5,0.5,-0.5) -- (-0.5,0.5,0.5) -- (0.5,0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,-0.5,-0.5) -- (0.5,0.5,-0.5) -- (0.5,0.5,0.5) -- (0.5,-0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (-0.5,0.5,-0.5) -- (-0.5,-0.5,-0.5) -- (-0.5,-0.5,0.5) -- (-0.5,0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (-0.5,-0.5,-0.5) -- (0.5,-0.5,-0.5) -- (0.5,-0.5,0.5) -- (-0.5,-0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,0.5,0.5) -- (-0.5,0.5,0.5) -- (-0.5,-0.5,0.5) -- (0.5,-0.5,0.5) -- cycle; 
            \end{scope}
            
            \begin{scope}[canvas is xy plane at z=0]
                \draw[line width=0.3mm, black] (0,0) ellipse (2cm and 1cm);
                \draw[line width=0.15mm, black, dashed] (-2,0) -- (-0.28,0);
                \draw[line width=0.15mm, black, dashed] (0.175,0) -- (2,0);
            \end{scope}
            
            \begin{scope}[canvas is zy plane at x=0]
                \draw[line width=0.3mm, black] (0,0) circle (1cm);
                \draw[line width=0.15mm, black, dashed] (-1,0) -- (-0.28,0);
                \draw[line width=0.15mm, black, dashed] (0.175,0) -- (1,0);
                \draw[line width=0.15mm, black, dashed] (0,-1) -- (0,-0.175);
                \draw[line width=0.15mm, black, dashed] (0,0.55) -- (0,1);
            \end{scope}
        
        \end{tikzpicture}
    \end{center}
\end{document}

我对结果几乎满意,但我想绘制椭圆体的轮廓(如下所示) 在此处输入图片描述

我该怎么做?

答案1

这是一个使用 Asymptote 的简单解决方案,仅使用了通常的几何变换。

https://www.overleaf.com/read/kcbdgdktrgrt

在此处输入图片描述

// Run on http://asymptote.ualberta.ca/
unitsize(1cm);
import three;
currentprojection=orthographic(3,3.5,1.4,zoom=.8);
pen p1=blue, p2=red;
pen p3=purple+opacity(.5);
pen p4=yellow+opacity(.3);
real a=1.5,b=3.5,c=2;
draw(scale(a,b,c)*unitsphere,p4);
draw(scale(a,b,1)*unitcircle3,p2);
draw(scale(a,1,c)*rotate(90,X)*unitcircle3,p2);
draw(scale(1,b,c)*rotate(90,Y)*unitcircle3,p2);

draw('$a$',align=N,O--a*X,p1);
draw('$b$',align=N,O--b*Y,p1);
draw('$c$',align=E,O--c*Z,p1);

draw(scale3(.5)*unitcube,p3);

答案2

好的,这是一个硬编码的解决方案:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}

\begin{document}
    \tdplotsetmaincoords{75}{30}
    \begin{center}
        \begin{tikzpicture}[scale=3.5, tdplot_main_coords]

            \begin{scope}[canvas is zx plane at y=0]
                \draw[line width=0.3mm, black] (0,0) ellipse (1cm and 2cm); 
            \end{scope}
            
            
            \begin{scope}[scale=0.35]
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,-0.5,-0.5) -- (0.5,0.5,-0.5) -- (-0.5,0.5,-0.5) -- (-0.5,-0.5,-0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,0.5,-0.5) -- (-0.5,0.5,-0.5) -- (-0.5,0.5,0.5) -- (0.5,0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,-0.5,-0.5) -- (0.5,0.5,-0.5) -- (0.5,0.5,0.5) -- (0.5,-0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (-0.5,0.5,-0.5) -- (-0.5,-0.5,-0.5) -- (-0.5,-0.5,0.5) -- (-0.5,0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (-0.5,-0.5,-0.5) -- (0.5,-0.5,-0.5) -- (0.5,-0.5,0.5) -- (-0.5,-0.5,0.5) -- cycle; 
                \draw[line width=0.15mm, black, fill=violet, line join=round] (0.5,0.5,0.5) -- (-0.5,0.5,0.5) -- (-0.5,-0.5,0.5) -- (0.5,-0.5,0.5) -- cycle; 
            \end{scope}
            
            \begin{scope}[canvas is xy plane at z=0]
                \draw[line width=0.3mm, black] (0,0) ellipse (2cm and 1cm);
                \draw[line width=0.15mm, black, dashed] (-2,0) -- (-0.28,0);
                \draw[line width=0.15mm, black, dashed] (0.175,0) -- (2,0);
            \end{scope}
            
            \begin{scope}[canvas is zy plane at x=0]
                \draw[line width=0.3mm, black] (0,0) circle (1cm);
                \draw[line width=0.15mm, black, dashed] (-1,0) -- (-0.28,0);
                \draw[line width=0.15mm, black, dashed] (0.175,0) -- (1,0);
                \draw[line width=0.15mm, black, dashed] (0,-1) -- (0,-0.175);
                \draw[line width=0.15mm, black, dashed] (0,0.55) -- (0,1);
            \end{scope}
            
%new part
            \begin{scope}[canvas is xz plane at y=0]
                \draw[line width=0.7mm, black, rotate=4] (0,0) ellipse (2.1cm and 1.053cm);
            \end{scope}
        
        \end{tikzpicture}
    \end{center}
\end{document}

在此处输入图片描述

如果您有更好的方法 - 请发布!

相关内容