You are on page 1of 5

Asymptote Cheat-Sheet

Tovi Wen

November 2020

There are plenty of good internet resources for helping someone get the basics of
asymptote down pact, after which they could theoretically figure out the tricky bits
for themself, but I’ll spell some of it out here.

§1 Introduction
Always import olympiad.asy from the external link here and begin your code with
import olympiad;
size(X cm);
defaultpen(fontsize(10pt));
Where X can be whatever you want (I usually choose something between 7 and 10) depending
on how detailed the diagram is.

§2 Points & Lines


To mark the intersection P , of two line segments AB and CD, write
pair P = extension(A,B,C,D);.
To mark the foot of the altitude H from a point A to a line BC, write
pair H = foot(A,B,C); .
To mark a point P on the segment AB such that P A : P B = 3 : 5 (or anything else), write
pair P = (5A + 3B)/(5 + 3); .
−−→
To mark a point P on the extension of ray AB such that P A : P B = 3 : 5, write
pair P = (5A - 3B)/(5 - 3); .
To mark the intersection P of the line through A perpendicular to AB with a line CD, write
P = extension(A, rotate(90, A)*B, C, D); .

§3 Circles
To mark the second intersection P of a line AD with the circumcircle of 4ABC (with D not
on the circle), write
pair O=circumcenter(A,B,C);
pair P = -A+2*foot(O,A,D);.
To mark the second intersection P of the circumcircles of 4ABC and 4AEF , write one of
pair P = intersectionpoints(circumcircle(A,B,C), circumcircle(A,E,F))[0];
pair P = intersectionpoints(circumcircle(A,B,C), circumcircle(A,E,F))[1];
.

1
Asymptote Cheat-Sheet Tovi Wen

As far as I know, there is no quick way to tell which intersection is correct, and which one is
useless and just duplicates A. Just compile both to find out which works.
To mark the two intersections P and Q, of the circumcircles of 4ABC and 4DEF , write
pair P = intersectionpoints(circumcircle(A,B,C), circumcircle(D,E,F))[0];
pair Q = intersectionpoints(circumcircle(A,B,C), circumcircle(D,E,F))[1];
.

§4 Drawing/Marking Things
If you want an arbitrary triangle (usually something that’s acute, and is especially not-special),
I usually write
pair A = dir(120);
pair B = dir(210);
pair C = dir(330);.
But you do you. The important thing is that dir(X) refers to the unit vector at an angle of
X degrees.
To draw the segment AB, and the circumcircle of 4ABC, write
draw(A--B);
draw(circumcircle(A,B,C));
To draw the triangle 4ABC without wasting too much time, write
draw(A--B--C--A);
and this technique works for general polygons as well.
To draw the arc of the circumcircle of 4ABC between 30 degrees above the horizontal and 190
degrees above the horizontal, write
draw(arc(circumcenter(A,B,C), circumradius(A,B,C), 30, 190));
To label the point A, write
dot(’’$A$’’, A, dir(X)); .
Where X is an angle that can be whatever you want. If A happens to lie on a circle centered
at the origin, it’s usually fine to just write
dot(’’$A$’’, A, dir(A));
But this doesn’t always work so well.

§5 Cosmetics
Skip this section if you want, but most people care about making their diagrams look classy
and pretty.

§5.1 Dots & Dashes


Often one will be drawing a diagram for a solution to a problem that includes some facts that
have to be proven along the way.
For example, suppose we are drawing a diagram for a problem which involves proving a quadri-
lateral ABCD is cyclic. We want to draw the circumcircle of ABCD but represent the fact
that we don’t know the concyclicity is true. Write one of
draw(circumcircle(A,B,C), dashed);
draw(circumcircle(A,B,C), dotted); .
Whichever looks best in context.

2
Asymptote Cheat-Sheet Tovi Wen

§5.2 Opacity & Coloring


