[pstricks] Right triangle to scale

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sun Jun 28 08:51:45 CEST 2009


David Arnold schrieb:

> Is there a cute way to present an algorithm a pythagorean triple and
> have a right triangle drawn to scale in a space that measures 2 inches
> by two inches?
> 
> For example, I feed the problem 3, 4, 5 and I get a right triangle with
> sides 3, 4, and 5.

\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\triangle{\@ifnextchar[\triangle at i{\triangle at i[]}}
\def\triangle at i[#1]#2#3{{%
  \psset{#1}
  \pst at divide{2pt}{#3pt}\result
  \pspolygon[unit=\result\psunit](#3,0)(0,#2)(0,0)}}
\makeatother
\begin{document}

\psset{unit=1in}
\begin{pspicture}(0,0)(2,2)
\psframe[linecolor=red,linewidth=1.5pt](0,0)(2,2)
\triangle[linestyle=dashed]{3}{4}
\triangle[linestyle=dotted,linecolor=blue]{5}{12}
\end{pspicture}

\end{document}


Herbert



More information about the PSTricks mailing list