Command |
Purpose and Examples |
point(x, y) |
Example:- point(3, 4) or A=point(3, 4) where A is the label. |
line(x1, y1, x2, y2) |
Example:- line(0,0,-2,5) or C=line(A, B) where A, B are point labels. Length can be optionally given as line(A, B, 3) where 3 is length of segment. |
arc(originPoint, radius, angleFrom, upto) |
Example:- arc(point(2, 2), 3, 40, 20)Uses point(2, 2) as origin, 3 as radius and starts the arc from 40 degrees adding another 20 degree in an anticlockwise direction. A negative value for "upto" parameter will move clockwise. To copy a line, give the first parameter as line or two points as shown here arc(point1, point2, originPoint, angleFrom, upto) |
perp(line, passThroughPoint, length=10) |
Example:- A=perp(line(1, 2, 3, 4), point(1, 2)) draws a perpendicular line to a given line(1, 2, 3, 4) passing through point(1, 2). The last optional parameter of perp command is the length of the perpendicular line which defaults to 10 |
parallel(line, passThroughPoint, length=10) |
Example:- parallel(line(1, 2, 3, 4), point(1, 2)) |
angle(point1, point2, degrees) |
Example:- angle(A, B, 45, 1) The two points A and B defines the base line.The ratio is an optional parameter which controls the position of the protractor. A value of 0 places it at A, 1 at B and 0.5 in the middle. |
polygon(comma separated points) |
Example:- polygon(A, B, C) draws a triangle where A, B, C are points |
findangle(2 lines or a polygon) |
Example:- findangle(A, B) finds the angle between two lines A, B or a polygon findangle(C) (C is the label of polygon, in this case the method returns the first angle) |
fill(A, B) |
Fills the interior of shapes A,B.The shapes can be an arc, polygon or another fill. The command accepts any number of shapes. fill(A), fill(arc(0, 0, 3, 0, 360), D, polygon(2, 3, 4, 6, 1, 0)) |
trace(comma separated points) |
Traces the curve passing through the given points. trace(point(0, 0), point(1, sin(30)), point(1, sin(60)), point(1, sin(120)), B) |
part(shape to extract from, 2 points on shape, optional part Index) |
Example:- part(a,D,E,2) or
A=part(a,intersect(a,b,1), point(2,3)) where A is the label of the shape to take part from.
The shape 'a' in the example refers to a polygon or line or arc. The 2 points given after the shape needs to be on
the shape (ie if it is arc, then the point must be on arc's perimeter, the same is true for polygon, the
points must be on one of the lines of the polygon. The part command extracts 2 shapes, so we can specify an optional
partIndex (either 1 or 2) and the point to get the desired part as shown here.
part(a,intersect(a,b,1), point(2,3), 2) The last value 2 extracts the second part.
You can only give either 1 or 2 as part index.
The returned part which is stored in 'A' can then be used
to build further complex shape used for tessllations. For example
polygon(2,4,6,7,A,10,12) In this example
a new polygon will be created by using points 2,4,6,7 and points from the 'A' part commands that follow them
|
fade(labels of shape, fade factor) |
Example:- fade(a,D,E, 0.4) The fade factor(last) value which must be between 0 to 1
which controls how much the objects should fade in or out |
pointtype('cross') |
Example:- pointtype('cross') Changes the point style from 'sphere' to 'cross'.
Any point command after this pointtype command will render a cross, if we want to go back to 'sphere' just
put another pointtype() command without any values |
dash(x1, y1, x2, y2, dashLength, dashGapLength) |
Example:- dash(3,4,7,8,0.5,0.6) Draws a dashed line, the
5th argument controls the dash length and 0.6 (the last value) controls the gap.
Using these 2 values we can draw dotted lines as well. Like other robocompass commands, instead of giving 4 values directly, we can either give a 2
points or any expression that resolves to 4 coordinates similar to dash(A, C, 1.2, 0.5)
where A, C are point labels
|
stroke(labels of shape, thickness) |
Example:- stroke(a,D,E, 3) Changes the thickness of
the shapes refered by the labels. The thickness must be greater than 0 and there is no upper limit |
reverse(labels of shape) |
Example:- reverse(a) Reverses the coordinates of the shape. This will be
useful in building complex tessellations. Generally used inside polygon(reverse(L), 3,7,8,1) ,
The L here could be a part or a line or any shape. You can also give more than one shape as argument |
plot("expression") |
Example:- plot("sin(x)") or
A=plot("tan(x)",2,10) where A is the label.
The min and max values after expression are optional
By default the plot covers the entire graphsheet area.
As in other functions, variables can be defined elsewhere and refereed inside the expression. All geometric
transformations like rotate,translate,dilate and clipping operations (and, or) can be performed on the resultant plot.
Implicit equations such as "x^2+y^2=r^2 are not supported. However you can
give equations such as "y=2*x" or "x=2y". |
para("expression1","expression2") |
Example:- para("2*sin(t)","3*cos*(t)")
or A=para("2*sin(t)","3*cos*(t)",0,6.29,0.1) where A is the label.
The expressions must have "t" as parameter.
The min and max and step values after expressions are optional.
pos command can be used to get a point at a particular point in graph like pos(p,0.2)
where p is p=plot("some exp") or p=para("some exp")
|
General rule |
Whenever a point is expected in an expression, use either point(2, 3), its label or a helper command which calculates and returns a point. Similarly wherever a line is expected give the label of a line or the label of two points. For example arc(A, B, point(2, 1), 50, 40) uses the distance from A to B and draws the arc from point(2, 1).
Note:- instead of point(2, 1) use 'C' if there is a point labeled C. |