Difference between revisions of "AoPSWiki:Sandbox"

Line 4: Line 4:
 
'''The Name Asymptote'''
 
'''The Name Asymptote'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>Why Asymptote is called Asymptote?
+
<br>Why Asymptote is called Asymptote?
<blockquote> http://asymptote.sourceforge.net/FAQ/section1.html#whyasy
+
<blockquote>http://asymptote.sourceforge.net/FAQ/section1.html#whyasy
 
Question 1.4. Why was the name Asymptote chosen?
 
Question 1.4. Why was the name Asymptote chosen?
Well, it isn't the perfect graphics package, but we do think it is getting there asymptotically...
+
Well, it isn't the perfect graphics package, but we do think it is getting there asymptotically...
 
</blockquote>
 
</blockquote>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''Tips'''
 
'''Tips'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
* To see the asymptote code of any diagram made with asymptote, click on the diagram and it will come up.
 
* To see the asymptote code of any diagram made with asymptote, click on the diagram and it will come up.
 
* If your code is not working check to make sure you have a semicolon after each line, no extra parentheses or brackets, and no open parentheses or brackets.
 
* If your code is not working check to make sure you have a semicolon after each line, no extra parentheses or brackets, and no open parentheses or brackets.
 
* Another thing to check if your code is not working, is to make sure every variable you've used in your code is in the pair.
 
* Another thing to check if your code is not working, is to make sure every variable you've used in your code is in the pair.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#1 Beginning your code'''
 
'''#1 Beginning your code'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
To start your asymptote diagram you have to include [asy] at the beginning, and [/asy] at the ending.
 
To start your asymptote diagram you have to include [asy] at the beginning, and [/asy] at the ending.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#2 Setting points'''
 
'''#2 Setting points'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
To create points in your diagram you can use
 
To create points in your diagram you can use
 
   <code>A = (0,0);</code>
 
   <code>A = (0,0);</code>
Line 38: Line 38:
  
 
Note: You should not use E, S, N, or W as variables, instead you should use EE, SS, NN, and WW, but label them as E, S, N, W. This is because E, S, N, and W are used to indicate directions in asymptote.
 
Note: You should not use E, S, N, or W as variables, instead you should use EE, SS, NN, and WW, but label them as E, S, N, W. This is because E, S, N, and W are used to indicate directions in asymptote.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#3 Pair part 1'''
 
'''#3 Pair part 1'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you include variables in your diagram you have to have <math>\verb#pair#</math> somewhere in your code.
 
If you include variables in your diagram you have to have <math>\verb#pair#</math> somewhere in your code.
  
Line 49: Line 49:
 
   pair A,B;
 
   pair A,B;
 
in your diagram to make it work.
 
in your diagram to make it work.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#4 Connecting two points, coloring the line'''
 
'''#4 Connecting two points, coloring the line'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
Once you have set variables <math>A</math> and <math>B</math>, you can connect them by writing
 
Once you have set variables <math>A</math> and <math>B</math>, you can connect them by writing
  
Line 104: Line 104:
 
draw(A--B--cycle, dashed+red);
 
draw(A--B--cycle, dashed+red);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#5 Labeling, Midpoint'''
 
'''#5 Labeling, Midpoint'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
To label a point you can use
 
To label a point you can use
  
Line 148: Line 148:
 
label("$x$", midpoint(A--B), NE);
 
label("$x$", midpoint(A--B), NE);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#6 Angle Measures'''
 
'''#6 Angle Measures'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw an angle measure on an angle use
 
If you want to draw an angle measure on an angle use
  
Line 200: Line 200:
 
label(scale(.75)*"$90^\circ$", B, 2.5*dir(50));
 
label(scale(.75)*"$90^\circ$", B, 2.5*dir(50));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
''' #7 Distance Function'''
 
''' #7 Distance Function'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: fath2012)
 
(Source: fath2012)
 
''' My distance function'''
 
''' My distance function'''
Line 216: Line 216:
 
''' A note '''
 
''' A note '''
 
Apparently a pair has an x property and a y property. I kind of discovered this it by testing. I think it might be documented somewhere.
 
Apparently a pair has an x property and a y property. I kind of discovered this it by testing. I think it might be documented somewhere.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#8 Casting'''
 
'''#8 Casting'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: fath2012)
 
(Source: fath2012)
 
''' Casting '''
 
''' Casting '''
Line 239: Line 239:
 
label((string) b,a,S);
 
label((string) b,a,S);
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#9 Right Angle Mark'''
 
'''#9 Right Angle Mark'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw a right angle mark use this:
 
If you want to draw a right angle mark use this:
  
Line 265: Line 265:
 
draw(rightanglemark(A,B,C,1.5));
 
draw(rightanglemark(A,B,C,1.5));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#10 Intersection'''
 
'''#10 Intersection'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw a point on an intersection of two lines you can use:
 
If you want to draw a point on an intersection of two lines you can use:
  
Line 294: Line 294:
 
F = intersectionpoint(A -- B, C -- D);
 
F = intersectionpoint(A -- B, C -- D);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#11 Filling'''
 
