-
Notifications
You must be signed in to change notification settings - Fork 4
Documentation
Read a TSQX file from input.txt and output Asymptote code into output.asy.
tsqx < input.txt > output.asy
Command line arguments:
-
--pre,-padds an Asymptote preamble. The preamble includes importing olympiad and cse5, both of which are important for lots of TSQX functions. -
--size,-sif provided, sets the image size in the preamble. Default size is 8cm. -
--soft-label,-bregular=does not dot points, only labels them. -
fnameif provided, reads from the designated file rather than stdin.
A TSQX file consists of a series of commands, separated by newlines. There are three kinds of TSQX commands:
- Point declarations
- Drawing commands
- Special commands
There are also end-of-line comments, which begin with #.
name [direction] [:|.|;|d?l?]= expression
Declares the point with the label name as the pair expression.
-
name. Point name. -
direction. Optional string for label direction, e.g.NEfor north-east of the point,150fordir(150), or2S3Efor2*S + 3*E. -
[:|.|;|d?l?]=. Controls whether the point is dotted or labeled.dmakes the point dotted andlmakes it labeled. The other symbols are aliases; the default ones are
| No dot | Has dot | |
|---|---|---|
| No label | := |
.= or d=
|
| Has label |
;= or l=
|
= or ld=
|
-
expression. An expression that returns a point.
expression [/ [fillpens /] outlinepens]
Draws the expression expression.
-
expression. An expression that returns a point. -
fillpens. Pens that determine the fill, e.g.0.2 lightbluebecomesopacity(0.2)+lightblue. -
outlinepens. Pens that determine the opacity, e.g.dotted blackbecomesdotted+black.
Special commands are abbreviations for several commands. The special commands are:
-
~triangle A B C. Assign to ABC points of an acute triangle,A = dir 110,B = dir 210,C = dir 330. -
~regular A B C .... Assigns to ABC... points of a regular polygon.
Expressions operate on points and paths:
-
A point is a pair of two real numbers, written in the code as
(x, y), where x and y are the x- and y-coordinates of the point respectively. Pairwise operations can be done on pairs, so the midpoint of segment AB would be(A+B)/2and we can double the coordinates of P by writing2*P. -
A path is any sequence of lines or curves. The segment joining two points A and B is written as
A--B. Segments can be chained, as inA--B--C, which contains segments AB and BC, orA--B--C--cyclewhich contains segments AB, BC, CA.
Expressions in TSQX are written as in a Lisp. So for example, circumcircle A (foot B C D) E produces circumcircle(A, foot(B, C, D), E). It's also possible to use comma-separated syntax, and to use space-separated syntax within it, e.g. circumcircle(A, (foot B C D), E) also works.
For convenience, although TSQX supports all Asymptote functions, here are the functions you're likely to use most often.
Functions that return pairs:
-
dir Areturns the point on the unit circle A degrees from 0. -
midpoint Preturns the midpoint of path P. -
intersect P Qreturns the intersection of paths P and Q, if it exists. -
IP P Qreturns the first intersection of paths P and Q using cse5. With three arguments,IP P Q Rreturns the Rth intersection of paths P and Q. -
OP P Qreturns the second intersection of paths P and Q using cse5. -
extension A B C Dreturns the intersection of the lines AB and CD. - `foot A B C`` returns the foot of the perpendicular from A to line BC.
-
circumcenter A B Creturns the circumcenter of triangle ABC. -
orthocenter A B Creturns the orthocenter of triangle ABC. -
incenter A B Creturns the incenter of triangle ABC. -
centroid A B Creturns the centroid of triangle ABC. -
bisectorpoint A Breturns a point on the perpendicular bisector of segment AB a unit distance from AB. With three arguments,bisectorpoint A B Creturns a point on the angle bisector of angle ABC a unit distance from B. -
tangent A B Creturns the Cth tangent from A to circle B.
Functions that return paths:
-
incircle A B Creturns the incircle of triangle ABC. -
circumcircle A B Creturns the circumcircle of triangle ABC. -
CP A Breturns the circle with center A passing through B. -
CR A Breturns the circle with center A and radius B. -
Line A Breturns the line joining A and B. -
arc A B C Dreturns the arc, centered at A through B, from C degrees to D degrees.
Functions for drawing:
-
anglemark A B Cdraws an angle mark at angle ABC. With four arguments,anglemark A B C Ddraws an angle mark of size D at angle ABC. -
rightanglemark A B Cdraws a right angle mark at angle ABC. With four arguments,rightanglemark A B C Ddraws a right angle mark of size D at angle ABC. -
pathticks A Bdraws B tick marks on path A.