[pstricks] Right triangle to scale
Michael Sharpe
msharpe at ucsd.edu
Sun Jun 28 03:41:58 CEST 2009
The hypotenuse is not relevant---only the other sides. The red square
is to show the outline of the 2 inch box. This code always places the
longer side horizontally.
\newdimen\xdim
\newdimen\ydim
\makeatletter
\def\drawrttri#1#2{\xdim=#1in \ydim=#2in \def\yy{#2}
\ifdim\ydim>\xdim \ydim=#1in \xdim=#2in \def\yy{#1}\fi %now \ydim<=\xdim
\pst at divide{2in}\xdim{\temp}
\psset{unit=\temp in}\psline(2in,0)(0,0)(0,\yy)(2in,0)}
\makeatother
\begin{document}
\begin{pspicture}(0,0)(2in,2in)
\psline[linecolor=red,linewidth=1.5pt](2in,0)(0,0)(0,2in)(2in,2in)(2in,
0)
\drawrttri{4}{3}
\end{pspicture}
On Jun 27, 2009, at 2:28 PM, David Arnold wrote:
> All,
>
> 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.
>
> Thanks.
>
> David.
> _______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
>
More information about the PSTricks
mailing list