如何以最少的努力绘制此图表?

如何以最少的努力绘制此图表?

如果可能的话,我想避免手动计算以节省时间。您能帮我简化以下代码片段吗?

\documentclass{minimal}
\usepackage{pst-node}
\psset{unit=6.2cm,linewidth=1.6pt}
\pagestyle{empty}
\begin{document}
\begin{pspicture}[showgrid=false](-0.1,-0.1)(2,2.1)
\SpecialCoor
\pstVerb{/side 1 def}
\pnode(!0 side){A}\uput[180](A){$A$}
\pnode(!0 0){B}\uput[225](B){$B$}
\pnode(!80 sin 2 exp side mul 40 sin div 70 sin div 0){C}\uput[-45](C){$C$}
\pnode(!80 sin side mul 30 sin div 20 cos mul 80 sin side mul 30 sin div 20 sin mul){D}\uput[0](D){$D$}
\pnode(!50 sin side mul 20 sin div 60 cos mul 50 sin side mul 20 sin div 60 sin mul){E}\uput[90](E){$E$}
\pnode(!80 sin side mul 70 sin div 60 cos mul 80 sin side mul 70 sin div 60 sin mul){P}\uput[110](P){$P$}
\pnode(!80 sin 2 exp side mul 60 sin div 70 sin div 20 cos mul 80 sin 2 exp side mul 60 sin div 70 sin div 20 sin mul){Q}\uput[80](Q){$Q$}
\pspolygon(A)(B)(C)(D)(E)
\psset{linecolor=red}
\psline(A)(D)
\psline(B)(E)
\psset{linecolor=blue}
\psline(P)(C)
\psline(B)(D)
\psset{linecolor=magenta,linewidth=0.8pt,arcsep=1.6pt,arrows=<->}
\psarc[origin={A}](A){30pt}{(D)}{(E)}\uput{15pt}[15](A){$\theta$}

\psarc[origin={B}](B){45pt}{(E)}{(A)}\uput{25pt}[75](B){$30^\circ$}
\psarc[origin={B}](B){45pt}{(C)}{(D)}\uput{25pt}[10](B){$20^\circ$}
\psarc[origin={B}](B){45pt}{(D)}{(E)}\uput{25pt}[40](B){$\alpha$}

\psarc[origin={D}](D){40pt}{(A)}{(B)}\uput{15pt}[187.5](D){$30^\circ$}
\psarc[origin={D}](D){40pt}{(B)}{(C)}\uput{15pt}[235](D){$50^\circ$}
\psarc[origin={D}](D){40pt}{(E)}{(A)}\uput{15pt}[140](D){$50^\circ$}


\psarc[origin={C}](C){35pt}{(D)}{(P)}\uput{15pt}[100](C){$70^\circ$}
\psarc[origin={C}](C){35pt}{(P)}{(B)}\uput{13pt}[160](C){$40^\circ$}

\psarc[origin={P}](P){45pt}{(C)}{(D)}\uput{20pt}[-25](P){$30^\circ$}
\end{pspicture}
\end{document}

在此处输入图片描述

对于那些有兴趣了解这个几何问题的解决方案的人,请参阅一道棘手的几何问题

答案1

对于交点使用\psIntersectionPoint。这是一个没有计算点的解决方案,但有角度 alpha 和 theta:

