如何计算并绘制圆与射线的交点

如何计算并绘制圆与射线的交点

我已经实现了绘制这个单位圆。但我想改进代码,因为圆和射线之间的交点是用命令绘制的\closeddot{3.875}{0.985};。我需要帮助来改进它并使其“自动化”并且更加准确。

这是我的MWE

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\newcommand{\opendot}[2]{\filldraw [fill=white,draw=black, thick] ({#1},{#2}) circle (.05) ;}
\newcommand{\closeddot}[2]{\filldraw [fill=black,draw=black, thick] ({#1},{#2}) circle (.05) ;}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            axis lines=middle,
            axis equal image,
            enlargelimits,
            xtick=\empty, ytick=\empty,
            data cs=polar,
            samples=100,
            thick
        ]
            \addplot [thick, black, smooth, domain=0:360] {0.8};
            \addplot [thick, blue, -latex, smooth, domain=0:300] {0.3+x/2000} node [pos=0.35, anchor= south] {$\beta$};
        \addplot [thick, black,-latex] coordinates {(0,0) (300,1)};
    \end{axis}
\draw (4.875,0.875) node  {$\left(\frac{1}{2},-\frac{\sqrt{3}}{2}\right)$};
\closeddot{3.875}{0.985};
\end{tikzpicture}
\end{document}

答案1

您可以使用intersectionsTikZ 中的库:

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{intersections}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
      axis lines=middle,
      axis equal image,
      enlargelimits,
      xtick=\empty, ytick=\empty,
      data cs=polar,
      samples=100,
      thick,
      clip=false
  ]

  \addplot [name path=circle,thick, black, smooth, domain=0:360] {0.8};
  \addplot [thick, blue, -latex, smooth, domain=0:300] {0.3+x/2000} node [pos=0.35, anchor= south] {$\beta$};
  \addplot [name path=ray,thick, black,-latex] coordinates {(0,0) (300,1)};
  \path[name intersections={of=ray and circle,by={a}}];   
  \filldraw (a) circle [radius=2pt] ;
  \node[right=6pt,yshift=-2pt] at (a) {$\left(\frac{1}{2},-\frac{\sqrt{3}}{2}\right)$};
  \end{axis}

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容