Difference between revisions of "Asymptote: CSE5"

(expand)
m
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Asymptote}}
 
{{Asymptote}}
The Asymptote '''CSE5''' package is a useful package that is supported on the AoPS forum. It is much larger than most other packages, and contains doubles of each function; a function with a full name and a function with an abbreviated name.
+
The Asymptote '''CSE5''' package is another package that is supported on the AoPS forum. You can download it [http://www.artofproblemsolving.com/Forum/viewtopic.php?t=149650  here]. The original idea for writing CSE5 was to enable writing terse codes for complicated pictures. Also some commands in CSE5 (like '''IP()''') work slightly better than the standard Asymptote routines in some cases (the typical example is finding the intersection point of a circle and a tangent line). At last, CSE5 allows to handle some runtime errors like an attempt to find an intersection point of two paths without common points, which may be useful if you try to draw a picture just from its verbal description and do not want to make any calculations beforehand.
 +
CSE5 contains doubles of each function; a function with a full name and a function with an abbreviated name.  
 
==Function List==
 
==Function List==
=== Mark Angle ( MA ) ===
+
<pre>
  function MA ( pair A, real t1, real t2, label L, color C )
+
MarkPoint          ( MP  );
 +
MarkCurve          ( MC  );
 +
MarkAngle          ( MA );
 +
Drawing            ( D  );
 +
DrawPathArray      ( DPA );
 +
IntersectionPoint ( IP  );
 +
OtherPoint        ( OP  );
 +
IntersectionPoints ( IPs );
 +
WayPoint          ( WP  );
 +
Line              ( L   );
 +
CirclebyRadius    ( CR  );
 +
CirclebyPoint      ( CP  );
 +
CopyClean          ( CC  );
 +
</pre>
  
This function marks an angle around point <math>A</math>, starting at angle <math>t1</math> degrees (<math>0</math> is the horizontal Ox axis, if the coordinate system would be centered in <math>A</math>), up to angle <math>t2</math>, with label <math>L</math> ("<nowiki>$\frac{\pi}{3}$</nowiki>" for example is a good value for this parameter), and color <math>C</math> (options are: <math>g</math> (gray), <math>lb</math> (light blue)).
+
==Function descriptions==
 +
=== MarkAngle ( MA ) ===
 +
pair MA(real a,Label s,int f,pen p,pair B,pair A,pair C,real r,int m,pair P,pen q)
 +
 
 +
The '''MA()''' or '''MarkAngle()''' command is a competitor of the olympiad '''anglemark()'''. The usage is
 +
'''MA(''' ''a,s,f,p'','''B,A,C,r''',''m,S,q'' ''')'''
 +
(the necessary arguments are bold and the optional ones are italic). Here
 +
 
 +
''a'' is the angle by which you want to rotate the label in degrees (0 by default);
 +
 
 +
''s'' is the string labelling the angle (empty string by default); the dollar (or now rather \(...\)) delimeters will be added automatically as in other cse5 labelling commands;
 +
 
 +
''f'' is the fontsize for your label (currently 9 by default; can be also reset by the '''anglefontsize=...''' command);
 +
 
 +
''p'' is the pen you wish to use for the label (red by default; can be also reset by the '''anglefontpen=...''' command);
 +
 
 +
'''B,A,C''' are the pairs determining the angle <math>\angle BAC</math> with the vertex <math>A</math>. The arcs are drawn counterclockwise from the side <math>AB</math> to the side <math>AC</math>;
 +
 
 +
'''r''' the radius of the largest arc in the anglemark;
 +
 
 +
''m'' the number of arcs in the anglemark (<math>1</math> by default). Can be set to <math>0</math>, in which case no arcs will be drawn, <math>1</math> through <math>7</math>, in which case <math>m</math> arcs will be drawn, and anything <math>>7</math> in which case the sector will be filled with color;
 +
 
 +
''S'' allows you to position the label manually with respect to the middle point of the largest arc. The automatic positioning is where you, probably, want it to be the most: on the bisector of the angle right beyond the largest arc in the anglemark.
 +
 +
''q'' is the pen used for drawing the arcs or filling the sector (green by default; can be also reset by the '''anglepen=...''' command).
 +
 
 +
'''MA()''' returns the vertex of the angle.
 +
 
 +
Example of usage:
 +
<pre>
 +
size(200);
 +
pair A=dir(-40), B=dir(0);
 +
for(int k=0;k<9;++k)
 +
{
 +
pair C=dir(40*(k+1));
 +
D(A--D(MA(k*40+90,"\beta_{"+string(k)+"}",12,black,C,B,A,0.1,k,orange))--C);
 +
A=B;B=C;
 +
}
 +
</pre>  
 +
results in
 +
<asy>
 +
size(200);
 +
pair A=dir(-40), B=dir(0);
 +
for(int k=0;k<9;++k)
 +
{
 +
pair C=dir(40*(k+1));
 +
D(A--D(MA(k*40+90,"\beta_{"+string(k)+"}",12,black,C,B,A,0.1,k,orange))--C);
 +
A=B;B=C;
 +
}
 +
</asy>
  
 
== See Also ==
 
== See Also ==
*<url>viewtopic.php?t=149650 Description of the package</url> by [[AoPS]] user [[User:fedja|fedja]].
+
*https://artofproblemsolving.com/community/c68h149650 Description of the package by [[AoPS]] user [[User:fedja|fedja]].

Revision as of 14:09, 30 June 2020

Asymptote (Vector Graphics Language)
Getting Started - Basics - Drawing - Labeling - Filling - Useful functions - Examples - Macros and Packages

Help - Reference - Advanced Asymptote - 3D Graphics - CSE5 Package - How to

The Asymptote CSE5 package is another package that is supported on the AoPS forum. You can download it here. The original idea for writing CSE5 was to enable writing terse codes for complicated pictures. Also some commands in CSE5 (like IP()) work slightly better than the standard Asymptote routines in some cases (the typical example is finding the intersection point of a circle and a tangent line). At last, CSE5 allows to handle some runtime errors like an attempt to find an intersection point of two paths without common points, which may be useful if you try to draw a picture just from its verbal description and do not want to make any calculations beforehand. CSE5 contains doubles of each function; a function with a full name and a function with an abbreviated name.

Function List

MarkPoint          ( MP  );
MarkCurve          ( MC  );
MarkAngle          ( MA  );
Drawing            ( D   );
DrawPathArray      ( DPA );
IntersectionPoint  ( IP  );
OtherPoint         ( OP  );
IntersectionPoints ( IPs );
WayPoint           ( WP  );
Line               ( L   );
CirclebyRadius     ( CR  );
CirclebyPoint      ( CP  );
CopyClean          ( CC  );

Function descriptions

MarkAngle ( MA )

pair MA(real a,Label s,int f,pen p,pair B,pair A,pair C,real r,int m,pair P,pen q)

The MA() or MarkAngle() command is a competitor of the olympiad anglemark(). The usage is MA( a,s,f,p,B,A,C,r,m,S,q ) (the necessary arguments are bold and the optional ones are italic). Here

a is the angle by which you want to rotate the label in degrees (0 by default);

s is the string labelling the angle (empty string by default); the dollar (or now rather \(...\)) delimeters will be added automatically as in other cse5 labelling commands;

f is the fontsize for your label (currently 9 by default; can be also reset by the anglefontsize=... command);

p is the pen you wish to use for the label (red by default; can be also reset by the anglefontpen=... command);

B,A,C are the pairs determining the angle $\angle BAC$ with the vertex $A$. The arcs are drawn counterclockwise from the side $AB$ to the side $AC$;

r the radius of the largest arc in the anglemark;

m the number of arcs in the anglemark ($1$ by default). Can be set to $0$, in which case no arcs will be drawn, $1$ through $7$, in which case $m$ arcs will be drawn, and anything $>7$ in which case the sector will be filled with color;

S allows you to position the label manually with respect to the middle point of the largest arc. The automatic positioning is where you, probably, want it to be the most: on the bisector of the angle right beyond the largest arc in the anglemark.

q is the pen used for drawing the arcs or filling the sector (green by default; can be also reset by the anglepen=... command).

MA() returns the vertex of the angle.

Example of usage:

size(200);
pair A=dir(-40), B=dir(0);
for(int k=0;k<9;++k)
{
pair C=dir(40*(k+1));
D(A--D(MA(k*40+90,"\beta_{"+string(k)+"}",12,black,C,B,A,0.1,k,orange))--C);
A=B;B=C;
}

results in [asy] size(200); pair A=dir(-40), B=dir(0); for(int k=0;k<9;++k) { pair C=dir(40*(k+1)); D(A--D(MA(k*40+90,"\beta_{"+string(k)+"}",12,black,C,B,A,0.1,k,orange))--C); A=B;B=C; } [/asy]

See Also