'''#11 Filling'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
To show you how to fill in a part of a diagram with a color I'll use an example from Week 3 Problem 5 in AoPS's Introduction to Geometry course.
 
To show you how to fill in a part of a diagram with a color I'll use an example from Week 3 Problem 5 in AoPS's Introduction to Geometry course.
  
Line 388: Line 388:
 
Try out different colors to see which ones you prefer for your asymptote diagrams.
 
Try out different colors to see which ones you prefer for your asymptote diagrams.
 
Have fun!
 
Have fun!
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#12 Dot'''
 
'''#12 Dot'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw a dot on a point on your diagram use
 
If you want to draw a dot on a point on your diagram use
  
Line 412: Line 412:
  
 
<code>dot(A);</code>
 
<code>dot(A);</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
Line 452: Line 452:
 
draw(rightanglemark(A,B,C,1.5));
 
draw(rightanglemark(A,B,C,1.5));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#14 Tick Marks'''
 
'''#14 Tick Marks'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to add tick marks to a line use
 
If you want to add tick marks to a line use
  
Line 496: Line 496:
 
add(pathticks(A--B, 2, spacing=1, s=2));
 
add(pathticks(A--B, 2, spacing=1, s=2));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#15 Arrows'''
 
'''#15 Arrows'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw arrow marks to show that two lines are parallel you can use
 
If you want to draw arrow marks to show that two lines are parallel you can use
  
Line 517: Line 517:
 
draw(A--C, MidArrow(size=0.2cm));
 
draw(A--C, MidArrow(size=0.2cm));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
  
 
'''#16 Shifting Coordinates'''
 
'''#16 Shifting Coordinates'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: fath2012)
 
(Source: fath2012)
 
You can use these to shift coordinates if you're shifting lots of coordinates
 
You can use these to shift coordinates if you're shifting lots of coordinates
Line 532: Line 532:
 
return  (p.x,p.y + amount);
 
return  (p.x,p.y + amount);
 
}</code>
 
}</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#17 Rotating'''
 
'''#17 Rotating'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: nosaj and Zhaom)
 
(Source: nosaj and Zhaom)
 
Maybe if you really wanted to: rotate
 
Maybe if you really wanted to: rotate
Line 544: Line 544:
 
</code>
 
</code>
 
rotate B <math>x</math> degrees around center A is where C is.
 
rotate B <math>x</math> degrees around center A is where C is.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#18 Circles'''
 
'''#18 Circles'''
<blockquote>
+
<br>
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
 
If you want to draw a circle use
 
If you want to draw a circle use
Line 568: Line 568:
 
draw(Circle((0,0),0.4),p=green+1.5bp);
 
draw(Circle((0,0),0.4),p=green+1.5bp);
 
</asy>
 
</asy>
/<blockquote></div></div>
+
/<br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#19 Dashed Lines'''
 
'''#19 Dashed Lines'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: independentstudyproject)
 
(Source: independentstudyproject)
 
If you want to draw a dashed line you can use
 
If you want to draw a dashed line you can use
Line 593: Line 593:
 
dot(B);
 
dot(B);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#20 Angle Mark'''
 
'''#20 Angle Mark'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom & mag1c)
 
(Source: Zhaom & mag1c)
 
To make an actual angle mark:
 
To make an actual angle mark:
Line 622: Line 622:
 
dot("A",A,SW*0.5);
 
dot("A",A,SW*0.5);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#21 "for" Command'''
 
'''#21 "for" Command'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom & heatherfinotti)
 
(Source: Zhaom & heatherfinotti)
 
If you want to do the for thing you do
 
If you want to do the for thing you do
Line 649: Line 649:
 
</asy></code>
 
</asy></code>
 
[/hide]
 
[/hide]
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#22 Extension'''
 
'''#22 Extension'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to extend a line you can use this
 
If you want to extend a line you can use this
  
Line 702: Line 702:
  
 
You have the extension <math>A, B,C,</math> and <math>I</math>, because you want it to go down from point <math>C</math>, through <math>I</math>, and end on <math>\overline{AB}</math>.
 
You have the extension <math>A, B,C,</math> and <math>I</math>, because you want it to go down from point <math>C</math>, through <math>I</math>, and end on <math>\overline{AB}</math>.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#23 How to draw an equilateral triangle'''
 
'''#23 How to draw an equilateral triangle'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
In #23 we'll walkthrough how to make an equilateral triangle.
 
In #23 we'll walkthrough how to make an equilateral triangle.
  
Line 772: Line 772:
 
</asy>
 
</asy>
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#24 How to draw an isosceles triangle'''
 
'''#24 How to draw an isosceles triangle'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
In #24 we'll walkthrough how to make an isosceles triangle.
 
In #24 we'll walkthrough how to make an isosceles triangle.
 
Let's start by placing <math>A</math> at <math>(0,0)</math>.
 
Let's start by placing <math>A</math> at <math>(0,0)</math>.
Line 835: Line 835:
 
</asy>
 
</asy>
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#25 How to draw a scalene triangle'''
 