\documentclass{minimal}
\usepackage{pstricks-add}
\psset{unit=6.2cm,linewidth=1.6pt}
\pagestyle{empty}
\def\psArc(#1)#2(#3)(#4)#5[#6]#7{%
  \psarc[origin={#1}](#1){#2}{(#3)}{(#4)}\uput{#5}[#6](#1){$#7$}}
\def\Uput[#1](#2){\uput[#1](#2){$#2$}}
\begin{document}

\begin{pspicture}(-0.1,-0.1)(2,2.1)
\pnode(0,1){A}\Uput[180](A) \pnode{B}\Uput[225](B)
\rput(A){\pnode(3;40){E'}} \pnode(3;60){E''} 
\psIntersectionPoint(A)(E')(B)(E''){E}\Uput[90](E)
\rput(A){\pnode(3;-10){D'}} \rput(E){\pnode(3;-60){D''}} 
\psIntersectionPoint(A)(D')(E)(D''){D}\Uput[0](D)
\pnode(3;0){C'} \rput(D){\pnode(3;-110){C''}} 
\psIntersectionPoint(B)(C')(D)(C''){C}\Uput[-45](C)
\psIntersectionPoint(A)(D)(B)(E){P} \Uput[110](P)
\psIntersectionPoint(B)(D)(C)(P){Q} \Uput[80](Q)

\pspolygon(A)(B)(C)(D)(E)
\psset{linecolor=red}
\psline(A)(D)\psline(B)(E)
\psset{linecolor=blue}
\psline(P)(C)\psline(B)(D)
\psset{linecolor=magenta,linewidth=0.8pt,arcsep=1.6pt,arrows=<->}
\psArc(A){30pt}(D)(E){15pt}[15]{\theta}
\psArc(B){45pt}(E)(A){25pt}[75]{30^\circ}
\psArc(B){45pt}(C)(D){25pt}[10]{20^\circ}
\psArc(B){45pt}(D)(E){25pt}[40]{\alpha}
\psArc(D){40pt}(A)(B){15pt}[187.5]{30^\circ}
\psArc(D){40pt}(B)(C){15pt}[235]{50^\circ}
\psArc(D){40pt}(E)(A){15pt}[140]{50^\circ}
\psArc(C){35pt}(D)(P){15pt}[100]{70^\circ}
\psArc(C){35pt}(P)(B){13pt}[160]{40^\circ}
\psArc(P){45pt}(C)(D){20pt}[-25]{30^\circ}
\psline[linestyle=dashed](E)(Q)
\end{pspicture}

\end{document}

在此处输入图片描述

答案2

我想展示如何使用 TikZ 实现这一点可能会很有用。正如 Altermundus 在评论中指出的那样,绘制双尖箭头来标记角度很困难(如果不需要箭头尖,就clip足够了)。我在这里使用了一个宏,它以三个节点为参数,并用它pgfmath来计算角度和绘制箭头。这不是非常精确,但对于许多应用程序来说应该足够好了。

第二个有趣的部分是calc坐标变换的表达式:该语法($(A)!0.5!30:(B)$)将直线上位置 0.5 处的点绕A旋转B30 度A

tikz 示例

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}

% Command for adding angle labels
\newcommand{\anglebetween}[4]{
    \pgfpointanchor{#1}{center}
    \pgfgetlastxy{\xA}{\yA}
    \pgfpointanchor{#2}{center}
    \pgfgetlastxy{\xB}{\yB}
    \pgfpointanchor{#3}{center}
    \pgfgetlastxy{\xC}{\yC}
    \pgfmathtruncatemacro\startangle{round( atan2((\xC-\xB),(\yC-\yB)) )}
    \pgfmathtruncatemacro\deltaangle{round(
        ifthenelse((atan2((\xA-\xB),(\yA-\yB))-atan2((\xC-\xB),(\yC-\yB)))>0,
        atan2((\xA-\xB),(\yA-\yB))-atan2((\xC-\xB),(\yC-\yB)),
        360+atan2((\xA-\xB),(\yA-\yB))-atan2((\xC-\xB),(\yC-\yB))
    )}
    \draw [latex-latex] ($(#2)!0.2*\baselength!(#3)$) arc [radius=0.2*\baselength,start angle=\startangle, delta angle=\deltaangle];
    \node at ($(#2)!0.16*\baselength!0.5*\deltaangle:(#3)$) {#4};
}

% Wrapper if angle is given
\newcommand{\labelknownangle}[3]{
    \anglebetween{#1}{#2}{#3}{\deltaangle$^{\circ}$}
}

% Wrapper if angle unknown
\newcommand{\labelunknownangle}[4]{
    \anglebetween{#1}{#2}{#3}{#4}
}

% Define length of first line
\def\baselength{7cm}
% Define length of "rays" used for finding intersections
\def\raylength{3*\baselength}

\begin{tikzpicture}

% Start of the code for the actual picture
\path (0,0) coordinate (B) -- +(\baselength,0) coordinate (C);

\path [name path=BD] (B) -- +(20:\raylength);
\path [name path=CD] (C) -- +(70:\raylength);
\path [name intersections={of=BD and CD, by=D}];

\path [name path=CP] (C) -- +(140:\raylength);
\path [name path=AD] (D) -- +(170:\raylength);
\path [name intersections={of=CP and AD, by=P}];

\path [name path=BE] (B) -- ($(B)!3!(P)$);
\path [name path=DE] (D) -- +(120:\raylength);
\path [name intersections={of=BE and DE, by=E}];

\path [name path=AB] (B) -- ($(B)!3!30:(E)$);
\path [name path=AD] (D) -- ($(D)!3!(P)$);
\path [name intersections={of=AB and AD, by=A}];

% Reset bounding box so the "rays" don't enlarge the picture
\pgfresetboundingbox
\draw (A) node [left] {A}
    -- (B) node [below left] {B}
    -- (C) node [below right] {C}
    -- (D) node [right] {D}
    -- (E) node [above] {E}
    -- cycle
;

\draw [red] (B) -- (E)
    (A) -- (D)
;

\draw [blue] (B) -- (D)
    (C) -- (P) node [above,black] {P}
;

\labelknownangle{D}{B}{C}
\labelknownangle{A}{B}{P}
\labelknownangle{B}{C}{P}
\labelknownangle{P}{C}{D}
\labelknownangle{C}{D}{B}
\labelknownangle{B}{D}{A}
\labelknownangle{A}{D}{E}
\labelknownangle{D}{P}{C}
\labelunknownangle{E}{B}{D}{$\alpha$}
\labelunknownangle{E}{A}{D}{$\theta$}
\end{tikzpicture}
\end{document}

答案3

使用 tkz-euclide 的解决方案

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc} 
\usepackage[upright]{fourier} 
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tkz-euclide} 
\usetkzobj{all} 

\definecolor{fondpaille}{cmyk}{0,0,0.1,0}
\pagecolor{fondpaille}   
\color{Maroon}  
\tkzSetUpColors[background=fondpaille,text=Maroon]  
\begin{document}
\begin{tikzpicture}[scale=1]
        \tkzInit[ymin=-1,ymax=12,xmin=-1,xmax=10]
        \tkzClip   
        \tkzDefPoint(1,0){B}  \tkzDefPoint(8,0){C}
        %To draw a triangle with two angles, I use two rotations
        \tkzDefPointBy[rotation= center B angle 20](C)    \tkzGetPoint{i}  
        \tkzDefPointBy[rotation= center C angle -110](B) % trick no need to name
        % the result   
        \tkzInterLL(B,i)(C,tkzPointResult)                \tkzGetPoint{D}
        % idem for  P
        \tkzDefPointBy[rotation= center D angle -80](C)   \tkzGetPoint{i}  
        \tkzDefPointBy[rotation= center C angle -40](B)    
        \tkzInterLL(D,i)(C,tkzPointResult)                \tkzGetPoint{P}    
        \tkzDefPointBy[rotation= center D angle -50](P) 
        \tkzInterLL(D,tkzPointResult)(B,P)                \tkzGetPoint{E}
        \tkzDefPointBy[rotation= center B angle 30](P) 
        \tkzInterLL(B,tkzPointResult)(D,P)                \tkzGetPoint{A}
        % now we get the point Q 
        \tkzInterLL(B,D)(C,P)                             \tkzGetPoint{Q}   

        % Now drawing and labeling

        \tkzDrawPolygon(A,B,C,D,E) 
        \tkzDrawSegments[red](A,D B,E) 
        \tkzDrawSegments[blue](B,D C,P)
        \tkzDrawPoints(A,B,C,D,E,P,Q) 

        \tkzMarkAngle[arc=ll,size=1 cm,color=red](P,B,A) 
        \tkzLabelAngle[pos=.8](P,B,A){\tiny$30^{\circ}$}      
        \tkzMarkAngle[arc=ll,size=1 cm,color=red](Q,P,D) 
        \tkzLabelAngle[pos=.8](Q,P,D){\tiny$30^{\circ}$}  
        \tkzMarkAngle[arc=ll,size=1 cm,color=red](P,D,Q) 
        \tkzLabelAngle[pos=-.8](P,D,Q){\tiny$30^{\circ}$}
        \tkzMarkAngle[arc=l,size=1 cm](C,B,D) 
        \tkzLabelAngle[pos=.8](C,B,D){\tiny$20^{\circ}$}
        \tkzMarkAngle[arc=l,size=1 cm](Q,C,B) 
        \tkzLabelAngle[pos=.8](Q,C,B){\tiny$40^{\circ}$} 
        \tkzMarkAngle[arc=l,size=1 cm](B,D,C) 
        \tkzLabelAngle[pos=.8](B,D,C){\tiny$50^{\circ}$} 
        \tkzMarkAngle[arc=l,size=1 cm](D,C,P) 
        \tkzLabelAngle[pos=.8](D,C,P){\tiny$70^{\circ}$}
        \tkzMarkAngle[arc=l,size=1 cm](E,D,P) 
        \tkzLabelAngle[pos=.8](E,D,P){\tiny$50^{\circ}$}  
        \tkzMarkAngle[arc=l,size=1 cm,color=blue](D,B,P) 
        \tkzLabelAngle[pos=.8](D,B,P){\tiny$\alpha$}
        \tkzMarkAngle[arc=l,size=1 cm,color=blue](P,A,E) 
        \tkzLabelAngle[pos=.8](P,A,E){\tiny$\theta$} 

        % labels for the points
        \tkzLabelPoint[below](B){$B$}   \tkzLabelPoint[below](C){$C$}
        \tkzLabelPoint[left](A){$A$}    \tkzLabelPoint[right](D){$D$}
        \tkzLabelPoints[above](E,Q)     \tkzLabelPoint[above left](P){$P$} 

\end{tikzpicture}   

\end{document}

在此处输入图片描述

答案4

GeoGebra是一个不错的选择。生成的图表可以导出为 TikZ、PSTricks 或 Asymptote 代码,以及 PDF/EPS/PNG。节省大量时间!

相关内容