Skip to content

Documentation

CJ Quines edited this page May 21, 2016 · 3 revisions

Structure

TSQX code consists of two parts:

  • Point declarations
  • Drawing commands

Single-line comments start with //, multi-line comments start with /* and end with */.

Pairs and paths

A pair is a sequence of two real numbers, representing a point, 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)/2 and we can double the coordinates of P by writing 2*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 in A--B--C, which contains segments AB and BC, or A--B--C--cycle which contains segments AB, BC, CA.

Point declaration

name [:|.|;]= expression [R direction]

Declares the point with the label name as the pair expression.

  • label can be any string that works in LaTeX math-mode.
  • [:|.|;]= is the assignment operator. The regular = both labels and dots the point. (If the --soft-label argument is given, the regular = only labels the point.) The := operator neither labels nor dots the point. The .= operator dots the point without labelling it. The ;= operator does one of two things: ** If --soft-label is given, it both labels and dots the point. ** Otherwise, it labels the point without dotting it.
  • expression is a pair, or any function that returns a pair.
  • [R direction] (optional) is the direction of the label, where direction is an angle in degrees. Default is dir(label), where label is the point itself.

Drawing commands

expression [[opacity] fillcolor /] [linestyle] [outlinecolor]

Draws the expression expression.

  • expression is a path, any function that returns a path, or any function that draws.
  • [opacity] (optional) is the opacity of the fill, where opacity is a number from 0 to 1.
  • [fillcolor /] (optional) is the color of the fill. Default is black.
  • [linestyle] (optional) is the line style of the outline.
  • [outlinecolor] (optional) is the color of the outline. Default is black.

Functions

name[n] arguments

Calls the function name with arguments arguments.

  • name is the name of the function. Some functions have short names, in these cases, the short name can be substituted for the function name.
  • [n] (optional) is used for function overloading: it forces the function to accept n arguments instead of the usual number.
  • arguments is a space-separated list of arguments for the function.

Functions that return pairs:

  • dir A returns the point on the unit circle A degrees from 0.
  • midpoint P returns the midpoint of path P.
  • intersect P Q returns the intersection of paths P and Q, if it exists.
  • IP P Q returns the first intersection of paths P and Q using cse5.
    • Overloaded with three arguments, IP3 P Q R returns the Rth intersection of paths P and Q.
  • OP P Q returns the second intersection of paths P and Q using cse5.
  • extension A B C D returns 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 C returns the circumcenter of triangle ABC.
  • orthocenter A B C returns the orthocenter of triangle ABC.
  • incenter A B C returns the incenter of triangle ABC.
  • centroid A B C returns the centroid of triangle ABC.
  • bisectorpoint A B returns a point on the perpendicular bisector of segment AB a unit distance from AB.
    • Overloaded with three arguments, bisectorpoint3 A B C returns a point on the angle bisector of angle ABC a unit distance from B.
  • tangent A B C returns the Cth tangent from A to circle B.

Functions that return paths:

  • incircle A B C returns the incircle of triangle ABC.
  • circumcircle A B C returns the circumcircle of triangle ABC. (short name circle A B C)
  • CP A B returns the circle with center A passing through B.
  • CR A B returns the circle with center A and radius B.
  • Line A B returns the line joining A and B.
  • arc A B C D returns the arc, centered at A through B, from C degrees to D degrees.

Functions for drawing:

  • anglemark A B C draws an angle mark at angle ABC.
    • Overloaded with four arguments, anglemark4 A B C D draws an angle mark of size D at angle ABC.
  • rightanglemark A B C draws a right angle mark at angle ABC. (short name rightangle A B C)
    • Overloaded with four arguments, rightanglemark4 A B C D draws a right angle mark of size D at angle ABC. (short name rightangle4 A B C D)
  • pathticks A B draws B tick marks on path A.

Presets

~name points

Assigns the points points to the preset named name.

  • name is the name of the preset.
  • points is a space-separated list of points, assigned in sequence.

Presets:

  • triangle A B C assigns to ABC points of an acute triangle, A = dir 110, B = dir 210, C = dir 330. (other name acute A B C)
  • obtuse A B C assigns to ABC points of a triangle obtuse angled at A, A = dir 100, B = dir 170, C = dir 10.
  • isosceles A B C assigns to ABC points of an isosceles triangle with vertex A, A = dir 90, B = dir 230, C = dir 310.
  • equilateral A B C assigns to ABC points of an equilateral triangle, A = dir 90, B = dir 210, C = dir 330.
  • triangle A B C assigns to ABC points of an acute triangle, A = dir 110, B = dir 210, C = dir 330.
  • cyclicquad A B C D assigns to ABCD points of a cyclic quadrilateral, A = dir 150, B = dir 200, C = dir 340, D = dir 70. (other name quadrilateral A B C D, though if anyone has any suggestions for non-cyclic quadrilateral points, do contact me)
  • regular A B C ... assigns to ABC... points of a regular n-gon, where n is the number of points given. (other name cyclic A B C..., if anyone has a better way to generate cyclic n-gons, do contact me)
Clone this wiki locally