'''#25 How to draw a scalene triangle'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
In #25 we'll walkthrough how to make a scalene triangle.
 
In #25 we'll walkthrough how to make a scalene triangle.
  
Line 876: Line 876:
 
</asy>
 
</asy>
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#26 Labeling Angles'''
 
'''#26 Labeling Angles'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: independentstudyproject)
 
(Source: independentstudyproject)
 
This is similar to #6 but it labels the angle with the arc.
 
This is similar to #6 but it labels the angle with the arc.
Line 897: Line 897:
 
label("$60^\circ$",(0.1,0.1),E);
 
label("$60^\circ$",(0.1,0.1),E);
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#27 Drawing triangles using SSS, SAS, AAS, and ASA'''
 
'''#27 Drawing triangles using SSS, SAS, AAS, and ASA'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom)
 
(Source: Zhaom)
 
drawing triangles:
 
drawing triangles:
Line 968: Line 968:
 
label("$C$",C,SE);
 
label("$C$",C,SE);
 
</asy>[/hide],then <math>A</math>=[hide][c](0,0);[/c][/hide],<math>B</math>=[hide][c]dir(c)*b;[/c][/hide],and <math>C</math>=[hide][c](a,0);[/c][/hide].
 
</asy>[/hide],then <math>A</math>=[hide][c](0,0);[/c][/hide],<math>B</math>=[hide][c]dir(c)*b;[/c][/hide],and <math>C</math>=[hide][c](a,0);[/c][/hide].
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#28 Arcs'''
 
'''#28 Arcs'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom and heatherfinotti)
 
(Source: Zhaom and heatherfinotti)
 
If you want to draw an arc you can use
 
If you want to draw an arc you can use
Line 997: Line 997:
 
</asy>
 
</asy>
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#29 The Nine Point Circle'''
 
'''#29 The Nine Point Circle'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom)
 
(Source: Zhaom)
 
The nine point circle:
 
The nine point circle:
Line 1,054: Line 1,054:
 
</asy>[/hide]
 
</asy>[/hide]
 
The center is N and the radius is r/2.
 
The center is N and the radius is r/2.
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#30 Pair Part 2'''
 
'''#30 Pair Part 2'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: Zhaom, eagle702)
 
(Source: Zhaom, eagle702)
 
Another way to use the variables in the pair at the start of your code, is by using
 
Another way to use the variables in the pair at the start of your code, is by using
Line 1,086: Line 1,086:
 
label("$B$", A[2], S);
 
label("$B$", A[2], S);
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#31 Finding the midpoint'''
 
'''#31 Finding the midpoint'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
(Source: fath2012)
 
(Source: fath2012)
 
This is really just a tool from the documetation but here it is anyway.
 
This is really just a tool from the documetation but here it is anyway.
Line 1,107: Line 1,107:
 
dot(midpoint(A--B));
 
dot(midpoint(A--B));
 
</asy>
 
</asy>
</blockquote></div></div>
+
</br></div></div>
  
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#32 Foot Command'''
 
'''#32 Foot Command'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
If you want to draw a perpendicular line from a point to another line, you can use the foot command:
 
If you want to draw a perpendicular line from a point to another line, you can use the foot command:
 
<code>draw(A--foot(A,B,C));</code>
 
<code>draw(A--foot(A,B,C));</code>
Line 1,150: Line 1,150:
 
</asy>
 
</asy>
 
</code>
 
</code>
</blockquote></div></div>
+
</br></div></div>
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
  
 
'''#33 Introduction to 3D Geometry'''
 
'''#33 Introduction to 3D Geometry'''
 
<div class="mw-collapsible-content">
 
<div class="mw-collapsible-content">
<blockquote>
+
<br>
 
Making 3D figures in asymptote is a bit different from making 2D figures in asymptote. I'll state some of the differences here.
 
Making 3D figures in asymptote is a bit different from making 2D figures in asymptote. I'll state some of the differences here.
  
Line 1,169: Line 1,169:
 
<code>A = (x,y,z);</code>
 
<code>A = (x,y,z);</code>
 
<math>x</math> and <math>y</math> are the coordinates of the base of the 3D figure, and <math>z</math> is the height of the coordinate on the 3D figure.[/quote]
 
<math>x</math> and <math>y</math> are the coordinates of the base of the 3D figure, and <math>z</math> is the height of the coordinate on the 3D figure.[/quote]
<blockquote></div></div>
+
<br></div></div>
 
</dd>
 
</dd>

Revision as of 14:04, 2 June 2022

Asymptote tutorial for AoPS

The Name Asymptote


Why Asymptote is called Asymptote?

http://asymptote.sourceforge.net/FAQ/section1.html#whyasy

Question 1.4. Why was the name Asymptote chosen? Well, it isn't the perfect graphics package, but we do think it is getting there asymptotically...


Tips


  • To see the asymptote code of any diagram made with asymptote, click on the diagram and it will come up.
  • If your code is not working check to make sure you have a semicolon after each line, no extra parentheses or brackets, and no open parentheses or brackets.
  • Another thing to check if your code is not working, is to make sure every variable you've used in your code is in the pair.

#1 Beginning your code


To start your asymptote diagram you have to include [asy] at the beginning, and [/asy] at the ending.


