1. 计算得出的角度BOC为250度,如何修正...
2. 有没有更好的方法来画切四边形
\documentclass[border=2pt]{standalone}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}
\usepackage{tikz-dimline}
\usepackage{tkz-euclide}
\usetkzobj{all}
\definecolor{fondpaille}{cmyk}{0,0,0.1,0}
\pagecolor{fondpaille}
\color{Maroon}
\begin{document}
\begin{tikzpicture}[scale=1.0]
\tkzInit
\pgfmathsetmacro{\Radius}{2}
\tkzDefPoint(0,0){O}
\tkzDefPoint(20:\Radius){A}
\tkzDefPoint(100:\Radius){B}
\tkzDefPoint(-150:\Radius){C}
\tkzDefPoint(-70:\Radius){D}
\tkzDrawSegments[dashed](O,A O,B O,C O,D)
\tkzDrawCircle(O,A)
\tkzTangent[at=A](O) \tkzGetPoint{h}
\tkzTangent[at=B](O) \tkzGetPoint{i}
\tkzTangent[at=C](O) \tkzGetPoint{j}
\tkzTangent[at=D](O) \tkzGetPoint{k}
\tkzInterLL(A,h)(B,i) \tkzGetPoint{R}
\tkzInterLL(A,h)(D,k) \tkzGetPoint{Q}
\tkzInterLL(C,j)(B,i) \tkzGetPoint{S}
\tkzInterLL(C,j)(D,k) \tkzGetPoint{P}
\tkzDrawSegments[thick,brown](P,Q Q,R R,S S,P)
\tkzDrawPoints[color=red,size=3mm,fill=red!60](P,Q,R,S)
\tkzLabelPoints[below](O,P,Q,R,S)
\tkzLabelPoints[below](A,B,C,D)
\tkzFindAngle(C,O,D)
\tkzGetAngle{angleCOD};
\FPround\angleCOD\angleCOD{0}
\tkzMarkAngle[size=.5](C,O,D)
\tkzLabelAngle[pos=.7](C,O,D){\tiny $\angleCOD^\circ$}
\tkzFindAngle(D,O,A)
\tkzGetAngle{angleAOD};
\FPround\angleAOD\angleAOD{0}
\tkzMarkAngle[size=.6](D,O,A)
\tkzLabelAngle[pos=.8](D,O,A){\tiny $\angleAOD^\circ$}
\tkzFindAngle(C,O,B)
\tkzGetAngle{angleBOC};
\FPround\angleBOC\angleBOC{0}
\tkzMarkAngle[size=.8](B,O,C)
\tkzLabelAngle[pos=-0.9](C,O,B){\tiny $\angleBOC^\circ$}
\tkzFindAngle(A,O,B)
\tkzGetAngle{angleAOB};
\FPround\angleAOB\angleAOB{0}
\tkzMarkAngle[size=.7](A,O,B)
\tkzLabelAngle[pos=0.9](A,O,B){\tiny $\angleAOB^\circ$}
\end{tikzpicture}
\end{document}
答案1
只是\tkzFindAngle(B,O,C)
,\tkzFindAngle(C,O,B)
我使用的是新版本。如果您有问题,我可以在我的网站上上传测试版。
\documentclass{article}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}
\usepackage{tikz-dimline}
\usepackage{tkz-euclide}
\usetkzobj{all}
\definecolor{fondpaille}{cmyk}{0,0,0.1,0}
\pagecolor{fondpaille}
\color{Maroon}
\makeatletter
%<--------------------------------------------------------------------------–>
% thanks karu : http://tex.stackexchange.com/questions/151667/tkzgetangle-strange-behavior/196224#196224 \tkzGetAngle strange behavior
% defines \tkz@FirstAngle and \tkz@SecondAngle sens trigo
%<--------------------------------------------------------------------------–>
\def\tkzNormalizeAngle(#1,#2){%
\begingroup
\pgfmathparse{#1}\xdef\tkz@FirstAngle{\pgfmathresult}%
\pgfmathparse{#2}\xdef\tkz@SecondAngle{\pgfmathresult}%
\pgfmathgreaterthan{\tkz@FirstAngle}{0}
\ifdim\pgfmathresult pt=1 pt\relax%
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle}
\ifdim\pgfmathresult pt=1 pt\relax%
\pgfmathsubtract{\tkz@FirstAngle}{360}
\xdef\tkz@FirstAngle{\pgfmathresult}%
\fi
\else
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle}
\ifdim\pgfmathresult pt=1 pt\relax%
\pgfmathadd{\tkz@SecondAngle}{360}
\xdef\tkz@SecondAngle{\pgfmathresult}%
\fi
\fi
\endgroup
}
%<--------------------------------------------------------------------------–>
% Angle
%<--------------------------------------------------------------------------–>
\def\tkzFindSlopeAngle(#1,#2){%
\begingroup
\tkzmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\global\let\tkzAngleResult\pgfmathresult
\endgroup
}
%<--------------------------------------------------------------------------–>
% Angle avec trois nodes
%<--------------------------------------------------------------------------–>
\def\tkzFindAngle(#1,#2,#3){% new code 2016
\begingroup
\tkzFindSlopeAngle(#2,#1)\tkzGetAngle{tkz@FirstAngle}
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@SecondAngle}
\tkzNormalizeAngle(\tkz@FirstAngle,\tkz@SecondAngle)
\FPadd\tkz@Angle{\tkz@SecondAngle}{-\tkz@FirstAngle}
\global\let\tkzAngleResult\tkz@Angle
\endgroup
}
%<--------------------------------------------------------------------------–>
% Find angle
%<--------------------------------------------------------------------------–>
\def\tkzGetAngle#1{%
\global\expandafter\edef\csname #1\endcsname{\tkzAngleResult}
}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=1.0]
\tkzInit
\pgfmathsetmacro{\Radius}{2}
\tkzDefPoint(0,0){O}
\tkzDefPoint(20:\Radius){A}
\tkzDefPoint(100:\Radius){B}
\tkzDefPoint(-150:\Radius){C}
\tkzDefPoint(-70:\Radius){D}
\tkzDrawSegments[dashed](O,A O,B O,C O,D)
\tkzDrawCircle(O,A)
\tkzTangent[at=A](O) \tkzGetPoint{h}
\tkzTangent[at=B](O) \tkzGetPoint{i}
\tkzTangent[at=C](O) \tkzGetPoint{j}
\tkzTangent[at=D](O) \tkzGetPoint{k}
\tkzInterLL(A,h)(B,i) \tkzGetPoint{R}
\tkzInterLL(A,h)(D,k) \tkzGetPoint{Q}
\tkzInterLL(C,j)(B,i) \tkzGetPoint{S}
\tkzInterLL(C,j)(D,k) \tkzGetPoint{P}
\tkzDrawSegments[thick,brown](P,Q Q,R R,S S,P)
\tkzDrawPoints[color=red,size=3mm,fill=red!60](P,Q,R,S)
\tkzLabelPoints[below](O,P,Q,R,S)
\tkzLabelPoints[below](A,B,C,D)
\tkzFindAngle(C,O,D)
\tkzGetAngle{angleCOD};
\FPround\angleCOD\angleCOD{0}
\tkzMarkAngle[size=.5](C,O,D)
\tkzLabelAngle[pos=.7](C,O,D){\tiny $\angleCOD^\circ$}
\tkzFindAngle(D,O,A)
\tkzGetAngle{angleAOD};
\FPround\angleAOD\angleAOD{0}
\tkzMarkAngle[size=.6](D,O,A)
\tkzLabelAngle[pos=.8](D,O,A){\tiny $\angleAOD^\circ$}
\tkzFindAngle(B,O,C)
\tkzGetAngle{angleBOC};
\FPround\angleBOC\angleBOC{0}
\tkzMarkAngle[size=.8](B,O,C)
\tkzLabelAngle[pos=-0.9](C,O,B){\tiny $\angleBOC^\circ$}
\tkzFindAngle(A,O,B)
\tkzGetAngle{angleAOB};
\FPround\angleAOB\angleAOB{0}
\tkzMarkAngle[size=.7](A,O,B)
\tkzLabelAngle[pos=0.9](A,O,B){\tiny $\angleAOB^\circ$}
\end{tikzpicture}
\end{document}
答案2
通过一些思考和自定义mark_angle
宏,你可以简单地完成所有这些操作元帖子同样,这里将其包装起来luamplib
以使标签更简单。使用 编译此文件lualatex
。
\documentclass[border=5mm]{standalone}
\usepackage{luatex85}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
pair O, A, B, C, D, P, Q, R, S;
path c;
c = fullcircle scaled 4cm;
O = origin;
A = point 20 / 360 * 8 of c;
B = point 100 / 360 * 8 of c;
C = point -150 / 360 * 8 of c;
D = point -70 / 360 * 8 of c;
P = whatever [C, O rotatedabout(C, 90)] = whatever [D, O rotatedabout(D, 90)];
Q = whatever [D, O rotatedabout(D, 90)] = whatever [A, O rotatedabout(A, 90)];
R = whatever [A, O rotatedabout(A, 90)] = whatever [B, O rotatedabout(B, 90)];
S = whatever [B, O rotatedabout(B, 90)] = whatever [C, O rotatedabout(C, 90)];
color brown, maroon;
brown = 2/3 (red + 1/2 green);
maroon = 2/3 (red + 1/4 blue);
draw P--Q--R--S--cycle withcolor brown;
vardef mark_angle(expr a, b, c, r, shade) =
save arc; path arc;
arc = fullcircle scaled 2r rotated angle (a-b) shifted b cutafter (b--c);
draw arc withcolor shade;
save theta; numeric theta;
theta = round(angle (c-b) - angle (a-b)) mod 360;
label("$\scriptstyle " & decimal theta & "^\circ$",
(r+8) * unitvector (a-b) rotated 1/2 theta) withcolor shade;
enddef;
mark_angle(D, O, A, 18, maroon);
mark_angle(A, O, B, 16, maroon);
mark_angle(B, O, C, 20, maroon);
mark_angle(C, O, D, 16, maroon);
draw c;
forsuffixes @=A, B, C, D:
draw O -- @ dashed evenly scaled 1/2;
label("$" & str @ & "$", @ + 8 unitvector @);
endfor
forsuffixes @=P, Q, R, S:
fill fullcircle scaled dotlabeldiam shifted @ withcolor 1/4 [red, white];
draw fullcircle scaled dotlabeldiam shifted @ withcolor 1/2 red;
label("$" & str @ & "$", @ + 8 unitvector @);
endfor
fill fullcircle scaled dotlabeldiam shifted O;
label("$O$", 8 dir 160);
cmykcolor straw; straw = (0, 0, 0.1, 0);
picture P; P = currentpicture;
fill bbox P withcolor straw;
draw P;
endfig;
\end{mplibcode}
\end{document}