diagrams,asymptote,code – Right Triangle with Angle: Creation and Code Explanation

asymptotecodediagrams

So my problem is simple, I just want to create a right triangle with angle 18. What I have so far is

diagram

Here's my code:

[asy]
size(300);
pair A = (0,0);
path B = dir(18);
path C = dir(90);
draw(A--B--C--cycle);
[/asy]

It does seem like it would be really simple to do, so if somebody could provide a solution that would be nice. Thanks!

Best Answer

Try this

\documentclass[border=5mm]{standalone}
\usepackage{asymptote}
\begin{document}
\begin{asy}
    size(300);
    pair A = (0,0);
    pair B = dir(18);
    pair C = (xpart(B), 0);
    draw (A--B--C--cycle);
\end{asy}
\end{document}

compile with latex, then asy on the file produced, then latex again.

enter image description here

  • You can also write pair C = (B.x, 0); instead of using xpart()

  • Note that asy is applying implicit scaling to everything for you because of the size(300) command at the top.