#2 Setting points


To create points in your diagram you can use

 A = (0,0);

Say you want to have point $B$ $4$ units to the right of point $A$, then you can use

 B = (4,0);

Setting points on your diagram is like setting points on a graph. The first number is the $x$-coordinate of the point and the second number is the $y$-coordinate of the point.

Note: You should not use E, S, N, or W as variables, instead you should use EE, SS, NN, and WW, but label them as E, S, N, W. This is because E, S, N, and W are used to indicate directions in asymptote.


#3 Pair part 1


If you include variables in your diagram you have to have $\verb#pair#$ somewhere in your code.

Example: You have two points $A$ and $B$, and you're drawing a line connecting them, you need to include

 pair A,B;

in your diagram to make it work.


#4 Connecting two points, coloring the line


Once you have set variables $A$ and $B$, you can connect them by writing

draw(A--B);

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B); [/asy]

If you want to make the line you're using to connect them red, you can use

draw(A--B--cycle, red);

This will make the line red.

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B--cycle, red); [/asy]

You can also make a line dashed by writing draw(A--B--cycle, dashed)

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B--cycle, dashed); [/asy]

If you wanted to give the line multiple characteristics, such as a red dashed line, you write + in between the characteristics. draw(A--B--cycle, dashed+red)

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B--cycle, dashed+red); [/asy]


#5 Labeling, Midpoint


To label a point you can use

label("$A$",A,dir(135));

The $A$ means you will label the point $A$. The A (no dollar signs) means you will be labeling the point A. The dir(135) determines where on the point the variable will be. Or you can use label("$A$",A,N);. The N means that the label will be above (North) of the point.

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B); label("$A$",A,N); label("$B$",B,N); [/asy]

If you want to draw a variable (x) or number at the center of a line you can use

label("$x$", midpoint(A--B), NE);

The NE at the end means North-East, this will decide where on the line the variable will be (above it to the right for NE).

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B); label("$A$",A,N); label("$B$",B,N); label("$x$", midpoint(A--B), NE); [/asy]


#6 Angle Measures


If you want to draw an angle measure on an angle use

label(scale(.75)*"$x$", Z, 2.5*dir(150));

In this line of code, there is a very important command. The "dir" command.

The angle for the dir command always starts facing east. So dir(0) would label the part exactly east of what you are labeling. Similarly dir(90) would label it exactly north, dir(180) would label it exactly west, and dir(270) would label it exactly south.

This is called the unit circle; the unit circle is a large concept that will be discussed in AoPS's Precalculus course. Basically, because a circle has $360^\circ$, the starting point is to the right of the circle and the degrees move counterclockwise around the circle. This also means that dir(0) is the same as dir(360). :)

Here's a diagram that will make this tricky concept more understandable.

The starting point, which we will call $w$ is at dir(0). dir(90) is the starting point rotated $90^\circ$ counter clockwise from the starting position; we will call this point $x$. Similarly, dir(180) is the starting point rotated $180^\circ$ counterclockwise from the starting position; we will call this point $y$. Finally, dir(270) is the starting point rotated $270^\circ$ counterclockwise from the starting position; we will call this point $z$.

Here are the variables on the unit circle:

[asy] size(150); import TrigMacros; rr_cartesian_axes(-5,5,-5,5, usegrid = false); draw(Circle((0,0),4),p=black+1bp); label("$w$", (4, 0), NE); label("$x$", (0, 4), NE); label("$y$", (-4, 0), NW); label("$z$", (0, -4), SE); [/asy]

The dir(150), at the end you have to play around with, it will move around the angle to see where the degree mark is. The $Z$ in it means that it is on point $Z$. The $x$ means that the angle is $x$ degrees. The scale(.75) defines the size of the angle mark. The 2.5* defines how far from the point the angle sign is.

Example:

[asy] pair A,B,C; A=(0,1); B=(0,0); C=(1,0); draw(A--B--C--A); label("$A$",A,N); label("$B$",B,W); label("$C$",C,E); label(scale(.75)*"$90^\circ$", B, 2.5*dir(50)); [/asy]


#7 Distance Function


(Source: fath2012) My distance function real dist(pair a,pair b){ return sqrt(abs(a.x-b.x)^2+abs(a.y-b.y)^2); } Took me some much time just to write a distance function. Hopefully, everybody else doesn't have to go through lots of research to make this. A note Apparently a pair has an x property and a y property. I kind of discovered this it by testing. I think it might be documented somewhere.


#8 Casting


(Source: fath2012) Casting This is not really a command but helps you convert a data type to another data type if you can. [asy] pair a = (5,5); int b = 2; dot(a); label((string) a,a,N); label((string) b,a,S); [/asy] pair a = (5,5); int b = 2; dot(a); label((string) a,a,N); label((string) b,a,S);


#9 Right Angle Mark


If you want to draw a right angle mark use this:

draw(rightanglemark(A,B,C,1.5));

The A,B,C means that it will draw the right angle mark on $\angle ABC$. The $1.5$ defines the size of the right angle mark.

Example:

