Geometry Expressions

I’ve written before about the geometry construction language, Eukleides. In that post, I said that ‘I [was] drawn to Eukleides because it is a language […], and not a mouse-flinging WYSIWYG virtual compass.’ Those WYSIWYG mouse-flingers are known as interactive geometry software (IGS), and I’ve never been a huge fan of them. Most of them are built in Java, and it shows. Even beyond Java issues, they largely feel made by interns employed by mathematicians rather than folks who have read The Design of Everyday Things. At the same time, complicated constructions like Gauss’s 17-gon1 can quickly become unwieldy in written code. I have experimented with many, though never really settled on an IGS.

Geometry Expressions (GX) is currently on sale for $10 (instead of $99) due to the pandemic. Saltire, the maker, hasn’t stated when this sale will end, which… is fair. I had previously played with the trial of GX, and found it to be… pretty usable, but also I need to really be in a mood to drop a hundred bucks on hobbyist (I mean, for me) maths software. At $10, I decided to take the plunge. Here are my thoughts so far.

The good

The UI/UX isn’t that bad!
I don’t think this is written in Java? But it might be. It’s cross-platform (macOS/Windows) so it’s entirely possible that it’s written in… something weird. The UX fits in fine with Windows, I can only imagine it’s kind of awful on macOS, but… I haven’t tested that yet. Just a gut feeling. There are UI/UX quirks that I’ll get into later, but it’s… manageable!
Export options
One thing that I really don’t love about Eukleides is that you can basically just export to EPS. I then have to separately convert this to SVG, and from there, post-process the SVG. Eukleides also only lets you draw from like… eleven basic colors? GX is clearly built with exporting in mind, and integral to this is the fact that you can… well… use color good! But the actual export options are also great. Native SVG, our old friend EPS, your normal raster formats, and… interesting things. Lua, which I haven’t tried yet, and both animated GIFs and interactive HTML/JS, neither of which I’ve done anything interesting with yet.
Interactivity
I mean, it is called an interactive geometry system, but it is really rather magical how that all comes together. Assuming everything is glued together correctly (another topic for later), you can just drag points around and watch your construction work with different parameters. So, in the simple angle bisector shown below, dragging points A or C around will change the angle of ∠ABC, and the construction will adjust, changing ∠ABM and ∠MBC accordingly.
Robust toolset
I guess you wouldn’t really expect less, but Eukleides, for instance, really kind of gives you the bare minimum for objects and the like. GX has fifteen drawing tools which behave as expected. It has fourteen methods of constraint – for instance, in the illustration below, radius r is a constraint. I constructed the first circle and applied the constraint. I could have constructed the other two circles at any size – as soon as I applied the constraint, r, they were bound to it. These can be units as well; a square with side lengths constrained to 2 has double the side length as one constrained to 1. It has fourteen built in construction tools, which don’t interest me much as my use-case is largely doing constructions from scratch. Finally, it has eleven calculations, such as the angle calculations in the construction below.

Basic angle bisector created in Geometry Expressions A B C r H r K r M z 0 ~ 0.4294711 z 1 ~ 0.4294711

All in all, it’s a pretty nice tool for the things I want to use it for. But, unsurprisingly, there are some pretty frustrating snags.

The bad

