Skip to content

Introduction to Construct

Alex Ozdemir edited this page Nov 28, 2017 · 3 revisions

Introduction to Construct (web version)

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:

  1. New points can be created by clicking on the canvas.
  2. Other objects are created by combining existing ones using constructions.

Placing Points and Drawing a Circle

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.

A circle, C, with center A and edge B.

Finding an Intersection

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:

Two circles intersecting at points D and E

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.

Finishing the Perpendicular Bisector Construction

Suppose we were constructing the perpendicular bisector of these two points. We'd only need one more step:

>> let p = line(D, E)

The perpendicular bisector

Saving the Construction for Future Use

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:

The perpendicular_bisector construction appears.

Using new constructions

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:

The perpendicular bisector

Writing Constructions Directly in the Library Editor

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.

Conclusion

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