[asy] pair A,B,C; A=(0,1); B=(0,0); C=(1,0); draw(A--B--C--A); label("$A$",A,N); label("$B$",B,W); label("$C$",C,E); draw(rightanglemark(A,B,C,1.5)); [/asy]


#10 Intersection


If you want to draw a point on an intersection of two lines you can use:

F = intersectionpoint(A -- C, B -- D);

In this code $F$ is the intersection point of lines $AC$ and $BD$.

Example:

[asy] pair A, B, C, D, F; A = (1,0); B = -A; C = (0.7,0.7); D = -C; draw(A--B); draw(C--D); label("$A$",A,E); label("$B$",B,N); label("$C$",C,N); label("$D$",D,S); label("$F$",F,SE); F = intersectionpoint(A -- B, C -- D); [/asy]


#11 Filling


To show you how to fill in a part of a diagram with a color I'll use an example from Week 3 Problem 5 in AoPS's Introduction to Geometry course.

[asy] fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,red); fill((7,0)--(1,5)--(7,5)--cycle,red); for (int i=0;i<=7;i+=1) { draw((i,0)--(i,5)); }; for (int j=0;j<=5;j+=1) { draw((0,j)--(7,j)); }; draw((7,0)--(1,5)--(5,0)); [/asy]

Let's walkthrough how the left side of the rectangle is red.

Whoever made the asymptote code for this used the line

fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,red);

The coordinates mean that it will fill in the quadrilateral at points (0,0); (0,5); (1,5); and (5,0). The red at the end means that the color will be red, here's what it would look like if I put blue instead of red (on the left and right side).

[asy] fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,blue); fill((7,0)--(1,5)--(7,5)--cycle,blue); for (int i=0;i<=7;i+=1) { draw((i,0)--(i,5)); }; for (int j=0;j<=5;j+=1) { draw((0,j)--(7,j)); }; draw((7,0)--(1,5)--(5,0)); [/asy]

If you want to make it a color like light blue, light brown, dark blue, etc. do not put a space between the two words.

If you wanted to make both sides dark blue you would put

fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,darkblue); fill((7,0)--(1,5)--(7,5)--cycle,darkblue);

Here's what it would look like:

[asy] fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,darkblue); fill((7,0)--(1,5)--(7,5)--cycle,darkblue); for (int i=0;i<=7;i+=1) { draw((i,0)--(i,5)); }; for (int j=0;j<=5;j+=1) { draw((0,j)--(7,j)); }; draw((7,0)--(1,5)--(5,0)); [/asy]

(It looks more like navy to me. But inserting "navy" does not work so I guess that's why.)

You don't have to have both sides the same color though, you could have the left side blue and the right side pink.

[asy] fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,blue); fill((7,0)--(1,5)--(7,5)--cycle,pink); for (int i=0;i<=7;i+=1) { draw((i,0)--(i,5)); }; for (int j=0;j<=5;j+=1) { draw((0,j)--(7,j)); }; draw((7,0)--(1,5)--(5,0)); [/asy]

Or vice versa.

[asy] fill((0,0)--(0,5)--(1,5)--(5,0)--cycle,pink); fill((7,0)--(1,5)--(7,5)--cycle,blue); for (int i=0;i<=7;i+=1) { draw((i,0)--(i,5)); }; for (int j=0;j<=5;j+=1) { draw((0,j)--(7,j)); }; draw((7,0)--(1,5)--(5,0)); [/asy]

Try out different colors to see which ones you prefer for your asymptote diagrams. Have fun!


#12 Dot


If you want to draw a dot on a point on your diagram use

dot(A, p=black+3bp);

This will draw a black dot on point $A$.

Example:

[asy] pair A; A=(0,0); dot(A, p=black+3bp); label("$A$",A,N); [/asy]

You can also use

dot(A);


#13 Size

To make your diagram larger or smaller you can use

size(200);

Example:

Big triangle

[asy] size(200); pair A,B,C; A=(0,1); B=(0,0); C=(1,0); draw(A--B--C--A); label("$A$",A,N); label("$B$",B,W); label("$C$",C,E); draw(rightanglemark(A,B,C,1.5)); [/asy]

And small triangle

[asy] size(70); pair A,B,C; A=(0,1); B=(0,0); C=(1,0); draw(A--B--C--A); label("$A$",A,N); label("$B$",B,W); label("$C$",C,E); draw(rightanglemark(A,B,C,1.5)); [/asy]


#14 Tick Marks


If you want to add tick marks to a line use

add(pathticks(A--B, spacing=1, s=2));

This will add a tick mark in the middle of line $AB$. The s controls how small/large the tick mark is. If you have more than 1 tick mark the spacing=1 determines how much space is between your tick marks (source Zhaom).

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B); label("$A$",A,N); label("$B$",B,N); add(pathticks(A--B, spacing=1, s=2)); [/asy]

If you want to add more than $1$ tick mark you can use

add(pathticks(A--B, 2, spacing=1, s=4));

What I changed was that I added a 2 after A--B. This works for 3, 4, etc.

Example:

