tikz 标注直线与圆的交点

14 篇文章 2 订阅
12 篇文章 0 订阅
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=10]

%画坐标系,标刻度
\draw[->](-1,0)--(1,0) node[right,scale=2]{};
\draw[->](0,-1)--(0,1) node[above,scale=2]{};

\foreach \i/\texti in{-1,-0.5,...,1}
\draw (\i,0)--(\i,0.01) node[below=3pt]{\texti};

\foreach \i/\texti in{-1,-0.5,...,1}
\draw (0,\i)--(0.01,\i) node[right=3pt]{\texti};

%画圆,等分
\draw (0,0) circle(1);
\foreach \i in{22.5,45,...,360}
\draw [gray, fill opacity=0.2] (0:0)--(\i:1);

\foreach \i/\texti in{-22.5,0,...,112.5}
\draw [name path = line \i, green, line width = 1pt, fill opacity=0.2] (0:0)--(\i:1) node [black, fill opacity=1, right=2pt] {$s_{\texti}$};

%定义一个点A,画一条线段OA
\coordinate  (O) at (0,0);
\coordinate [black,fill opacity=1, label=right:$A$] (A) at (40:1);  
\draw [red, line width=4pt] (40:1) circle(0.02); %点
\draw [red, fill opacity=0.2] (O)--(A) ;

%以OA为直径画圆
\draw [name path = cir_0, dashed] (40:0.5) circle(0.5);
\path [name path = OA] (0:0) --(40:1);

%圆与各条线段的交点
\path [name intersections = {of = cir_0 and line -22.5,  by = d1}]; 
\coordinate [label=above:$I_{1}$] (d1) at (intersection-2);  %定义交点

\path [name intersections = {of = cir_0 and line 0,        by = d2}]; 
\coordinate [label=above:$I_{2}$] (d2) at (intersection-2);  %定义交点

\path [name intersections = {of = cir_0 and line 22.5,   by = d3}]; 
\coordinate [label=above:$I_{3}$] (d3) at (intersection-1);  %定义交点

\path [name intersections = {of = cir_0 and line 45,      by = d4}]; 
\coordinate [label=above:$I_{4}$] (d4) at (intersection-1);  %定义交点

\path [name intersections = {of = cir_0 and line 67.5,   by = d5}]; 
\coordinate [label=above:$I_{5}$] (d5) at (intersection-1);  %定义交点

\path [name intersections = {of = cir_0 and line 90,      by = d6}]; 
\coordinate [label=above:$I_{6}$] (d6) at (intersection-1);  %定义交点

\path [name intersections = {of = cir_0 and line 112.5, by = d7}]; 
\coordinate [label=above:$I_{7}$] (d7) at (intersection-2);  %定义交点

\draw [red, line width=3pt] (d1) circle (0.005); %画交点
\draw [red, line width=3pt] (d2) circle (0.005); %画交点
\draw [red, line width=3pt] (d3) circle (0.005); %画交点
\draw [red, line width=3pt] (d4) circle (0.005); %画交点
\draw [red, line width=3pt] (d5) circle (0.005); %画交点
\draw [red, line width=3pt] (d6) circle (0.005); %画交点
\draw [red, line width=3pt] (d7) circle (0.005); %画交点

\draw [dashed, green, line width=1pt] (A)--(d1);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d2);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d3);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d4);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d5);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d6);  %画直角边
\draw [dashed, green, line width=1pt] (A)--(d7);  %画直角边

%可行解
\draw [blue,dashed] 
        let 
            \p1=($(d1)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1);
                     
\draw [blue,dashed] 
        let 
            \p1=($(d2)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1);
            
\draw [blue,dashed] 
        let 
            \p1=($(d3)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1); 
            
 \draw [blue,dashed] 
        let 
            \p1=($(d4)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1);  

\draw [blue,dashed] 
        let 
            \p1=($(d5)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1);   
            
\draw [blue,dashed] 
        let 
            \p1=($(d6)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1); 
            
\draw [blue,dashed] 
        let 
            \p1=($(d7)-(O)$),
            \n1={veclen(\x1,\y1)}
        in 
            (O) circle (\n1);                                                  \end{tikzpicture}
\end{document}

编译结果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值