Primitives
Point
The most basic of primitives is the point
.
The point supports two coordinates, an x
and a y
coordinate, representing the location of the point in the Cartesian plane centered at (0, 0)
.
While we only currently support two dimensional points, we plan to support three dimensional points as well.
In order to create a point, the writer must do the following:
[point A]
This will create a point named A
.
In order to give the point coordinates, the [loc]
keyword must be used; see the Other Types page.
Currently, only single letter named points are allowed, however, we plan to allow points with longer names in the near future, once we solidify support for keyword arguments for all objects.
Line
A line
(technically a line segment in our code) is made up of two points representing the end points of the line.
Much like a point
can only currently be given a single letter name, a line
can currently only be given a two letter name, which each letter representing the single letter for a point
.
In order to create a line, simply do the following:
[line AB]
This will create a line with one endpoint as point A
and the other as point B
.
If the endpoints exist already, the code will use the existing endpoint, otherwise, it will create one.
For example, if point A
already exists, [line AB]
will not make a new point A
but will instead use the already created one.
This means that the follow produce identical results
[point A]
[point B]
[line AB]
and
[line AB]
Design Decision
Circle
A circle is defined by three points on the circumference of the circle.
Like the other primitives, these points can currently only have single letter names.
As such, a circle can only have a three letter name, with each letter representing a point
.
To create a circle, simply provide these three points as an argument to the circle
type, as follows:
[circle ABC]
Much like a line
, this will create the points if they do not already exist, and will use existing points if they do.
Design Decision
- A center and a radius
- Three unique points
Polygon
Much like the other primitives, a polygon
is defined by a series of points
.
Unlike a circle
or a line
however, the ordering of the points for a polygon
matters.
We connect each consecutive point
with a line
to create the polygon
.
This means that polygon ABCD
will be different from polygon ACDB
, even though they are comprised of the same points.
You create a polygon
as follows:
[polygon ABCD]
This will implicitly create all a line
between each consecutive point
, and as such, will implicitly create each point
if it does not already exist.
As such, the above declaration is equivalent to the following (however the above is obviously much more compact):
[point A]
[point B]
[point C]
[point D]
[line AB]
[line BC]
[line CD]
[line DA]
[polygon ABCD]
Design Decision
triangle
datatype.
However, we quickly realized that if we wanted to support polygons with arbitrary sides, having a type for each possible polygon would not only be unfesible from a design end, but it would also be very annoying for the end user.
As such, we switched to a generic polygon
object.
The type of the polygon will be based upon the number of points that are provided to the polygon.