Difference between revisions of "AoPSWiki:Sandbox"

Line 1: Line 1:
 
<h1>Asymptote tutorial for AoPS</h1>
 
<h1>Asymptote tutorial for AoPS</h1>
<u>'''Table of Contents'''</u>
 
 
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''The Name Asymptote'''
 
'''The Name Asymptote'''
Line 10: Line 8:
 
[/quote]
 
[/quote]
 
[/quote]</div></div>
 
[/quote]</div></div>
[hide=Tips]
+
 
 +
<div class="mw-collapsible mw-collapsed" style="width:100%">
 +
'''Tips'''
 +
<div class="mw-collapsible-content">
 
[list]
 
[list]
 
[*] 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.
Line 16: Line 17:
 
[*] 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.
 
[/list]
 
[/list]
[/hide]
+
</div></div>
[hide=#1 Beginning your code]
+
 
 +
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#1 Beginning your code'''
 
'''#1 Beginning your code'''
 +
<div class="mw-collapsible-content">
 +
To start your asymptote diagram you have to include [asy] at the beginning, and [/asy] at the ending.
 +
</div></div>
  
To start your asymptote diagram you have to include [verbatim][asy][/verbatim] at the beginning, and [verbatim][/asy][/verbatim] at the ending.
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
[/hide]
 
