在 Tikz 环境中旋转椭圆体

在 Tikz 环境中旋转椭圆体

这是我的代码的结果:结果
现在,我想让内椭圆体与 x 轴对齐,而不是像现在这样与 y 轴对齐。换句话说,我想将整个椭圆体在 xy 平面上旋转 90 度,所以我应该以某种方式引入一些前瞻性,如下所示(黑色部分是我想要放置椭圆体的位置):在此处输入图片描述
我应该如何修改我的代码?(简化的代码没有轴和线,但这并不重要)

\begin{tikzpicture}[scale = 0.3][line cap=round, line join=round]
    \draw [ball color=white,very thin,opacity=0.4] (0,0,0) circle (8) ;
    \fill[white,opacity=0.6] (0,0) circle (8 and 3);
    \shade[right color=orange,middle color=red,left color=blue,opacity=0.4,shading angle=-110] (0,0) circle (8 and 3);
    \shade[ball color=orange,opacity=0.3] (0,0) circle (8 and 3);
    \draw[line width=0.5pt,rotate around={0.:(0.,0.)},dash pattern=on 4pt off 3pt, color = violet, opacity = 0.6] (0,0) ellipse (1 and 3);
\end{tikzpicture}

答案1

你正在使用 2D 工具创建 3D 图形,因此它永远不会完美。这里我只是猜测了一些数字。

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[very thick]
\shadedraw[ball color=white, fill opacity=0.8] (0,0,0) circle[radius=8];
\shadedraw[ball color=white, fill opacity=0.8, shading angle=-45, rotate=45] (0,0,0) ellipse[x radius=4.3, y radius=3];
\shadedraw[left color=blue, right color=orange, fill opacity=0.4, shading angle=-45, rotate=45] (0,0,0) ellipse[x radius=4.3, y radius=3];
\draw[dashed, rotate=45] (0,0,0) ellipse[x radius=4.3/3, y radius=3];
\draw[-Latex]  (0,0,0) -- (8,0,0);
\draw[-Latex]  (0,0,0) -- (0,8,0);
\draw[-Latex]  (0,0,0) -- (0,0,8);
\end{tikzpicture}
\end{document}

阴影球和椭圆体

答案2

我认为使用 Asymptote 的 3D 图形有更好的代码,但目前,这里有一个解决方案。是围绕 x 轴rotate(45,X)旋转的度数。45O--X

在此处输入图片描述

// Run on http://asymptote.ualberta.ca/
// code modified from https://sourceforge.net/p/asymptote/discussion/409349/thread/c0185797a0/
import graph3;
import smoothcontour3;
unitsize(1cm);
currentprojection.zoom=.8;
real a=2.5, b=3, c=1;
real f(real x, real y, real z) {return x^2/a^2+y^2/b^2+z^2/c^2-1;}
draw(rotate(45,X)*implicitsurface(f,(-a,-b,-c),(a,b,c),maxdepth=7),pink+opacity(.5));
draw(scale3(b)*unitsphere,yellow+opacity(.2));

xlimits(-a,b+1);
ylimits(-b,b+1);
zlimits(-c,b+1);
axes3("$x$","$y$","$z$",Arrow3);

我正在尝试以下更简单的代码,但无法调试它。

unitsize(3cm);
import graph3;
transform3 t=rotate(45,X)*scale(0.8,1,0.5);
draw(t*unitsphere,purple+opacity(.3));
draw(unitsphere,yellow+opacity(.2));

axes3("$x$","$y$","$z$",Arrow3);  

答案3

像这样?

在此处输入图片描述

使用您的简化代码:

\documentclass[tikz, border=2mm]{standalone}

\begin{document}
    \begin{tikzpicture}[scale = 0.3][line cap=round, line join=round]
        \draw [ball color=white,very thin,opacity=0.4] (0,0,0) circle (8) ;
        \node [right] at (8,0) {$y$};
        \node [above] at (0,8) {$z$};
        \node [above] at (-2.2,-4) {$x$};
        %\draw[line width=0.5pt,rotate around={0.:(0.,0.)},dash pattern=on 7pt off 8pt] (0,0) ellipse (8 and 2);
        \draw[line width=1pt,-latex]  (0,0) -- (0,8);
        \draw[line width=1pt,-latex]  (0,0) -- (-2,-3);
        \draw[line width=1pt,-latex]  (0,0) -- (8,0);
        \fill[white,opacity=0.6] (0,0) circle (8 and 3);
        \shade[right color=orange,middle color=red,left color=blue,opacity=0.4,shading angle=-110] (0,0) circle (8 and 3);
        \shade[ball color=orange,opacity=0.3] (0,0) circle (8 and 3);
    %   \draw[line width=0.5pt,rotate around={0.:(90.,0.)},dash pattern=on 4pt off 3pt, color = violet, opacity = 0.6] (0,0) ellipse (1 and 3);
    \end{tikzpicture}

    
\end{document}

相关内容