Difference between revisions of "Asymptote: Olympiad Package Part 1"

(Created page with '{{Asymptote}} Sometimes, you don't want to write the coordinate (3.5,6.2) over and over and over again. Thus, the olympiad package is a lifesaver. Let's look at this simple bit …')
 
 
Line 2: Line 2:
  
 
Sometimes, you don't want to write the coordinate (3.5,6.2) over and over and over again. Thus, the olympiad package is a lifesaver. Let's look at this simple bit of code: (Note, the import olympiad command is not needed on the forum).
 
Sometimes, you don't want to write the coordinate (3.5,6.2) over and over and over again. Thus, the olympiad package is a lifesaver. Let's look at this simple bit of code: (Note, the import olympiad command is not needed on the forum).
 +
 +
<pre><nowiki>
 +
import olympiad;
 +
real r=2.5, a=3.5;
 +
dot((r,a));
 +
</nowiki></pre>
 +
 +
<asy>
 +
import olympiad;
 +
real r=2.5, a=3.5;
 +
dot((r,a));
 +
</asy>
 +
 +
Or something like:
  
 
<pre><nowiki>
 
<pre><nowiki>

Latest revision as of 00:48, 7 January 2010

Asymptote (Vector Graphics Language)
Getting Started - Basics - Drawing - Reference - Examples - Macros and Packages - Advanced Asymptote - 3D Graphics - Help

Useful functions - CSE5 Package - How to

Sometimes, you don't want to write the coordinate (3.5,6.2) over and over and over again. Thus, the olympiad package is a lifesaver. Let's look at this simple bit of code: (Note, the import olympiad command is not needed on the forum).

import olympiad;
real r=2.5, a=3.5;
dot((r,a));

[asy] import olympiad; real r=2.5, a=3.5; dot((r,a)); [/asy]

Or something like:

import olympiad;
pair A=origin, B=(3,0), C=(3,2), D=(0,2);
draw(A--B--C--D--cycle);

[asy] import olympiad; pair A=origin, B=(3,0), C=(3,2), D=(0,2); draw(A--B--C--D--cycle); [/asy]

(Note that the origin is the point (0,0)).

Now let's go even farther:

import olympiad;
pair A=origin, B=(3,0), C=(3,2), D=(0,2);
path p=A--B--C--D--cycle;
draw(p);

[asy] import olympiad; pair A=origin, B=(3,0), C=(3,2), D=(0,2); path p=A--B--C--D--cycle; draw(p); [/asy]

At the moment, this does nothing to shorten our code. However, in this bit:

import olympiad;
pair A=origin, B=(3,0), C=(3,2), D=(0,2);
path p=A--B--C--D--cycle;
draw(p);
draw(shift(3.5,0)*p);
draw(shift(7,0)*p);

[asy] import olympiad; pair A=origin, B=(3,0), C=(3,2), D=(0,2); path p=A--B--C--D--cycle; draw(p); draw(shift(3.5,0)*p); draw(shift(7,0)*p); [/asy]

the code works nicely. Without defining the path, the code would have been much longer.

Invalid username
Login to AoPS