Incident snapping does not work well
I said pretty frustrating, but I’m starting off with an incredibly frustrating UX gaffe. In the above construction, I followed the method of doing an angle bisector by hand with a compass and straightedge. Since I was doing this on an IGS that could precisely measure things for me, however, the construction itself had to be quite precise. I tried several times, and kept coming up with angles that were slightly off. The problem was that center points H and K were not quite aligned with the intersection of circle B along ∠ABC. Why did this happen? When creating the two intersecting circles (H and K), the cursor changed to a design that clearly indicated it was snapping incident to the relevant intersection. Additionally, the two intersecting objects were highlighted. But it didn’t actually snap. The only way to get this to work was to use the construction tools to make intersection points; the circle tool was willing to snap incident to existing point just fine. This is absurd. Certainly the solution is to make snapping function across the board, but if that can’t be done, don’t make the UI change such that it appears as though that’s happening. I don’t know how such a decision can be shipped.
It’s easy to feel like you have to undo a lot
The tools are pretty good for constructing and the like, but… less-so for touching things up or fixing goofs. There were plenty of time where I created things and just felt kind of… lost in either how I accidentally made a thing, or how to get a thing to do what I wanted vs. just… getting it right from the outset. For instance, I haven’t figured out how to rotate a polygon around its midpoint, only vertices (and these rotations don’t seem to have any shift-constraints, nor do translations). Mild example but little things like that make the toolset feel less fleshed-out than I’d like.
Nonstandard UX behaviors
To an extent, this still feels like some mathematician’s hired hand whipped up some controls without studying, say, Illustrator. There aren’t keyboard shortcuts that I can find for the tools (the menu doesn’t even have alt-keys defined, which is infuriating). Scroll-wheel zooms (actually, I believe it scales the document, which is even sillier) instead of… scrolling (this is one of my biggest pet peeves in image editing software). Scroll/pan is achieved by holding right-click instead of Space. Et cetera. It’s not as bad as many that I’ve played with, but it can be cumbersome to use.
Unclean SVG export
I’m glad I can export right to SVG! But the export is… a lot. There’s a lot of extra stuff in there, and weird behaviors like every digit in 0.4294711 up there being a separate textbox. I actually imported it into Illustrator and cleaned a couple of things up (there were some points and extra bits that I couldn’t quite figure out how to get rid of, &c.) but… the text is really small! It’s not font-size, and my knowledge of SVG isn’t quite at the point where I’m going to solve it for this post. And while I apologize for the text being difficult to read, it does help demonstrate that the SVG output is just a bit much. I also had to touch up the rightward double arrow; GX’s export opted to find this in a Symbol font instead of using U+21D2. Little things, but room for improvement.

In conclusion

For $102? I’m happy with this purchase. It doesn’t do too much; it’s not a full-featured CAS with an IGS built in. Because of this, all of your tools are right there in front of you and are fairly self-explanatory. The UX could use some polish, but it isn’t terrible. There are a lot of export options, and hopefully I can figure out how to do something fun with the interactive ones. I don’t know that I would be bothering to write this if I was just checking out the trial at a $99 price point, however. It’s specialized software, and I get that; we’re also increasingly numb to the work that goes into software and the value of said work. But, boy, if I was going to pay full-price? I sure as hell would want keyboard shortcuts, functioning snapping, and just a little bit of general UX touch-up.

If you’re reading this, and you’re a recreational maths nerd, and you’re stuck at home, and Saltire is still offering GX for $10… I think it’s hard to pass up.


Golfing in Eukleides

Eukleides is decidedly not a golfing language, but when a geometry-related question came up on PPCG, I had to give it a shot. Eukleides can be quite rigid; for starters it is very strongly typed. Functions are declared by what they intend to return, so while set would be the shortest way to declare a function, it can’t really be exploited (unless returning a set is, in fact, desired). Speaking of sets, one thing that is potentially golfable is ‘casting’ a point to a set. Given a point, p, attempting a setwise operation on p will fail because a point does not automatically cast to a set (strict typing). p=set(p) will overwrite point p with a single-item set containing the point that was p. If, however, it is okay to have two copies of the point in the set, p=p.p is three bytes shorter.

If user input is required, the command number("prompt") reads a number from STDIN. The string for the prompt is required, though it can be empty (""). Thus, if more than four such inputs (or empty strings for other purposes) are required, it saves bytes to assign a variable with a one-letter name to an empty string.

Whitespace is generally unavoidable, but I did come to realize that boolean operators do not need to be preceded by whitespace if preceded by a number. So, if a==7or a==6 is perfectly valid. aor a, 7ora, 7 or6 are all invalid, however. This may be an interpreter bug, but for the time being it is an exploitable byte.

