-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction to Construct
Construct is a tool for manipulating classical geometric objects: points, lines, circles, etc. You can find it online here.
There are two ways to create geometric objects in Construct:
- New points can be created by clicking on the canvas.
- Other objects are created by combining existing ones using constructions.
Let's look at an example of how to create points and do constructions with them. We start by clicking twice on the canvas, which creates two new points, A
and B
by default. We then type
>> let C = circle(A, B)
into the Construct shell, to create a circle.
The built-in constructions are circle
, line
, segment
, and ray
. There's also a special built-in construction call intersection
. Let's draw another circle and try it out.
>> let C2 = circle(B, A)
>> let D, E = intersection(C, C2)
the result is:
Something interesting happened here: the intersection of C
and C2
was not a single point, it was two points. We bound each point to a different name by putting D, E
to the left of the equal sign.
Suppose we were constructing the perpendicular bisector of these two points. We'd only need one more step:
>> let p = line(D, E)
If we want to save this construction for future use, it's easy. We state what the inputs to the construct are (the two points), and what the outputs are (just the line).
>> given point A, point B
>> return p
>> :write perpendicular_bisector
notice that the objects are separated by commas, and the type of each input must be specified. The last command is a meta-command, something that isn't part of the construct language per-say, but can be used in the shell to do something. Notice that after you enter the :write
command, your construction appears in the library editor:
To use our construction, we have to :reset
the shell, which loads whatever is in the library editor, and clears the canvas.
>> :reset
We then place a new pair of points, and invoke the construction:
>> let l = perpendicular_bisector(A, B)
the result is the perpendicular bisector, without the intermediate steps:
You can also write constructions directly into the library editor. For example, the following construction finds the midpoint of two points, using the perpendicular_bisector
construction we just wrote.
construct midpoint
given point A, point B
let p = perpendicular_bisector(A, B)
let s = segment(A, B)
let I = intersection(p, s)
return I
After typing it into the library editor, you can reset the shell to use it.
You've seen how to use the built-in constructions circle
, line
, and segment
. You've also seen how to use intersection
. You've seen how to write and use your own constructions. This is a powerful set of tools that will allow you to do many things.
If you're interested in learning more, check-out the next lesson on Shapes