Difference between revisions of "User:Azjps/geogebra"
m (→Functions and Integrals) |
(+) |
||
Line 10: | Line 10: | ||
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | ||
</asy> | </asy> | ||
− | Support for drawing | + | Support for drawing different options of points, along with point labeling. |
<asy> | <asy> | ||
Line 19: | Line 19: | ||
dot((-5,0),ds); label("$A$",(-4.92,0.12),NE*lsf); label("$B$",(-3.92,0.12),NE*lsf); label("$C$",(-2.92,0.12),NE*lsf); label("$D$",(-1.92,0.12),NE*lsf); label("$E$",(-0.92,0.12),NE*lsf); label("$F$",(0.08,0.12),NE*lsf); label("$G$",(1.08,0.12),NE*lsf); label("$H$",(2.08,0.12),NE*lsf); label("$I$",(3.08,0.12),NE*lsf); label("$J$",(4.08,0.12),NE*lsf); dot((5,0),linewidth(1pt)+ds); label("$K$",(5.08,0.04),NE*lsf); dot((-5,1),ds); label("$L$",(-4.92,1.12),NE*lsf); label("$M$",(-3.92,1.12),NE*lsf); label("$N$",(-2.92,1.12),NE*lsf); label("$O$",(-1.92,1.12),NE*lsf); label("$P$",(-0.92,1.12),NE*lsf); label("$Q$",(0.08,1.12),NE*lsf); label("$R$",(1.08,1.12),NE*lsf); label("$S$",(2.08,1.12),NE*lsf); label("$T$",(3.08,1.12),NE*lsf); label("$U$",(4.08,1.12),NE*lsf); dot((5,1),ds); label("$V$",(5.08,1.12),NE*lsf); dot((-5,2),ds); dot((5,2),linewidth(5pt)+ds); label("$I_1$",(5.08,2.2),NE*lsf); dot((-5,3),ds); dot((-5,4),ds); dot((-5,3.5),ds); dot((-4,3),ds); dot((-4,4),ds); | dot((-5,0),ds); label("$A$",(-4.92,0.12),NE*lsf); label("$B$",(-3.92,0.12),NE*lsf); label("$C$",(-2.92,0.12),NE*lsf); label("$D$",(-1.92,0.12),NE*lsf); label("$E$",(-0.92,0.12),NE*lsf); label("$F$",(0.08,0.12),NE*lsf); label("$G$",(1.08,0.12),NE*lsf); label("$H$",(2.08,0.12),NE*lsf); label("$I$",(3.08,0.12),NE*lsf); label("$J$",(4.08,0.12),NE*lsf); dot((5,0),linewidth(1pt)+ds); label("$K$",(5.08,0.04),NE*lsf); dot((-5,1),ds); label("$L$",(-4.92,1.12),NE*lsf); label("$M$",(-3.92,1.12),NE*lsf); label("$N$",(-2.92,1.12),NE*lsf); label("$O$",(-1.92,1.12),NE*lsf); label("$P$",(-0.92,1.12),NE*lsf); label("$Q$",(0.08,1.12),NE*lsf); label("$R$",(1.08,1.12),NE*lsf); label("$S$",(2.08,1.12),NE*lsf); label("$T$",(3.08,1.12),NE*lsf); label("$U$",(4.08,1.12),NE*lsf); dot((5,1),ds); label("$V$",(5.08,1.12),NE*lsf); dot((-5,2),ds); dot((5,2),linewidth(5pt)+ds); label("$I_1$",(5.08,2.2),NE*lsf); dot((-5,3),ds); dot((-5,4),ds); dot((-5,3.5),ds); dot((-4,3),ds); dot((-4,4),ds); | ||
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | ||
− | </asy> Also includes an option to remove the coloring of just points (to avoid Geogebra's default of using different colors for different classes of points). | + | </asy> Also includes an option to remove the coloring of just points (to avoid Geogebra's default of using different colors for different classes of fixed points). |
Line 41: | Line 41: | ||
xaxis("$\theta$",-7.3,8.06,linewidth(1.2),Ticks(laxis,xlbl,Step=3.141592653589793,Size=2),Arrows(6),above=true); yaxis(-1.44,5.2,linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); real f1(real x){return 2+2*cos(2*x+pi);} draw(graph(f1,-7.29,8.05),linewidth(1.6)+ttqqzz); label("$2 + 2 \cos(2x + \pi)$",(-7.14,4.1),NE*lsf,ttqqzz); | xaxis("$\theta$",-7.3,8.06,linewidth(1.2),Ticks(laxis,xlbl,Step=3.141592653589793,Size=2),Arrows(6),above=true); yaxis(-1.44,5.2,linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); real f1(real x){return 2+2*cos(2*x+pi);} draw(graph(f1,-7.29,8.05),linewidth(1.6)+ttqqzz); label("$2 + 2 \cos(2x + \pi)$",(-7.14,4.1),NE*lsf,ttqqzz); | ||
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | ||
− | </asy> | + | </asy> Allows most functions and can draw integrals and Riemman-like sums. Above, the function is given by <math>f(x) = 2+2cos(2x)</math>; the four shaded regions are drawn using the commands '''Integral[f,-2pi,-pi], LowerSum[f,-pi,0,5], UpperSum[f,0,pi,5],''' and '''TrapezoidalSum[f,pi,2pi,5]'''. |
<geogebra>6636ccd3479762307d932c319db7ec1998236a4c</geogebra> | <geogebra>6636ccd3479762307d932c319db7ec1998236a4c</geogebra> | ||
Known bugs: | Known bugs: | ||
Line 57: | Line 57: | ||
dot((0,0),ds); dot((1,0),ds); dot((-3.34,0.08),ds); dot((-2.28,1.58),ds); dot((-3.4,2.72),ds); dot((-0.94,0.34),ds); dot((2.72,0.58),ds); dot((4.54,0.52),ds); dot((0.68,4.86),ds); | dot((0,0),ds); dot((1,0),ds); dot((-3.34,0.08),ds); dot((-2.28,1.58),ds); dot((-3.4,2.72),ds); dot((-0.94,0.34),ds); dot((2.72,0.58),ds); dot((4.54,0.52),ds); dot((0.68,4.86),ds); | ||
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | ||
− | </asy> | + | </asy> Allows lines, rays, vectors (not shown), and the different conic sections (which includes circle arcs and sectors), including different line colors, line types, line sizes, and in some cases, fill colors. Lines and rays automatically re-scale to fit the entire window when the diagram size is changed. |
<geogebra>f475aec9be4bbeb0d7a8b525fb2cbbe905383c5d</geogebra> | <geogebra>f475aec9be4bbeb0d7a8b525fb2cbbe905383c5d</geogebra> | ||
Line 73: | Line 73: | ||
for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); draw((0,0)--(2,0),zzttqq); draw((2,0)--(3.41,1.41),zzttqq); draw((3.41,1.41)--(3.41,3.41),zzttqq); draw((3.41,3.41)--(2,4.83),zzttqq); draw((2,4.83)--(0,4.83),zzttqq); draw((0,4.83)--(-1.41,3.41),zzttqq); draw((-1.41,3.41)--(-1.41,1.41),zzttqq); draw((-1.41,1.41)--(0,0),zzttqq); draw(arc((2,0),0.6,0.79,pi),qqwuqq); draw(arc((2,0),0.5,0.79,pi),qqwuqq); draw(arc((-1.41,1.41),0.6,-45,85.38),qqwuqq,BeginArcArrow(6)); draw(arc((-1.41,3.41),0.6,-90,40.38),qqwuqq,EndArcArrow(6)); draw(arc((0,4.83),0.6,-2.36,0),qqwuqq); draw((0.21,4.33)--(0.25,4.22),qqwuqq); draw((0.14,4.31)--(0.17,4.19),qqwuqq); draw((0.27,4.36)--(0.33,4.26),qqwuqq); draw(arc((2,4.83),0.6,pi,5.5),qqwuqq); draw((1.73,4.36)--(1.67,4.26),qqwuqq); draw((1.86,4.31)--(1.83,4.19),qqwuqq); draw(arc((3.41,3.41),0.6,2.36,4.71),qqwuqq); draw((2.92,3.21)--(2.8,3.16),qqwuqq); draw(arc((3.41,1.41),0.6,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.5,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.4,1.57,3.93),qqwuqq); draw((0,0)--(2,0),EndArrow(6)); | for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); draw((0,0)--(2,0),zzttqq); draw((2,0)--(3.41,1.41),zzttqq); draw((3.41,1.41)--(3.41,3.41),zzttqq); draw((3.41,3.41)--(2,4.83),zzttqq); draw((2,4.83)--(0,4.83),zzttqq); draw((0,4.83)--(-1.41,3.41),zzttqq); draw((-1.41,3.41)--(-1.41,1.41),zzttqq); draw((-1.41,1.41)--(0,0),zzttqq); draw(arc((2,0),0.6,0.79,pi),qqwuqq); draw(arc((2,0),0.5,0.79,pi),qqwuqq); draw(arc((-1.41,1.41),0.6,-45,85.38),qqwuqq,BeginArcArrow(6)); draw(arc((-1.41,3.41),0.6,-90,40.38),qqwuqq,EndArcArrow(6)); draw(arc((0,4.83),0.6,-2.36,0),qqwuqq); draw((0.21,4.33)--(0.25,4.22),qqwuqq); draw((0.14,4.31)--(0.17,4.19),qqwuqq); draw((0.27,4.36)--(0.33,4.26),qqwuqq); draw(arc((2,4.83),0.6,pi,5.5),qqwuqq); draw((1.73,4.36)--(1.67,4.26),qqwuqq); draw((1.86,4.31)--(1.83,4.19),qqwuqq); draw(arc((3.41,3.41),0.6,2.36,4.71),qqwuqq); draw((2.92,3.21)--(2.8,3.16),qqwuqq); draw(arc((3.41,1.41),0.6,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.5,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.4,1.57,3.93),qqwuqq); draw((0,0)--(2,0),EndArrow(6)); | ||
dot((0,0),ds); dot((2,0),ds); dot((3.41,1.41),ds); dot((3.41,3.41),ds); dot((2,4.83),ds); dot((0,4.83),ds); dot((-1.41,3.41),ds); dot((-1.41,1.41),ds); label("$135^\circ$",(2.64,0.12),NE*lsf,qqwuqq); label("$135^\circ$",(0.28,0.78),NE*lsf,qqwuqq); label("$135^\circ$",(-1.1,2.06),NE*lsf,qqwuqq); label("$135^\circ$",(-0.72,3.28),NE*lsf,qqwuqq); label("$135^\circ$",(-1,4.68),NE*lsf,qqwuqq); label("$135^\circ$",(2.2,4.8),NE*lsf,qqwuqq); label("$135^\circ$",(3.38,3.64),NE*lsf,qqwuqq); label("$135^\circ$",(3.5,1.58),NE*lsf,qqwuqq); | dot((0,0),ds); dot((2,0),ds); dot((3.41,1.41),ds); dot((3.41,3.41),ds); dot((2,4.83),ds); dot((0,4.83),ds); dot((-1.41,3.41),ds); dot((-1.41,1.41),ds); label("$135^\circ$",(2.64,0.12),NE*lsf,qqwuqq); label("$135^\circ$",(0.28,0.78),NE*lsf,qqwuqq); label("$135^\circ$",(-1.1,2.06),NE*lsf,qqwuqq); label("$135^\circ$",(-0.72,3.28),NE*lsf,qqwuqq); label("$135^\circ$",(-1,4.68),NE*lsf,qqwuqq); label("$135^\circ$",(2.2,4.8),NE*lsf,qqwuqq); label("$135^\circ$",(3.38,3.64),NE*lsf,qqwuqq); label("$135^\circ$",(3.5,1.58),NE*lsf,qqwuqq); | ||
− | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); </asy> | + | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); </asy> Allows certain transparent fills. There are four possible options allowed for fill colors: |
* No fills. Self-explanatory. | * No fills. Self-explanatory. | ||
Line 79: | Line 79: | ||
* With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums. | * With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums. | ||
* By layering (example above). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions. | * By layering (example above). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions. | ||
+ | |||
Polygons and angles, by default, will have transparent fill colors. Both have support for different line colors and fill colors (with different transparencies, colors, line sizes, etc). Angles include several different styles, including multiple arcs, tick marks, and arc arrows. | Polygons and angles, by default, will have transparent fill colors. Both have support for different line colors and fill colors (with different transparencies, colors, line sizes, etc). Angles include several different styles, including multiple arcs, tick marks, and arc arrows. | ||
<geogebra>008edd5949bd2386cd1b9a7b223f16e44cbaf28c</geogebra> | <geogebra>008edd5949bd2386cd1b9a7b223f16e44cbaf28c</geogebra> | ||
Line 114: | Line 115: | ||
dot((1,0),xdxdff); dot((1,2),blue); dot((-0.66,0.82),blue); dot((1,1.85),uququq); dot((2.28,1.34),xdxdff); dot((1,-1.85),uququq); dot((2.48,1.85),uququq); dot((2.48,1.34),uququq); | dot((1,0),xdxdff); dot((1,2),blue); dot((-0.66,0.82),blue); dot((1,1.85),uququq); dot((2.28,1.34),xdxdff); dot((1,-1.85),uququq); dot((2.48,1.85),uququq); dot((2.48,1.34),uququq); | ||
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); | ||
− | </asy> | + | </asy> Locus constructions with all of the usual lines options. Shown above is the "witch of aggensi". |
<geogebra>d2594993982afff858b6296678b2bab7bbe351d8</geogebra> | <geogebra>d2594993982afff858b6296678b2bab7bbe351d8</geogebra> | ||
+ | |||
+ | Comment: Can create huge files. | ||
Known bugs: none. | Known bugs: none. | ||
Line 133: | Line 136: | ||
<geogebra>9fa91fc57b9e5def39d73828270c8c027c565d85</geogebra> | <geogebra>9fa91fc57b9e5def39d73828270c8c027c565d85</geogebra> | ||
+ | |||
+ | == Options == | ||
+ | An outline of the different available options. | ||
+ | |||
+ | (The first three options are related and automatically update with respect to eath other). | ||
+ | |||
+ | '''X/Y Units (cm)''': Indicates how many units in the picture correspond to 1 centimeter. | ||
+ | |||
+ | '''Picture width/height''': Indicates what size the Asymptote output should be, in centimeters. | ||
+ | |||
+ | '''xmin/xmax/ymin/ymax''': Indicates the dimensions of the picture in the picture's coordinates. | ||
+ | |||
+ | (The next options change other features). | ||
+ | |||
+ | '''Font size''': Changes the default font size. The value defaults at 10pt, but I personally recommend 7pt for any file with multiple text lines, which more closely approximates the size of the font in the Geogebra window. | ||
+ | |||
+ | '''Fill type''': This includes four options as to how Geogebra elements with different fill colors should be implemented: | ||
+ | |||
+ | * None: No fills are drawn. | ||
+ | * Only opaque fills. This will only cause filled objects with opaque transparencies, which are arbitrarily defined as shapes with transparency alpha values greater than 0.9 (on a 0 to 1, 1 being fully opaque, scale), to appear filled. | ||
+ | * With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums. | ||
+ | * By layering (my personal preference). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions. | ||
+ | |||
+ | '''Concise code''': This produces shorter Asymptote code. Some of the changes between non-concise and concise code: | ||
+ | |||
+ | * In non-concise code, most new commands have their own line. In concise code, there are at most about 8 lines of code. | ||
+ | * Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth). | ||
+ | * Pen colors are produced with a single line of pen declarations. | ||
+ | * Functions are re-used where possible. | ||
+ | * Less spacing. | ||
+ | |||
+ | The advantages of concise code: | ||
+ | |||
+ | * Less code to examine. | ||
+ | * Non-concise code will usually not render on the AoPS forums due to size limits. | ||
+ | * Guide to customizing code should be in the following posts. | ||
+ | |||
+ | The disadvantages of concise code: | ||
+ | |||
+ | * More difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing. | ||
+ | * No documentation comments. | ||
+ | * Difficult to read through from given code window, requires wrap-around to read effectively. | ||
+ | |||
+ | '''Concise with cse5''': There is also a cse5 option that allows the code to be further compactified with help with the cse5 package (see the stickies in this forum). | ||
+ | |||
+ | * In non-concise code, most new commands have their own line. In cse5 code, there are at most about 8 lines of code. | ||
+ | * Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth). | ||
+ | * Pairs are given names and produced in a single line; color pens are also produced in a single line. | ||
+ | * Functions are re-used where possible. | ||
+ | * Command shortcuts, such as MP() and D() are used extensively. | ||
+ | * Almost no spacing. | ||
+ | |||
+ | The advantages of cse5 code: | ||
+ | |||
+ | * Less code to examine. | ||
+ | * With the exception of excessively complicated diagrams, will almost always fit within AoPS size restrictions. | ||
+ | * Guide to customizing code should be in the following posts. | ||
+ | * Allows more customization; changing a declared point and pen will reflect changes across the code. | ||
+ | |||
+ | The disadvantages of cse5 code: | ||
+ | |||
+ | * Extremely difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing and short commands. | ||
+ | * No documentation comments. | ||
+ | * Difficult to read through from given code window, requires wrap-around to read effectively. | ||
+ | * May occasionally draw skinny points and lines, due to default pathpen and pointpen attributes. | ||
+ | |||
+ | My personal recommendation is the concise code for producing quick sketches (cse5 for large quick sketches), and the non-concise code otherwise. | ||
+ | |||
+ | '''Grayscale''': Uses monochromatic scale to produce all output. | ||
+ | |||
+ | '''Show Axes/Grid''' (default checked): Show or hide the axes and the grid. | ||
+ | |||
+ | '''Keep dot colors''': Geogebra defaults free points to a blue color and semi-fixed points to a light blue color. Without this option checked, the Asymptote code will automatically set points to the default color (black). With checked, the Asymptote code will include the point colors as shown in the Geogebra window. | ||
+ | |||
+ | |||
+ | == Documentation == |
Revision as of 22:12, 20 June 2010
Gallery of examples: The following Asymptote codes were all generated from Geogebra files (File > Export > Graphics View as Asymptote ...).
Contents
Points
Support for drawing different options of points, along with point labeling.
Also includes an option to remove the coloring of just points (to avoid Geogebra's default of using different colors for different classes of fixed points).
<geogebra>1c89b124bb471a351bc108d34f8096d1f892e012</geogebra>
Also has support for different types of axes: bold, with arrows, different colors, different labelling schemes (including with labels as in the next example). Also supports drawing of grid (with for loop constructions). There is a checkbox option to show and hide axes and grids.
Known bugs:
- Labels may be displaced more from points than shown in Geogebra window. This is not really a bug but a font problem, since Asymptote will write the labels in LaTeX, which has a different size from normal text. The recommended solution is to decrease the font size to fontsize(8) or fontsize(7).
- In cse5 mode, certain dots will appear smaller (default pointpen nature of cse5).
Functions and Integrals
Allows most functions and can draw integrals and Riemman-like sums. Above, the function is given by ; the four shaded regions are drawn using the commands Integral[f,-2pi,-pi], LowerSum[f,-pi,0,5], UpperSum[f,0,pi,5], and TrapezoidalSum[f,pi,2pi,5].
<geogebra>6636ccd3479762307d932c319db7ec1998236a4c</geogebra>
Known bugs:
- May capitalize certain functions (like trigonometric functions). Please let me know if this happens.
- Certain functions recognized by Geogebra might not be recognized by Asymptote.
- Integrals/Sums drawn over functions that reach undefined values (ex, at ) will cause a break when drawn in Asymptote (unlikely to be fixed); drawing the functions themselves will work, however.
- With certain very contrived function strings, it is possible to break the code (won't fix).
- Sometimes will render LaTeX commands in function strings. Please let me know if this happens.
Lines and Conics
import graph; size(11.6cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-5.06,xmax=6.54,ymin=-3.4,ymax=5.54; pen qqzztt=rgb(0,0.6,0.2), qqqqzz=rgb(0,0,0.6), ffqqtt=rgb(1,0,0.2);draw(circle((0,0),1),linewidth(2.8));draw((0,0)--(1,0)); draw((0,ymin)--(0,ymax)); draw((xmin,(-(3.19)-(1.03)*xmin)/3.02)--(xmax,(-(3.19)-(1.03)*xmax)/3.02)); draw((xmin,(-(-3.19)-(-0.88)*xmin)/3.06)--(xmax,(-(-3.19)-(-0.88)*xmax)/3.06)); draw(shift((-2.81,0.83))*rotate(54.75)*xscale(2.12)*yscale(1.91)*unitcircle,linewidth(1.6)+linetype("2pt 8pt 10pt 8pt")+qqzztt);pair hl1(real t){return (0.53*(1+t^2)/(1-t^2),0.74*2*t/(1-t^2));} pair hr1(real t){return (0.53*(-1-t^2)/(1-t^2),0.74*(-2)*t/(1-t^2));} draw(shift((3.63,0.55))*rotate(178.11)*graph(hl1,-0.99,0.99),linewidth(1.6)+linetype("4pt 4pt")+qqqqzz); draw(shift((3.63,0.55))*rotate(178.11)*graph(hr1,-0.99,0.99),linewidth(1.6)+linetype("4pt 4pt")+qqqqzz); real p1(real x){return x^2/2/3.48;} draw(shift((1.16,3.19))*rotate(16.04)*graph(p1,-13.93,13.93),linewidth(2)+ffqqtt); dot((0,0),ds); dot((1,0),ds); dot((-3.34,0.08),ds); dot((-2.28,1.58),ds); dot((-3.4,2.72),ds); dot((-0.94,0.34),ds); dot((2.72,0.58),ds); dot((4.54,0.52),ds); dot((0.68,4.86),ds); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); (Error making remote request. Unknown error_msg)
Allows lines, rays, vectors (not shown), and the different conic sections (which includes circle arcs and sectors), including different line colors, line types, line sizes, and in some cases, fill colors. Lines and rays automatically re-scale to fit the entire window when the diagram size is changed.
<geogebra>f475aec9be4bbeb0d7a8b525fb2cbbe905383c5d</geogebra>
Known bugs:
- Circle fills and sectors fills do not work.
Filled objects
import graph; size(9.7cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-3.58,xmax=6.12,ymin=-1.1,ymax=6.1; pen cqcqcq=rgb(0.75,0.75,0.75), fueaev=rgb(0.96,0.92,0.9), zzttqq=rgb(0.6,0.2,0), evefev=rgb(0.9,0.94,0.9), qqwuqq=rgb(0,0.39,0); filldraw((0,0)--(2,0)--(3.41,1.41)--(3.41,3.41)--(2,4.83)--(0,4.83)--(-1.41,3.41)--(-1.41,1.41)--cycle,fueaev,zzttqq); filldraw(arc((2,0),0.6,45,180)--(2,0)--cycle,evefev,qqwuqq); filldraw(arc((0,0),0.6,0,135)--(0,0)--cycle,evefev,qqwuqq); filldraw(arc((-1.41,1.41),0.6,-45,90)--(-1.41,1.41)--cycle,evefev,qqwuqq); filldraw(arc((-1.41,3.41),0.6,-90,45)--(-1.41,3.41)--cycle,evefev,qqwuqq); filldraw(arc((0,4.83),0.6,-135,0)--(0,4.83)--cycle,evefev,qqwuqq); filldraw(arc((2,4.83),0.6,180,315)--(2,4.83)--cycle,evefev,qqwuqq); filldraw(arc((3.41,3.41),0.6,135,270)--(3.41,3.41)--cycle,evefev,qqwuqq); filldraw(arc((3.41,1.41),0.6,90,225)--(3.41,1.41)--cycle,evefev,qqwuqq); /*grid*/ pen gs=linewidth(0.7)+cqcqcq+linetype("2pt 2pt"); real gx=1,gy=1; for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); draw((0,0)--(2,0),zzttqq); draw((2,0)--(3.41,1.41),zzttqq); draw((3.41,1.41)--(3.41,3.41),zzttqq); draw((3.41,3.41)--(2,4.83),zzttqq); draw((2,4.83)--(0,4.83),zzttqq); draw((0,4.83)--(-1.41,3.41),zzttqq); draw((-1.41,3.41)--(-1.41,1.41),zzttqq); draw((-1.41,1.41)--(0,0),zzttqq); draw(arc((2,0),0.6,0.79,pi),qqwuqq); draw(arc((2,0),0.5,0.79,pi),qqwuqq); draw(arc((-1.41,1.41),0.6,-45,85.38),qqwuqq,BeginArcArrow(6)); draw(arc((-1.41,3.41),0.6,-90,40.38),qqwuqq,EndArcArrow(6)); draw(arc((0,4.83),0.6,-2.36,0),qqwuqq); draw((0.21,4.33)--(0.25,4.22),qqwuqq); draw((0.14,4.31)--(0.17,4.19),qqwuqq); draw((0.27,4.36)--(0.33,4.26),qqwuqq); draw(arc((2,4.83),0.6,pi,5.5),qqwuqq); draw((1.73,4.36)--(1.67,4.26),qqwuqq); draw((1.86,4.31)--(1.83,4.19),qqwuqq); draw(arc((3.41,3.41),0.6,2.36,4.71),qqwuqq); draw((2.92,3.21)--(2.8,3.16),qqwuqq); draw(arc((3.41,1.41),0.6,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.5,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.4,1.57,3.93),qqwuqq); draw((0,0)--(2,0),EndArrow(6)); dot((0,0),ds); dot((2,0),ds); dot((3.41,1.41),ds); dot((3.41,3.41),ds); dot((2,4.83),ds); dot((0,4.83),ds); dot((-1.41,3.41),ds); dot((-1.41,1.41),ds); label("$135^\circ$",(2.64,0.12),NE*lsf,qqwuqq); label("$135^\circ$",(0.28,0.78),NE*lsf,qqwuqq); label("$135^\circ$",(-1.1,2.06),NE*lsf,qqwuqq); label("$135^\circ$",(-0.72,3.28),NE*lsf,qqwuqq); label("$135^\circ$",(-1,4.68),NE*lsf,qqwuqq); label("$135^\circ$",(2.2,4.8),NE*lsf,qqwuqq); label("$135^\circ$",(3.38,3.64),NE*lsf,qqwuqq); label("$135^\circ$",(3.5,1.58),NE*lsf,qqwuqq); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); (Error making remote request. Unknown error_msg)
Allows certain transparent fills. There are four possible options allowed for fill colors:
- No fills. Self-explanatory.
- Opaque fills only. This will only cause filled objects with opaque transparencies, which are arbitrarily defined as shapes with transparency alpha values greater than 0.9 (on a 0 to 1, 1 being fully opaque, scale), to appear filled.
- With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums.
- By layering (example above). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions.
Polygons and angles, by default, will have transparent fill colors. Both have support for different line colors and fill colors (with different transparencies, colors, line sizes, etc). Angles include several different styles, including multiple arcs, tick marks, and arc arrows.
<geogebra>008edd5949bd2386cd1b9a7b223f16e44cbaf28c</geogebra>
Known bugs:
- Non re-sized arc arrows.
- Overlapping transparency color problems.
Text
import graph; size(11.58cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-4.3,xmax=7.28,ymin=-2.64,ymax=6.3; pen cqcqcq=rgb(0.75,0.75,0.75), qqccqq=rgb(0,0.8,0), ccqqtt=rgb(0.8,0,0.2); /*grid*/ pen gs=linewidth(0.7)+cqcqcq+linetype("3pt 3pt"); real gx=1,gy=1; for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); Label laxis; laxis.p=fontsize(10); xaxis(-4.3,7.28,defaultpen+black,Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); yaxis(-2.64,6.3,defaultpen+black,Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); label("abc",(-3,5.24),SE*lsf); label("a2 b3 c3 o pi e infty otimes sqrt(x)",(-3,4.24),SE*lsf); label("$\parbox{1.4 cm}{abc \\ def \\ ghi}$",(-3,3.24),SE*lsf); label("$ \sqrt{ abc } $",(-3,2.24),SE*lsf); label("$abc \\ def$",(-3,1.24),SE*lsf); label("$abc$",(-3,0.24),SE*lsf); label("$\alpha\beta\gamma$",(-3,-0.76),SE*lsf); label("alpha beta gamma ",(-3,-1.76),SE*lsf); label("\textit{\textbf{abc}}",(0,5.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{\textbf{alpha beta gamma }}",(0,-1.76),SE*lsf,qqccqq+fontsize(12)); label("$\mathit{\mathbf{ \alpha\beta\gamma }}$",(0,-0.76),SE*lsf,ccqqtt+fontsize(12)); label("\textit{\textbf{$abc$}}",(0,0.24),SE*lsf,qqccqq+fontsize(12)); label("$\mathit{\mathbf{ abcdef }}$",(0,1.24),SE*lsf,ccqqtt+fontsize(12)); label("$\mathit{\mathbf{ \sqrt{ abc } }}$",(0,2.24),SE*lsf,ccqqtt+fontsize(12)); label("$\parbox{1.5 cm}{\textit{\textbf{abc \\ def \\ ghi}}}$",(0,3.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{\textbf{a2 b3 co pi e infty otimes sqrt(x)}}",(0,4.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{abc}",(3,5.24),SE*lsf,fontsize(8)); label("$\parbox{1.34 cm}{\textit{abc \\ def \\ ghi}}$",(3,3.24),SE*lsf,fontsize(8)); label("$\mathit{ \sqrt{ abc } }$",(3,2.24),SE*lsf,fontsize(8)); label("$\mathit{abcdef}$",(3,1.24),SE*lsf,fontsize(8)); label("\textit{$abc$}",(3,0.24),SE*lsf,fontsize(8)); label("\textit{alpha beta gamma }",(3,-1.76),SE*lsf,fontsize(8)); label("$\mathit{ \alpha\beta\gamma }$",(3,-0.76),SE*lsf,fontsize(8)); label("pi e infty otimes questeq ne le ge neg wedge vee parallel perp in subseteq subset cong equiv measuredangle triangle ",(3,4.24),SE*lsf); dot((-3,0),ds); dot((-3,1),ds); dot((-3,2),ds); dot((-3,3),ds); dot((-3,4),ds); dot((-3,5),ds); dot((0,5),ds); dot((0,4),ds); dot((0,3),ds); dot((0,2),ds); dot((0,1),ds); dot((0,0),ds); dot((0,-1),ds); dot((-3,-1),ds); dot((-3,-2),ds); dot((0,-2),ds); dot((3,5),ds); dot((3,4),ds); dot((3,3),ds); dot((3,2),ds); dot((3,1),ds); dot((3,0),ds); dot((3,-1),ds); dot((3,-2),ds); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); (Error making remote request. Unknown error_msg)
Supports most text options, including different font styles, bold, italics, and .
<geogebra>087e142af582ed87e10a11362584f7ced9b606bd</geogebra>
Known bugs:
- Including text strings with dollar signs will convert it to LaTeX. An odd number of dollar signs in a text string will usually cause an error (working on for strings).
- Certain contrived strings will break the code (may never be fixed).
- Fontsize might not be correct occasionally, especially for cse5 commands. (working on)
Locus construction
Locus constructions with all of the usual lines options. Shown above is the "witch of aggensi".
<geogebra>d2594993982afff858b6296678b2bab7bbe351d8</geogebra>
Comment: Can create huge files.
Known bugs: none.
Statistics
Full example
import graph; size(13.92cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); real xmin=-0.72,xmax=3.2,ymin=-1.81,ymax=1.35; pen ffqqcc=rgb(1,0,0.8), uququq=rgb(0.25,0.25,0.25), evefev=rgb(0.9,0.94,0.9), qqwuqq=rgb(0,0.39,0), evffff=rgb(0.9,1,1), qqffff=rgb(0,1,1); filldraw(arc((2.69,-1.5),0.16,134.59,180)--(2.69,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((2,-0.8),0.16,-113.2,-90)--(2,-0.8)--cycle,evefev,qqwuqq); filldraw(arc((2,-1.5),0.16,0,90)--(2,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((1.7,-1.5),0.16,0,66.8)--(1.7,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,157.5,180)--(1.31,0)--cycle,evefev,qqwuqq); filldraw(arc((0.38,0),0.16,0,90)--(0.38,0)--cycle,evefev,qqwuqq); filldraw(arc((2.23,0),0.16,90,180)--(2.23,0)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,0,22.5)--(1.31,0)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,22.5,112.5)--(1.31,0)--cycle,evffff,qqffff); filldraw(arc((0,0),0.16,0,45)--(0,0)--cycle,evffff,qqffff); draw((xmin,(-(0)-(0)*xmin)/1)--(xmax,(-(0)-(0)*xmax)/1)); draw(circle((0,0),1.31),linetype("4pt 4pt")+blue);draw(circle((1.31,0),1),linetype("4pt 4pt")+red);draw((0.92,0.92)--(0,0),linewidth(1.6)); draw((0,0)--(1.31,0),linewidth(1.6)); draw((0.92,0.92)--(1.31,0),linewidth(1.6)); draw((1.31,0)--(2.23,0.38),linewidth(1.6)); draw((2.23,0.38)--(0.92,0.92),linewidth(1.6)); draw((0.38,0.38)--(2.23,0.38),ffqqcc); draw((0,0)--(2.23,0.38),ffqqcc); draw((2.23,0.38)--(2.23,0),dotted); draw((0,0.38)--(0,0),dotted); draw((0,0.38)--(0.38,0.38),dotted); draw((0.38,0.38)--(0.38,0.38),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(0,0),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(1.31,0),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(1.31,0),linewidth(1.2)+linetype("1pt 1pt")); draw((2.69,-1.5)--(2,-0.8)); draw((2,-0.8)--(1.7,-1.5)); draw((1.7,-1.5)--(2.69,-1.5)); draw((2,-0.8)--(2,-1.5)); label("$r $",(2.69,-1.84),SE*lsf); label("r",(2.3,-1.39),SE*lsf); label("$ r\sqrt{ 2 } $",(2.75,-1.24),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(2.02,-1.85),SE*lsf); label("$45^\circ$",(2.41,-1.3),SE*lsf); label("$22.5^\circ$",(2.02,-0.96),SE*lsf); draw(circle((2.07,-1.43),0.01),qqwuqq); label("$90^\circ$",(2.15,-1.3),SE*lsf); label("$67.5^\circ$",(1.79,-1.28),SE*lsf); label("$22.5^\circ$",(0.84,0.1),SE*lsf); label("r",(0.71,-0.06),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(0.27,0.35),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.05,-0.12),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.09,0.63),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.44,0.31),SE*lsf); draw(circle((0.45,0.07),0.01),qqwuqq); label("$90^\circ$",(0.6,0.1),SE*lsf); draw(circle((2.16,0.07),0.01),qqwuqq); label("$90^\circ$",(2.31,0.17),SE*lsf); label("$22.5^\circ$",(1.64,0.11),SE*lsf); label("r",(2.04,-0.09),SE*lsf); draw((1.4,-0.2)--(1.11,0.17),EndArrow(6));label("$ \sqrt{ (r (\sqrt{ 2 } - 1) + r + r )^2 + (r (\sqrt{ 2 } - 1) )^2 }$",(1.58,-0.2),SE*lsf); label("$ = \sqrt{ (r (\sqrt{ 2 } + 1) )^2 + (r (\sqrt{ 2 } - 1) )^2 } $",(1.53,-0.37),SE*lsf); label("$\mathbf{=r \sqrt{ 6 }}$",(1.53,-0.72),SE*lsf,blue); label("$= \sqrt{ r^2 (3 + 2 \sqrt{ 2 }) + r^2 (3 - 2 \sqrt{ 2 }) } $",(1.53,-0.54),SE*lsf); label("$\mathbf{2r}$",(1.46,0.64),SE*lsf,blue); label("$\mathbf{\frac{BE}{AE} = \frac{r \sqrt{ 6 }}{2r} = \frac{ \sqrt{ 6 }}{2}}$",(0.78,-1.47),SE*lsf,red+fontsize(14)); draw((1.74,-1.13)--(0.83,-0.06),EndArrow(6));draw(circle((1.34,0.09),0.01),qqffff); label("$45^\circ$",(-0.01,0.13),SE*lsf); label("$90^\circ$",(-0.22,1.47),SE*lsf); label("$90^\circ$",(1.39,0.24),SE*lsf); draw((0.38,0)--(0.38,0.38),linewidth(0.4)+dotted); dot((0,0),blue); label("$B$",(-0.06,-0.09),NE*lsf,blue); dot((1.31,0),blue); label("$D$",(1.34,-0.09),NE*lsf,blue); dot((0.92,0.92),blue); label("$C$",(0.91,0.99),NE*lsf,blue); dot((2.23,0.38),blue); label("$E$",(2.27,0.39),NE*lsf,blue); dot((0.38,0.38),blue); label("$A$",(0.33,0.41),NE*lsf,blue); dot((0.38,0),linewidth(1pt)+uququq); label("$G$",(0.41,-0.1),NE*lsf,uququq); dot((0,0.38),linewidth(1pt)+uququq); dot((2.23,0),linewidth(1pt)+uququq); label("$F$",(2.24,-0.1),NE*lsf,uququq); dot((0.38,0.38),uququq); dot((1.7,-1.5),blue); dot((2,-0.8),blue); dot((2.69,-1.5),blue); dot((2,-1.5),blue); clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); (Error making remote request. Unknown error_msg)
Courtesy of User:Kouichi Nakagawa.
<geogebra>9fa91fc57b9e5def39d73828270c8c027c565d85</geogebra>
Options
An outline of the different available options.
(The first three options are related and automatically update with respect to eath other).
X/Y Units (cm): Indicates how many units in the picture correspond to 1 centimeter.
Picture width/height: Indicates what size the Asymptote output should be, in centimeters.
xmin/xmax/ymin/ymax: Indicates the dimensions of the picture in the picture's coordinates.
(The next options change other features).
Font size: Changes the default font size. The value defaults at 10pt, but I personally recommend 7pt for any file with multiple text lines, which more closely approximates the size of the font in the Geogebra window.
Fill type: This includes four options as to how Geogebra elements with different fill colors should be implemented:
- None: No fills are drawn.
- Only opaque fills. This will only cause filled objects with opaque transparencies, which are arbitrarily defined as shapes with transparency alpha values greater than 0.9 (on a 0 to 1, 1 being fully opaque, scale), to appear filled.
- With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums.
- By layering (my personal preference). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions.
Concise code: This produces shorter Asymptote code. Some of the changes between non-concise and concise code:
- In non-concise code, most new commands have their own line. In concise code, there are at most about 8 lines of code.
- Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth).
- Pen colors are produced with a single line of pen declarations.
- Functions are re-used where possible.
- Less spacing.
The advantages of concise code:
- Less code to examine.
- Non-concise code will usually not render on the AoPS forums due to size limits.
- Guide to customizing code should be in the following posts.
The disadvantages of concise code:
- More difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing.
- No documentation comments.
- Difficult to read through from given code window, requires wrap-around to read effectively.
Concise with cse5: There is also a cse5 option that allows the code to be further compactified with help with the cse5 package (see the stickies in this forum).
- In non-concise code, most new commands have their own line. In cse5 code, there are at most about 8 lines of code.
- Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth).
- Pairs are given names and produced in a single line; color pens are also produced in a single line.
- Functions are re-used where possible.
- Command shortcuts, such as MP() and D() are used extensively.
- Almost no spacing.
The advantages of cse5 code:
- Less code to examine.
- With the exception of excessively complicated diagrams, will almost always fit within AoPS size restrictions.
- Guide to customizing code should be in the following posts.
- Allows more customization; changing a declared point and pen will reflect changes across the code.
The disadvantages of cse5 code:
- Extremely difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing and short commands.
- No documentation comments.
- Difficult to read through from given code window, requires wrap-around to read effectively.
- May occasionally draw skinny points and lines, due to default pathpen and pointpen attributes.
My personal recommendation is the concise code for producing quick sketches (cse5 for large quick sketches), and the non-concise code otherwise.
Grayscale: Uses monochromatic scale to produce all output.
Show Axes/Grid (default checked): Show or hide the axes and the grid.
Keep dot colors: Geogebra defaults free points to a blue color and semi-fixed points to a light blue color. Without this option checked, the Asymptote code will automatically set points to the default color (black). With checked, the Asymptote code will include the point colors as shown in the Geogebra window.