Not all clines are created equal. Say we want to include the line segment AB in our diagram,
but it’s mostly irrelevant, so we want it a bit out of focus. Write
draw(A--B, opacity(0.3));
or anything between 0.3 and 1. As you can probably guess, if we want to amplify the segment,
give it an opacity greater than 1.
If you want to color a segment AB, write
draw(A--B, orange);
and if you want to do all three, you can, by saying
draw(A--B, opacity(0.3) + orange + dashed);
I usually like to shade some of the objects with different colors to make the diagrams look
fancy. Here, you really need to use the opacity feature as usually, anything more than 0.1
will be overpowering and destroy the diagram. If you want to shade 4ABC orange, and its
circumcircle blue, write
fill(A--B--C--cycle, orange+opacity(0.03));
fill(circumcircle(A,B,C), blue+opacity(0.03));

§6 Stuff I Forgot
This guide is by no means extensive. If there’s something you need to figure out that I haven’t
mentioned, just think of a problem that uses a similar construction (there probably is one),
and check the AOPS forum for that problem. Odds are somebody has made a nice asymptote
diagram that you can borrow some stuff from.

§7 Example
I think the following diagram involves most of the techniques discussed. If you’re interested,
the diagram is for GOTEEM 2019/5.

M
A B2

C2
R

B1
C1

B C
P

Below is the code which renders the above example:

3
Asymptote Cheat-Sheet Tovi Wen

begin{center}
begin{asy}
import olympiad;
size(12 cm);
defaultpen(fontsize(10pt));

pair A, B, C, M, B1, O1, C1, OB, OC, P, B2, C2, X, Y, R;

A=dir(120); B=dir(210); C=dir(330);


M=dir(90); B1 = midpoint(A--B);
O1=circumcenter(A,M,B1); C1 = -A+2*foot(O1,A,C);
OB=circumcenter(A,B,C1); OC=circumcenter(A,C,B1);
P=intersectionpoints(circumcircle(A,B,C1), circumcircle(A,C,B1))[1];
B2=-P+2*foot(OB, P, B1); C2=-P+2*foot(OC,P,C1);
X=extension(A,P,B1,C1); Y=extension(C1,C2,B1,B2); R=extension(M,A,B1,C1);

fill(circumcircle(A,B,C), blue+opacity(0.02));
fill(A--B--C--cycle, red+opacity(0.03));

draw(A--B--C--A, red);
draw(circumcircle(A,B,C), blue);
draw(circumcircle(A,B1,C1), springgreen+dashed);
draw(circumcircle(A,B,C1), orange + opacity(0.5));
draw(circumcircle(A,C,B1), orange + opacity(0.5));
draw(arc(M, circumradius(B1, C1, B2), 190, 365), dashed + heavycyan);
draw(arc(circumcenter(A,B2,C2), circumradius(A, B2, C2), 55, 145),
dotted + red);
draw(R--M, deepcyan);
draw(R--C1, deepcyan);
draw(R--C2, deepcyan);
draw(P--B2, lightblue);
draw(P--C2, lightblue);
draw(A--P, dotted + lightblue);
draw(B2--C1, dotted + lightblue);
draw(B2--C1, dotted + lightblue);
draw(C2--B1, dotted + lightblue);

dot(’’$A$’’, A, dir(A));
dot(’’$B$’’, B, dir(B));
dot(’’$C$’’, C, dir(C));
dot(’’$P$’’, P, dir(P));
dot(’’$B 1$’’, B1, dir(210));
dot(’’$C 1$’’, C1, dir(C1));
dot(’’$B 2$’’, B2, dir(B2));
dot(’’$C 2$’’, C2, dir(C2));
dot(’’$M$’’, M, dir(M));
dot(’’$R$’’, R, dir(R));
end{asy}
end{center}

4
Asymptote Cheat-Sheet Tovi Wen

§8 Exercises
Problem 1. Initialize the reflection of A over the line BC.

Problem 2. Initialize the intersection of the tangents to the circumcircle of 4ABC at B, C.

Problem 3. Initialize the HM-point of 4ABC.

Problem 4. Make a nice asymptote diagram to be used in a solution to IMO 2019/6.

Problem 5. Make a nice asymptote diagram to be used in a solution to IMO 2008/6.

Problem 6. Make a nice asymptote diagram to be used in a solution to USA TSTST 2019/9.

You might also like