Finally, loci. Loci are akin to for-loops that automagically make sets. Unfortunately, they don’t seem to care much for referencing themselves mid-loop, which meant that I couldn’t exploit how short of a construction they are compared to manually creating a set in a for-loop.

This was a fun exercise, and just goes to show that if you poke around at any language enough, you’ll find various quirks that may prove useful given some ridiculous situation or another.


A few of my favorite: Pink pencils

I write a lot. I carry many bags. I’m untidy. I own and use many mechanical pencils. Some of them good, some of them bad, most of them pink. Here are my favorites.

Pentel Sharp Kerry:
The Kerry is hands-down the best pencil I own, in a very practical sense. It’s not beautiful; its oddly shiny-and-gridded midsection that looks grippy but is too high to function as such is just gaudy. The pencil was introduced at least 30 years ago, but I can’t imagine that ever looked good. But it’s such a well-engineered, functional pencil that it’s hard to rail on too much. It’s kind of the pencil version of 70s Japanese ‘pocket pens’ in that it has a cap, and it ‘grows’ to a usable size when said cap is posted. A pencil introduces its own challenges, of course, so the cap actually has its own lead advance button (which contains the eraser) that interfaces with the main advance. The cap obviates the need for a retraction method, so the Kerry lives comfortably in a pocket or a bag. I don’t have a bag without a Kerry in it.
Uni Kuru Toga High Grade:
Uni’s Kuru Toga is one of the most meaningful innovations in mechanical pencil mechanisms as far as I’m concerned. With a 2.0mm lead, or possibly even down to a 1.3mm, one might sharpen their lead with a purpose-built rasp or a lead pointer. Get much narrower, and your leads are all over the place. I use 4B whenever possible, and 2B otherwise, so this is less of a problem for me, but it’s still nice to find ways to mitigate problems. The Kuru Toga mechanism rotates the lead by a tiny amount every time you press it to paper. This mechanism is a bit ‘spongy’, perhaps, almost like a pencil with a suspension mechanism. I found it very easy to adjust to, but I’ve heard of others taking issue with it. The High Grade has an aluminum grip, which I like the weight and feel of, but others may prefer the rubber grip model.
Pilot Clutch Point:
This pencil is fairly maligned, and I understand why. The aforementioned pencils (and the following pencils) all use an internal clutch mechanism, and have a straight lead sleeve. Straight lead sleeves are great for draughting; they slide perfectly along a straightedge. I, personally, don’t like them all that much for writing, however. The internal mechanism brings with it other advantages. Keeping the mechanism protected, and having the lead held straight by the sleeve before the clutch means far less breakage. The Pilot Clutch Point exposes the clutch right at the front of the pencil, and if you don’t treat it with respect, it will jam. Badly. But when it works, it has a nice, pointy mechanism that will hold the shortest bits of lead known to humankind. It may very well be my favorite pencil for everyday writing.
Pentel Sharp Pocket:
The baby sister of the Kerry, I suppose? Much thinner, slightly shorter, and with a much more Biro-like cap that doesn’t really extend the pencil whatsoever. Great for attaching to a diary or the like. Works as well as any Pentel does. Very light.
Staedtler 775:
I guess the pink one is only available in Korea, but it does exist, and one can find it on eBay, so I say it counts. The 775 is a classic draughting Staedtler. It has a retracting point, but you have to ram it in to get it to do so. This has its ups and downs, being a simple retraction system makes it incredibly steady when engaged. But it’s also hard to disengage, and you risk breaking the lead or bending the sleeve.
Zebra Color Flight:
A really cheap pencil, but bonus points for coming in three shades of pink. It also has one other neat trick up its sleeve – much more eraser than the typical mechanical pencil, extended by rotating the advance. The plastic feels cheap, nothing to write home about. But considering how cheap they can be, the Zebra Color Flight pencils are actually pretty nice.