[hide=#2 Setting points]
 
 
'''#2 Setting points'''
 
'''#2 Setting points'''
 
+
<div class="mw-collapsible-content">
 
To create points in your diagram you can use
 
To create points in your diagram you can use
  
Line 36: Line 39:
  
 
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.
[/hide]
+
</div></div>
[hide=#3 Pair part 1]
+
 
 +
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#3 Pair part 1'''
 
'''#3 Pair part 1'''
 
+
<div class="mw-collapsible-content">
 
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 47: Line 51:
  
 
in your diagram to make it work.
 
in your diagram to make it work.
[/hide]
+
</div></div>
[hide=#4 Connecting two points, coloring the line]
+
 
 +
<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">
 
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 100: Line 105:
 
draw(A--B--cycle, dashed+red);
 
draw(A--B--cycle, dashed+red);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#5 Labeling, Midpoint]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#5 Labeling, Midpoint'''
 
'''#5 Labeling, Midpoint'''
 
+
<div class="mw-collapsible-content">
 
To label a point you can use
 
To label a point you can use
  
Line 142: Line 147:
 
label("$x$", midpoint(A--B), NE);
 
label("$x$", midpoint(A--B), NE);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#6 Angle Measures]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#6 Angle Measures'''
 
'''#6 Angle Measures'''
 
+
<div class="mw-collapsible-content">
 
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 192: Line 197:
 
label(scale(.75)*"$90^\circ$", B, 2.5*dir(50));
 
label(scale(.75)*"$90^\circ$", B, 2.5*dir(50));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#7 Distance function]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
''' #7 Distance Function'''
 
''' #7 Distance Function'''
 
+
<div class="mw-collapsible-content">
 
(Source: fath2012)
 
(Source: fath2012)
 
''' My distance function'''
 
''' My distance function'''
Line 206: Line 211:
 
''' 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.
[/hide]
+
</div></div>
[hide=#8 Casting]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#8 Casting'''
 
'''#8 Casting'''
 
+
<div class="mw-collapsible-content">
 
(Source: fath2012)
 
(Source: fath2012)
 
''' Casting '''
 
''' Casting '''
Line 227: Line 232:
 
label((string) b,a,S);
 
label((string) b,a,S);
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#9 Right Angle Mark]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#9 Right Angle Mark'''
 
'''#9 Right Angle Mark'''
 
+
<div class="mw-collapsible-content">
 
If you want to draw a right angle mark use this:
 
If you want to draw a right angle mark use this:
  
Line 251: Line 256:
 
draw(rightanglemark(A,B,C,1.5));
 
draw(rightanglemark(A,B,C,1.5));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#10 Intersection]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#10 Intersection'''
 
'''#10 Intersection'''
 
+
<div class="mw-collapsible-content">
 
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 278: Line 283:
 
F = intersectionpoint(A -- B, C -- D);
 
F = intersectionpoint(A -- B, C -- D);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#11 Filling]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#11 Filling'''
 
'''#11 Filling'''
 
+
<div class="mw-collapsible-content">
 
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 370: Line 375:
 
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!
[/hide]
+
</div></div>
[hide=#12 Dot]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#12 Dot'''
 
'''#12 Dot'''
 
+
<div class="mw-collapsible-content">
 
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 392: Line 397:
  
 
<code>dot(A);</code>
 
<code>dot(A);</code>
[/hide]
+
</div></div>
[hide=#13 Size]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#13 Size'''
 
'''#13 Size'''
 
+
<div class="mw-collapsible-content">
 
To make your diagram larger or smaller you can use
 
To make your diagram larger or smaller you can use
  
Line 431: Line 436:
 
draw(rightanglemark(A,B,C,1.5));
 
draw(rightanglemark(A,B,C,1.5));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#14 Tick Marks]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#14 Tick Marks'''
 
'''#14 Tick Marks'''
 
+
<div class="mw-collapsible-content">
 
If you want to add tick marks to a line use
 
If you want to add tick marks to a line use
  
Line 473: Line 478:
 
add(pathticks(A--B, 2, spacing=1, s=2));
 
add(pathticks(A--B, 2, spacing=1, s=2));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#15 Arrows]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#15 Arrows'''
 
'''#15 Arrows'''
 
+
<div class="mw-collapsible-content">
 
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 492: Line 497:
 
draw(A--C, MidArrow(size=0.2cm));
 
draw(A--C, MidArrow(size=0.2cm));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#16 Shifting Coordinates]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#16 Shifting Coordinates'''
 
'''#16 Shifting Coordinates'''
 
+
<div class="mw-collapsible-content">
 
(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 505: Line 510:
 
return  (p.x,p.y + amount);
 
return  (p.x,p.y + amount);
 
}</code>
 
}</code>
[/hide]
+
</div></div>
[hide=#17 Rotating]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#17 Rotating'''
 
'''#17 Rotating'''
 
+
<div class="mw-collapsible-content">
 
(Source: nosaj and Zhaom)
 
(Source: nosaj and Zhaom)
 
Maybe if you really wanted to: rotate
 
Maybe if you really wanted to: rotate
Line 515: Line 520:
 
</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.
[/hide]
+
</div></div>
[hide=#18 Circles]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#18 Circles'''
 
'''#18 Circles'''
 
+
<div class="mw-collapsible-content">
 
If you want to draw a circle use
 
If you want to draw a circle use
  
Line 537: Line 542:
 
draw(Circle((0,0),0.4),p=green+1.5bp);
 
draw(Circle((0,0),0.4),p=green+1.5bp);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#19 Dashed Lines]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#19 Dashed Lines'''
 
'''#19 Dashed Lines'''
 
+
<div class="mw-collapsible-content">
 
(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 560: Line 565:
 
dot(B);
 
dot(B);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#20 Angle Mark]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#20 Angle Mark'''
 
'''#20 Angle Mark'''
 
+
<div class="mw-collapsible-content">
 
(Source: Zhaom & mag1c)
 
(Source: Zhaom & mag1c)
 
To make an actual angle mark:
 
To make an actual angle mark:
Line 587: Line 592:
 
dot("A",A,SW*0.5);
 
dot("A",A,SW*0.5);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#21 "for" command]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#21 "for" Command'''
 
'''#21 "for" Command'''
 
+
<div class="mw-collapsible-content">
 
(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 612: Line 617:
 
</asy></code>
 
</asy></code>
 
[/hide]
 
[/hide]
[/hide]
+
</div></div>
[hide=#22 Extension]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#22 Extension'''
 
'''#22 Extension'''
 
+
<div class="mw-collapsible-content">
 
If you want to extend a line you can use this
 
If you want to extend a line you can use this
  
Line 663: Line 668:
  
 
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>.
[/hide]
+
</div></div>
[hide=#23 How to draw an equilateral triangle]
+
<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">
 
In #23 we'll walkthrough how to make an equilateral triangle.
 
In #23 we'll walkthrough how to make an equilateral triangle.
  
Line 731: Line 736:
 
</asy>
 
</asy>
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#24 How to draw an isosceles triangle]
+
<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">
 
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 792: Line 797:
 
</asy>
 
</asy>
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#25 How to draw a scalene triangle]
+
<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">
 
In #25 we'll walkthrough how to make a scalene triangle.
 
In #25 we'll walkthrough how to make a scalene triangle.
  
Line 831: Line 836:
 
</asy>
 
</asy>
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#26 Labeling Angles]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#26 Labeling Angles'''
 
'''#26 Labeling Angles'''
 
+
<div class="mw-collapsible-content">
 
(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 850: Line 855:
 
label("$60^\circ$",(0.1,0.1),E);
 
label("$60^\circ$",(0.1,0.1),E);
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#27 Drawing triangles using SSS, SAS, AAS, and ASA]
+
<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">
 
(Source: Zhaom)
 
(Source: Zhaom)
 
drawing triangles:
 
drawing triangles:
Line 919: Line 924:
 
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].
[/hide]
+
</div></div>
[hide=#28 Arcs]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#28 Arcs'''
 
'''#28 Arcs'''
 
+
<div class="mw-collapsible-content">
 
(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 946: Line 951:
 
</asy>
 
</asy>
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#29 The Nine Point Circle]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#29 The Nine Point Circle'''
 
'''#29 The Nine Point Circle'''
 
+
<div class="mw-collapsible-content">
 
(Source: Zhaom)
 
(Source: Zhaom)
 
The nine point circle:
 
The nine point circle:
Line 1,001: Line 1,006:
 
</asy>[/hide]
 
</asy>[/hide]
 
The center is N and the radius is r/2.
 
The center is N and the radius is r/2.
[/hide]
+
</div></div>
[hide=#30 Pair part 2]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#30 Pair Part 2'''
 
'''#30 Pair Part 2'''
 
+
<div class="mw-collapsible-content">
 
(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,031: Line 1,036:
 
label("$B$", A[2], S);
 
label("$B$", A[2], S);
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#31 Finding the midpoint]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#31 Finding the midpoint'''
 
'''#31 Finding the midpoint'''
 
+
<div class="mw-collapsible-content">
 
(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,050: Line 1,055:
 
dot(midpoint(A--B));
 
dot(midpoint(A--B));
 
</asy>
 
</asy>
[/hide]
+
</div></div>
[hide=#32 Foot command]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#32 Foot Command'''
 
'''#32 Foot Command'''
 
+
<div class="mw-collapsible-content">
 
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,091: Line 1,096:
 
</asy>
 
</asy>
 
</code>
 
</code>
[/hide]
+
</div></div>
[hide=#33 Introduction to 3D Geometry]
+
<div class="mw-collapsible mw-collapsed" style="width:100%">
 
'''#33 Introduction to 3D Geometry'''
 
'''#33 Introduction to 3D Geometry'''
 
+
<div class="mw-collapsible-content">
 
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.
  

Revision as of 11:15, 2 June 2022

Asymptote tutorial for AoPS

Expand

The Name Asymptote

Expand

Tips

Expand

#1 Beginning your code

Expand

#2 Setting points

Expand

#3 Pair part 1

Expand

#4 Connecting two points, coloring the line

Expand

#5 Labeling, Midpoint

Expand

#6 Angle Measures

Expand

#7 Distance Function

Expand

#8 Casting

Expand

#9 Right Angle Mark

Expand

#10 Intersection

Expand

#11 Filling

Expand

#12 Dot

Expand

#13 Size

Expand

#14 Tick Marks

Expand

#15 Arrows

Expand

#16 Shifting Coordinates

Expand

#17 Rotating

Expand

#18 Circles

Expand

#19 Dashed Lines

Expand

#20 Angle Mark

Expand

#21 "for" Command

Expand

#22 Extension

Expand

#23 How to draw an equilateral triangle

Expand

#24 How to draw an isosceles triangle

Expand

#25 How to draw a scalene triangle

Expand

#26 Labeling Angles

Expand

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

Expand

#28 Arcs

Expand

#29 The Nine Point Circle

Expand

#30 Pair Part 2

Expand

#31 Finding the midpoint

Expand

#32 Foot Command

Expand

#33 Introduction to 3D Geometry