Show label:
Label offset:
X : Y :
RoboCompass has 10 drawing commands and 12 helper commands. Drawing commands can be assigned labels and referenced in other commands.
In effect, these commands can be combined in creative ways to produce all sorts of Geometrical constructions.
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) |
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).
|
point(x,y)
A=point(3,4)line(x1,y1,x2,y2)
line(0,0,-2,5)arc(originPoint,radius,angleFrom,upto)
arc(point1,point2,originPoint,angleFrom,upto)
perp(line,passThroughPoint,length=10)
A=perp(line(1,2,3,4),point(1,2))
perp(A,B)
parallel(line,passThroughPoint,length=10)
parallel(line(1,2,3,4),point(1,2))
parallel(A,B)angle(point1,point2,degrees)
angle(point(2,0),point(6,0),45)
angle(A,B,90,1)polygon(comma separated points)
polygon(point(2,2),point(4,2),point(3,5))
polygon(A,B,C)findangle(2 lines or a polygon)
findangle(A,B)fill(A,B,fillType=0,output=1)
fill(A)trace(comma separated points)
trace(point(0,0),point(1,sin(30)),point(1,sin(60)),point(1,sin(120)),B)plot(math expression,min?,max?)
plot("sin(x)")para(expression1,expression2,min?,max?)
para("2*sin(t)","2*cos(t)",0,6.29,0.1)Command |
Purpose and Examples |
---|---|
dist(point1, point2) | Calculates the distance between two points. Give a dist(C)if C is a line (i.e. segment) |
X(point) | Gives the X coordinate of a point A. A= X(point(2,1)) |
Y(point) | Gives the Y coordinate of a point A. B= Y(point(1,2)) |
pos(polygon or line or arc, index) | Returns the point at a given index. If a polygon A has 4 points, pos(A, 3) returns the third point, Similarly if a line's label is B a index of 2 returns the end point. Example:- pos(B, 2) |
intersect(object1, object2, index=1) | Intersects any two objects (except points).Example G=point(intersect(D, E)) By default returns the first intersecting point, for second and third intersecting point, give 2 or 3 respectively. For example this intersect(D, E, 2) gives the second intersecting point. |
reflect(object, line) | Reflects the object by a given line. Example:- reflect(D, A) where D is the label of point to reflect and A is the reflecting line |
rotate(object, angle, withrespectTo=point(0, 0)) | Rotates the object by a given degree. By default, the rotation is with respect to origin (0, 0), which can be optionally overridden by giving the parameter withrespectPoint. |
translate(object, x, y, withrespectTo=point(0, 0)) | Translates the object by given x, y with respect to origin or by given withRespectTo parameter. translate(arc(2, 3, 3, 0, 180), 2, 3, point(2, 1)) or translate(G, 2, 4) |
dilate(object, scaleFactor, withRespectTo=point(0, 0)) | Dilates the object by a given scaleFactor parameter.dilate(point(3, 1), 2) |
project(point1, line) | Projects the input point on the line and returns the projected point. Example:-project(A, line(0, 0, 1, 0)) projects the point A on the given line. |
interpolate(point1, point2, ratio) | Example:- interpolate(A, B, 0.5) A ratio of 0.5 returns the midpoint of A, B |
hide(comma separated labels) | Example:- hide(A, B, C, D) hides objects A, B, C, D. To show again use show(A, B, C, D) |
group(comma separated objects) | Transformations can be applied on multiple objects simultaneously by creating a group. For example to rotate both a arc 'A' and a polygon 'B' together, use C=group(A, B) and then D=rotate(C, 120) where C is the label of the group. Groups can also be nested. |
Boolean operations - and, or, diff | A variety of shapes can be created by applying Boolean operations on simple shapes. These shapes can be tessellated by transformation commands. For example and(A, B, C) creates a polygonal region common (intersection) to A, B, C where A, B, C can be an arc or a polygon. Similarly, or(A, E, polygon(0, 0, 2, 3, 4, 1)) and diff(A, B) create union and difference of the given regions respectively. Regions with interior holes are not supported (resulting from an xor operation), but the same result can be created by combining multiple polygons using the group command. |
text("String") text("String", x-coordinate, y-coordinate) | Example: text("Hello World!") Example: text("Hello World!", 3, 3) |
Note: |
dist(point1, point2)
dist(point(2,1),point(1,2))X(point)
A=X(point(2,1))
X(A)Y(point)
B=Y(point(1,2))
Y(A)pos(polygon or line or arc,index)
pos(B,2)intersect(object1,object2,index=1)
G=point(intersect(D,E))
intersect(D,E,2)reflect(object,line)
reflect(point(2,2),line(4,0,4,4))
reflect(D,A)rotate(object,angle,withrespectTo=point(0,0))
rotate(point(2,2),90,point(0,0))
rotate(D,30,A)translate(object,x,y,withrespectTo=point(0,0))
translate(arc(2,3,3,0,180),2,3,point(2,1))
translate(G,2,4)dilate(object,scaleFactor,withRespectTo=point(0,0))
dilate(point(3,1),2)
dilate(M,0.5,point(8,0))project(point1,line)
project(point(2,2),line(0,0,1,0))
project(A,line(0,0,1,0))interpolate(point1,point2,ratio)
interpolate(point(0,0),point(10,0),0.3)
interpolate(A,B,0.5)hide(comma separated labels)
hide(A,B,C,D)
show(A,B,C,D)group(comma separated objects)
C=group(A,B)
m=group(a,b,c,d)and(comma separated objects)
and(A,B,C)or(comma separated objects)
or(A,E,polygon(0,0,2,3,4,1))diff(comma separated objects)
diff(A,B)text("String")
text("String",x-coordinate,y-coordinate)
text("Hello World!")For unrestricted access download Robocompasspro
Robocompass Desktop Version