[asy] pair A,B; A=(0,0); B=(1,0); draw(A--B); label("$A$",A,N); label("$B$",B,N); add(pathticks(A--B, 2, spacing=1, s=2)); [/asy]


#15 Arrows


If you want to draw arrow marks to show that two lines are parallel you can use

draw(A--C, MidArrow(size=0.2cm));

This will draw a little black arrow at the midpoint of $AC$.

Example:

[asy] pair A, C;  A = (0,0); C = (2,0); draw(A--C, MidArrow(size=0.2cm)); [/asy]


#16 Shifting Coordinates


(Source: fath2012) You can use these to shift coordinates if you're shifting lots of coordinates pair shiftx(pair p,int amount){ return (p.x + amount,p.y); } pair shifty(pair p,int amount){ return (p.x,p.y + amount); }


#17 Rotating


(Source: nosaj and Zhaom) Maybe if you really wanted to: rotate pair C=rotate(x,A)*B; rotate B $x$ degrees around center A is where C is.


#18 Circles

If you want to draw a circle use

[asy] unitsize(1cm); draw(Circle((0,0),0.4),p=black+1.5bp); [/asy]

The Circle((0,0) determines where on your picture the circle is (on this one it is centered at the point $(0,0)$. The 0.4 determines the radius of your circle, so in this circle the radius has a length of 0.4. The 1cm determines the size of the circle. The p=black makes the circle black, if we wanted to make it green we would use p=green. Example: [asy] unitsize(1cm); draw(Circle((0,0),0.4),p=green+1.5bp); [/asy]

/

#19 Dashed Lines


(Source: independentstudyproject) If you want to draw a dashed line you can use

draw(A--B, dashed);

Example:

[asy] pair A,B; A = (0,0); B = (5,0); draw(A--B, dashed); label("$A$", A, S); label("$B$", B, S); dot(A); dot(B); [/asy]


#20 Angle Mark


(Source: Zhaom & mag1c) To make an actual angle mark: at the top do

import markers;</code>
and then do for the angle:
<code>markangle(1,L="whatever degrees it is",B,A,C,radius=2mm)</code>
the "2mm" is the size and B,A,and C are the points. If you do C,A,B it becomes the other angle.
for example:
<asy>
import markers;
pair A,B,C;
A=(0,0);
B=(1,0);
C=(1,1);
draw(B--A--C);
dot(B^^A^^C);
markangle(1,L="B,A,C and 6mm",B,A,C,radius=6mm);
markangle(1,L="C,A,B and 5mm",C,A,B,radius=5mm);
dot("B",B,E);
dot("C",C,NE);
dot("A",A,SW*0.5);
 (Error making remote request. Unknown error_msg)

#21 "for" Command


(Source: Zhaom & heatherfinotti) If you want to do the for thing you do for (int i=-10;i<=10;i+=1){whatever code you have in here} to make $i$ start at -10,increase by 1 every time (i+=1),and end at 10 and you repeat whatever is inside. [hide=Example][asy] pair A,B; for(int i=0;i<=7;i+=1) { A=dir(360*i/8); B=dir(360*(i+1)/8); draw(A--B);} [/asy]

This is [asy] pair A,B; for(int i=0;i<=7;i+=1) { A=dir(360*i/8); B=dir(360*(i+1)/8); draw(A--B);} [/asy] [/hide]


#22 Extension


If you want to extend a line you can use this

Z = extension(A,B,C,I);

[asy] // Source: Week 7 Problem 6 (edited a bit) pair A,B,C,X,Y,I;  A= (0,0); B = (1,0); C = (0.8,0.7); X = intersectionpoint(B--C , A -- (bisectorpoint(B,A,C))); Y = intersectionpoint(A--C, B -- scale(6)*( (bisectorpoint(C,B,A)) - B)); I = intersectionpoint(A--X, B--Y); draw(A--B--C--cycle); draw(B--Y); label("$A$",A,SW); label("$B$",B,SE); label("$C$",C,N); label("$I$",I,SW); label("$Y$",Y,NW); [/asy]

Example: If we wanted to draw a line that started at point $C$, went through point $I$, and ended on line $AB$, we could use this code Z = extension(A,B,C,I); to get

[asy] pair A,B,C,X,Y,Z,I;  A= (0,0); B = (1,0); C = (0.8,0.7); X = intersectionpoint(B--C , A -- (bisectorpoint(B,A,C))); Y = intersectionpoint(A--C, B -- scale(6)*( (bisectorpoint(C,B,A)) - B)); I = intersectionpoint(A--X, B--Y); Z = extension(A,B,C,I); draw(A--B--C--cycle); draw(B--Y); draw(C--Z); label("$A$",A,SW); label("$B$",B,SE); label("$C$",C,N); label("$I$",I,SW); label("$Y$",Y,NW); label("$Z$",Z,S); [/asy]

You have the extension $A, B,C,$ and $I$, because you want it to go down from point $C$, through $I$, and end on $\overline{AB}$.


#23 How to draw an equilateral triangle


In #23 we'll walkthrough how to make an equilateral triangle.

The way to draw an equilateral triangle is just where you set your points.

Let's put point $A$ at (0,0).

[asy] pair A;  A = (0,0);  label("$A$", A, W); [/asy]

Now, to make an equilateral triangle every side has to be the same.

Let's put point $B$ at (0,2), and draw a line connecting $A$ to $B$.

[asy] pair A, B;  A = (0,0); B = (2,0);  draw(A--B);  label("$A$", A, W); label("$B$", B, E); [/asy]

Last, we need to decide where to put point $C$. Since we're trying to draw an equilateral triangle we have to have point $C$ the same distance away from $A$ and $B$. We also have to have point $C$'s height equal, so we have an equilateral triangle.

This means that the $x$-coordinate of point $C$ is $1$, and the $y$-coordinate is $\sqrt{3}$. This forms our equilateral triangle $ABC$. Here's our equilateral triangle and the code for it.

[asy] pair A, B, C;  A = (0,0); B = (2,0); C = (1, sqrt(3));  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]

[asy] pair A, B, C;  A = (0,0); B = (2,0); C = (1, sqrt(3));  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]


