TikZ绘图示例——尺规作图:直角的画法(一)
原创
©著作权归作者所有:来自51CTO博客作者zorch的原创作品,请联系作者获取转载授权,否则将追究法律责任
方法
- 作任意水平直线;
- 作任意斜线与水平直线相交于点;
- 在斜线上任取一点;
- 以为圆心,为半径作圆弧分别与水平直线和斜线交于点, 连接,即为直角.
图形
代码
\documentclass[tikz,border=3pt]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{intersections,through}
\begin{document}
\begin{tikzpicture}[]
% 标记两点, 做直线
\coordinate (M) at (-.5,0);
\coordinate (N) at (2.5,0);
\draw [name path=l] (M) -- (N);
% 标记圆心并画圆
\coordinate [label=$O$] (O) at (1,1);
\fill (O) circle(1pt);
\coordinate (P) at ($(O)+(1.25,0)$);
% 圆被标记为o
\draw (O) circle (1.25);
\coordinate [name path=o,circle through=(P)] (o) at (O);
% 找交点并标记A,B
\path [name intersections={of=l and o}]
coordinate [label=below:$A$] (A) at (intersection-1)
coordinate [label=below:$B$] (B) at (intersection-2);
% 绘制斜线
\draw [name path=l2] ($(B)!-.15!(O)$) -- ($(B)!2.25!(O)$);
% 标记C点: 圆与斜线的交点
\path [name intersections={of=l2 and o}]
coordinate [label=left:$C$] (C) at (intersection-1);
% 连接CA
\draw ($(C)!-.1!(A)$) -- ($(C)!1.1!(A)$);
% 标记直角
\draw (A) rectangle ($(A)+(.1,.1)$);
\end{tikzpicture}
\end{document}