如何在三维空间中绘制一个圆,使得包含该圆的平面与给定向量正交?

如何在三维空间中绘制一个圆,使得包含该圆的平面与给定向量正交?

如何在三维空间中绘制一个圆,使得包含该圆的平面与给定向量正交?

答案1

您可以计算矢量球坐标,然后使用 Ti 旋转画布Z3d库。我制作了一个简单的宏来展示这个想法,但您可以根据需要添加更多参数(中心、半径、颜色等)或制作一个pic

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{3d,perspective}

\newcommand{\mycircle}[3] % vector x, y, z
{%
  \pgfmathsetmacro\vtheta{atan2(#2,#1)}                     % spherical coordinate theta
  \pgfmathsetmacro\vphi  {acos(#3/sqrt(#1*#1+#2*#2+#3*#3))} % spherical coordinate phi
  \begin{scope}[rotate around z=\vtheta,rotate around y=\vphi,canvas is xy plane at z=0]
    \draw (-0.5,-0.5) rectangle (0.5,0.5);
    \draw[fill=gray,fill opacity=0.2] (0,0) circle (0.5);   % the plane, probably not needed
  \end{scope}
}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,scale=2,3d view={120}{30}]
\draw[-latex] (0,0,0) -- (1,0,0);
\draw[-latex] (0,0,0) -- (0,1,0);
\draw[-latex] (0,0,0) -- (0,0,1);
\def\vx{0.3}
\def\vy{0.6}
\def\vz{0.9}
\mycircle{\vx}{\vy}{\vz}
\draw[-latex,red] (0,0,0) -- (\vx,\vy,\vz);
\end{tikzpicture}
\end{document}

在此处输入图片描述

为了提供更直观的示例,这是一个使用相同宏的动画。

\documentclass {beamer}
\usepackage    {tikz}
\usetikzlibrary{3d,perspective}

\setbeamertemplate {navigation symbols}{}

\newcommand{\mycircle}[3] % vector x, y, z
{%
  \pgfmathsetmacro\vtheta{atan2(#2,#1)}                     % spherical coordinate theta
  \pgfmathsetmacro\vphi  {acos(#3/sqrt(#1*#1+#2*#2+#3*#3))} % spherical coordinate phi
  \begin{scope}[overlay,rotate around z=\vtheta,rotate around y=\vphi,canvas is xy plane at z=0]
    \draw (-0.5,-0.5) rectangle (0.5,0.5);
    \draw[fill=gray,fill opacity=0.2] (0,0) circle (0.5);
  \end{scope}
}

\newcommand{\myframe}[3]
{
\begin{frame}\centering
\begin{tikzpicture}[line cap=round,line join=round,thick,scale=6,3d view={120}{30}]
\draw[-latex] (0,0,0) -- (1,0,0);
\draw[-latex] (0,0,0) -- (0,1,0);
\draw[-latex] (0,0,0) -- (0,0,1);
\mycircle{#1}{#2}{#3}
\draw[-latex,red] (0,0,0) -- (#1,#2,#3);
\end{tikzpicture}
\end{frame}
}

\begin{document}
\foreach\i in {0,10,...,80}
{
\pgfmathsetmacro\vx{0.5*cos(\i)}
\pgfmathsetmacro\vy{0.5*sin(\i)}
\pgfmathsetmacro\vz{0}
\myframe{\vx}{\vy}{\vz}
}

\foreach\i in {0,10,...,80}
{
\pgfmathsetmacro\vx{0}
\pgfmathsetmacro\vy{0.5*cos(\i)}
\pgfmathsetmacro\vz{0.5*sin(\i)}
\myframe{\vx}{\vy}{\vz}
}

\foreach\i in {0,10,...,80}
{
\pgfmathsetmacro\vx{0.5*sin(\i)}
\pgfmathsetmacro\vy{0}
\pgfmathsetmacro\vz{0.5*cos(\i)}
\myframe{\vx}{\vy}{\vz}
}
\end{document}

在此处输入图片描述

答案2

正如您所说,有无限个圆。在 3D 中,圆由平面和球体定义。在此代码中,假设您要绘制一个圆,其圆心为(a, b, c),半径为rcircle,包含圆的平面的法向量为(a,b,c)。圆位于球体上(a, b, c),球体半径为rsphere=sqrt(a*a+b*b+c*c+rcircle*rcircle)。您可以使用3d工具

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=70,theta=70},line cap=butt,line join=round,declare function={a=2;b=2;c=1;rcircle=4;rsphere=sqrt(a*a+b*b+c*c+rcircle*rcircle);},c/.style={circle,fill,inner sep=1pt}] 
    \path[overlay]
    (a,b,c) coordinate (C)
    (0,0,0)  coordinate (O);
    \draw[3d/screen coords] (O) circle[radius=rsphere]; 
    \pic[blue]{3d/circle on sphere={R=rsphere,C={(O)}, P={(C)}}};
    \path foreach \p/\g in {C/-90,O/90}
    {(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}  

在此处输入图片描述

3dtools可以画出三角形的外接圆。因此,如果你想在已知给定方程的平面上画一个圆,你可以选择三个不共线的点位于这个平面上。此代码在平面上画一个圆,其方程为2 x + 2 y - z = 7

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[    dot/.style={circle,inner sep=1pt,fill},
    3d/install view={phi=100,theta=70}] 
\path (2,2,1) coordinate (A)
    (4, -1, -1) coordinate (B)
    (6, 0, 5) coordinate (C);
    \path[draw={none}] pic{3d circle through 3 points={%
            A={(A)},B={(B)},C={(C)},center name=I}};
    \foreach \p in {A,B,C,I}
    \draw[fill=black] (\p) circle (1pt);
    \foreach \p/\g in {A/-90,B/-90,I/0,C/90}
    \path (\p)+(\g:3mm) node{$\p$};
\end{tikzpicture}
\end{document}  

在此处输入图片描述

答案3

渐近线,内置例程

circle(C,r,n)

C给出具有中心、半径r和法线的三维圆n

在此处输入图片描述

// Run on http://asymptote.ualberta.ca/
// Use mouse to rotate
unitsize(1cm);                              // choose the unit is cm
import three;                               // loading 3D
triple C=(-1,2,2);                          // center of the circle
real   r=2;                                 // radius of the circle 
triple n=(1,2,3);                           // normal of the circle
path3  p=circle(C,r,n);                     // the circle is a 3D path
draw(surface(p),red+opacity(.2));           // filling inside the circle
draw(p,red);                                // draw the circle

draw("$\vec{n}$",align=E,C--C+n,Arrow3);    // showing the normal
dot("$C$",C,red);                           // showing the center
draw(Label("$x$",EndPoint),O--3X);          // the x-axis
draw(Label("$y$",EndPoint),O--5Y);          // the y-axis
draw(Label("$z$",EndPoint),O--5Z);          // the z-axis 

答案4

我想在三维空间中画一个与矢量垂直的圆。它必须简单。例如,矢量的长度可以是半径 R。

所以...指定圆心(x0,y0,z0),单位向量n,并用R缩放它。

pgfplot 可以做到这一点吗?

相关内容