#24 How to draw an isosceles triangle


In #24 we'll walkthrough how to make an isosceles triangle. Let's start by placing $A$ at $(0,0)$.

[asy] pair A;  A = (0,0);  label("$A$", A, W); [/asy]

Now, let's place $B$ at $(2,0)$, and connecting $A$ and $B$.

[asy] pair A, B;  A = (0,0); B = (2,0);  draw(A--B);  label("$A$", A, W); label("$B$", B, E); [/asy]

To make this an isosceles triangle point $C$ can go anywhere with the coordinates $(1,x)$, as long as $x$ isn't $0$ because then it would be a line not a triangle. So here's our isosceles triangle and the code for it.

[asy] pair A, B, C;  A = (0,0); B = (2,0); C = (1,4);  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]

[asy] pair A, B, C;  A = (0,0); B = (2,0); C = (1,4);  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]


#25 How to draw a scalene triangle


In #25 we'll walkthrough how to make a scalene triangle.

This is the easiest type of triangle to make in asymptote. You just make sure none of your points are on the same line (vertical and horizontal). We can put $A$ at $(0,0)$, $B$ at $(3,-1)$, and $C$ at $(7,4)$. Here's our scalene triangle and the code for it.

[asy] pair A, B, C;  A = (0,0); B = (3,-1); C = (7,4);  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]

[asy] pair A, B, C;  A = (0,0); B = (3,-1); C = (7,4);  draw(A--B--C--cycle);  label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); [/asy]


#26 Labeling Angles


(Source: independentstudyproject) This is similar to #6 but it labels the angle with the arc.

To label an angle with an arc, use the "anglemark" function. For instance, if you want to draw a $60^\circ$ angle using points $A$, $B$, and $C$, where the angle is at $A$, you would do draw(anglemark(B,A,C,3.5)); The draw, draws the anglemark; the anglemark makes the anglemark; the 3 letters symbolize what angle you want; 3.5 is the size of the angle mark.

Example: [asy] pair A,B,C; A = (0,0); B = (1,0); C = A + dir(60); draw(C--A--B); draw(anglemark(B,A,C,3.5)); label("$60^\circ$",(0.1,0.1),E); [/asy]


#27 Drawing triangles using SSS, SAS, AAS, and ASA


(Source: Zhaom) drawing triangles: SSS: given a triangle with sides $a$,$b$,and $c$,for example: [asy] pair A,B,C; A=(0,0); B=(2,2); C=(3,0); draw(A--B--C--A); label("$a$",(A+C)/2,S); label("$b$",(A+B)/2,NW); label("$c$",(B+C)/2,NE); label("$A$",A,SW); label("$B$",B,N); label("$C$",C,SE); [/asy] Then $A$ would be [hide][c](0,0);[/c][/hide],$B$ would be [hide][c]dir(aSin(sqrt((a+b+c)/2*((a+b+c)/2-a)*((a+b+c)/2-b)*((a+b+c)/2-c))*2/a/b))*b;[/c][/hide], and $C$ would be [hide][c](a,0)[/c][/hide]. ASA: using [hide=this diagram][asy] import markers; pair A,B,C; A=(0,0); B=(2,2); C=(3,0); draw(A--B--C--A); label("$a$",(A+C)/2,S); markangle(1,L="$b^\circ$",C,A,B,radius=4mm); markangle(1,L="$c^\circ$",A,B,C,radius=4mm); label("$A$",A,SW); label("$B$",B,N); label("$C$",C,SE); [/asy][/hide] You need two more points,$D$ and $E$.Then,$A$=[hide][c](0,0);[/c][/hide],$C$=[hide][c](a,0);[/c][/hide],$D$=[hide][c]dir(b)*3000;[/c][/hide],$E$=[hide][c]dir(180-c)*3000[/c][/hide],and $B$=[hide][c]intersectionpoint(A--D,C--E);[/c][/hide]. AAS: for [hide=this diagram][asy] import markers; pair A,B,C; A=(0,0); B=(2,2); C=(3,0); draw(A--B--C--A); label("$a$",(A+C)/2,S); markangle(1,L="$b^\circ$",C,A,B,radius=4mm); markangle(1,L="$c^\circ$",A,B,C,radius=4mm); label("$A$",A,SW); label("$B$",B,N); label("$C$",C,SE); [/asy][/hide] ,it's the same as ASA except $E$=[hide][c]dir(b+c)*3000[/c][/hide]. SAS: Still using the same diagram but like [hide=this][asy] import markers; pair A,B,C; A=(0,0); B=(2,2); C=(3,0); draw(A--B--C--A); label("$a$",(A+C)/2,S); label("$b$",(A+B)/2,NW); markangle(1,L="$c^\circ$",C,A,B,radius=4mm); label("$A$",A,SW); label("$B$",B,N); label("$C$",C,SE); [/asy][/hide],then $A$=[hide][c](0,0);[/c][/hide],$B$=[hide][c]dir(c)*b;[/c][/hide],and $C$=[hide][c](a,0);[/c][/hide].