Eukleides

Despite having failed out of geometry in my younger days, it has become my favorite sort of recreational math. I think, back in elhi geometry, too much emphasis was placed on potential practical applications instead of just distilling it down to the reality that this was what math was before there was any sort of formal mathematical system. Geometry is hands-on, it’s playful, and as such I have come to really enjoy playing with it. As much as I enjoy doing constructions with a straightedge and compass, I occasionally poke around to see what tools exist on the computer as well. Recently, I stumbled across a very neat thing: Eukleides.

I’m drawn to Eukleides because it is a language for geometry, and not a mouse-flinging WYSIWYG virtual compass. This seems contradictory given my gushing about geometry being hands-on, and don’t get me wrong – I love a hands-on GUI circle-canvas too1. But sometimes (often times) my brain is in code-mode and it’s easier to express what I’m trying to do in words than to fiddle around with a mouse. And a task like ‘intersecting a couple of circles’ is far more conducive to writing out than, say, laying down an SVG illustration from scratch.

a b c d e bi

There you have one of the first constructions learned by anyone studying geometry – bisecting an angle with three arcs (or, full-blown circles in this case). Angle ∠abc is bisected by segment bbi. Here’s the code:

% Percent signs are comments
a=point(7,0); b=point(0,0) % Semicolons and newlines separate commands
a b c triangle 5,-40°
g=circle(b,3)
d=intersection(g,a.b); e=intersection(g,b.c)
d=d[0]; e=e[0] % Intersections return sets (arrays), extract the points
h=circle(d,3); i=circle(e,3)
bi=intersection(h,i)
bi=bi[1]
label
  a 0°; b 180°; c 40° % Label the points
  d -40° gray; e 90° gray
  bi 20°
  a,b,bi; bi,b,c 1.5 % Make the angle markers
end
draw
  c.b.a
  g lightgray; h gray
  i gray
  bi
  b.bi
end

Note that the code originally used shades of grey, I shifted these around to match my site’s colors when I converted the resulting EPS file to SVG. The code is pretty straightforward: define some points, make an angle of them, draw a circle, intersect segments ab and bc, make some more circles, intersect where the circles meet, and boom – a bisected angle. The language reminds me a bit of GraphViz/DOT – purpose-built for naturally expressing how things will be drawn.

We can actually prove that the construction works without even generating an image file. Removing the draw and label sections, and replacing them with some print (to stdout) statements calling angle measurement functions:

a=point(7,0); b=point(0,0)
a b c triangle 5,-40°
g=circle(b,3)
d=intersection(g,a.b); e=intersection(g,b.c)
d=d[0];e=e[0]
h=circle(d,3); i=circle(e,3)
bi=intersection(h,i)
bi=bi[1]
%%%%%%%% New content starts here:
print angle(a,b,c)
print angle(a,b,c)/2
print angle(a,b,bi)
print angle(bi,b,c)

We get ∠abc, ∠abc/2, ∠abbi, and ∠bcbi. The last three of these should be equal, and:

40
20
20
20

…they are! We can also do fun things like dividing the circumference of a circle by its diameter:

print (perimeter(circle(point(0,0),4))/8)

…to get 3.14159. Very cool. There are a few improvements I would like to see. Notably, while you can label points etc. with their names, I can’t find a way to add arbitrary labels, or even labels based on functions. So you can’t (seemingly) label a line segment with its length, or an angle with its measure. Also, the interpreter wants ISO 8859-1 encoding, and it uses the degree symbol2 (°) to represent angle measures. This gets all flippy-floppy when moving to UTF-8, and in fact if I forget to convert a file to ISO 8859-1, I’ll get syntax errors if I use degree symbols. Finally, it only outputs to EPS; native SVG would be incredibly welcome.

Eukleides is a lot of fun to play with, and it’s worth mentioning that it has looping and conditionals and the like, so it is programmable and not just computational or presentational. Presumably some pretty interesting opportunities are thus opened up.