#28 Arcs


(Source: Zhaom and heatherfinotti) If you want to draw an arc you can use

draw(arc(A,B,C,D));

$A$ is where the arc is centered, $B$ is the radius of the arc, $C$ is the angle it starts at and $D$ is the angle it ends at. Example:

[asy] draw(arc((0,0),1,90,30),green); draw(arc((0,0),1,30,-30),blue); [/asy]

The code for this arc is

[asy] draw(arc((0,0),1,90,30),green); draw(arc((0,0),1,30,-30),blue); [/asy]


#29 The Nine Point Circle


(Source: Zhaom) The nine point circle: [c][asy] pair A,B,C,H,O,N; A=(0,0); B=(2,0); C=(1, sqrt(3)); H=orthocenter(A,B,C); O=circumcenter(A,B,C); N=(H+O)/2; draw(A--B--C--cycle); label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); real dist(pair a,pair b){ return sqrt(abs(a.x-b.x)^2+abs(a.y-b.y)^2); } real a=dist(A,B); real b=dist(B,C); real c=dist(C,A); real s=(a+b+c)/2; real d=sqrt(s*(s-a)*(s-b)*(s-c)); real r=(a*b*c)/(4*d); draw(Circle(N,r/2)); [/asy][/c] A,B, and C can really be any coordinates. [hide=example][asy] pair A,B,C,H,O,N; A=(0,0); B=(3,0); C=(3,4); H=orthocenter(A,B,C); O=circumcenter(A,B,C); N=(H+O)/2; draw(A--B--C--cycle); label("$A$", A, W); label("$B$", B, E); label("$C$", C, N); real dist(pair a,pair b){ return sqrt(abs(a.x-b.x)^2+abs(a.y-b.y)^2); } real a=dist(A,B); real b=dist(B,C); real c=dist(C,A); real s=(a+b+c)/2; real d=sqrt(s*(s-a)*(s-b)*(s-c)); real r=(a*b*c)/(4*d); draw(Circle(N,r/2)); dot("N",N,N); [/asy][/hide] The center is N and the radius is r/2.


#30 Pair Part 2


(Source: Zhaom, eagle702) Another way to use the variables in the pair at the start of your code, is by using

pair A[1]; pair A[2];

The coding will register this as two different variables. Make sure that when you are labeling points you use the correct command.

label("$A$", A[1], S);

And not:

label("$A$", A, S);

You can still have names of different variable using this pair function by labeling them as

label("$A$", A[1], S); label("$B$", A[2], S);


#31 Finding the midpoint


(Source: fath2012) This is really just a tool from the documetation but here it is anyway. Find the midpoint of AB pair A = (-5,6); pair B = (9,-2); draw(A--B); dot(midpoint(A--B)); [asy] pair A = (-5,6); pair B = (9,-2); draw(A--B); dot(midpoint(A--B)); [/asy]


#32 Foot Command


If you want to draw a perpendicular line from a point to another line, you can use the foot command: draw(A--foot(A,B,C)); This would draw a line that starts at point $A$ and is perpendicular to $\overline{BC}$. [asy] size(200); pair A, B, C;  A = (0,0); B = (0,4); C = (2,0);  draw(A--B--C--cycle);  draw(A--foot(A,B,C));  label("$A$", A, S); label("$B$", B, N); label("$C$", C, S); [/asy] Here's the code for the triangle: [asy] size(200); pair A, B, C;  A = (0,0); B = (0,4); C = (2,0);  draw(A--B--C--cycle);  draw(A--foot(A,B,C));  label("$A$", A, S); label("$B$", B, N); label("$C$", C, S); [/asy]


#33 Introduction to 3D Geometry


Making 3D figures in asymptote is a bit different from making 2D figures in asymptote. I'll state some of the differences here.

The first thing you have to do when making 3D figures in asymptote, is putting import three; at the beginning of your code. Next, instead of using pair A,B,C; you would use triple A,B,C; The other main difference in 2D geometry asymptote and 3D geometry asymptote is that when you are labeling a variable, instead of using A = (x,y); you have to use A = (x,y,z); $x$ and $y$ are the coordinates of the base of the 3D figure, and $z$ is the height of the coordinate on the 3D figure.[/quote]