Advertisements

Archive for July 5th, 2019

Wrapping GCMC Text Around Arcs

GCMC includes a typeset function converting a more-or-less ASCII string into the coordinate points (a “vectorlist” containing a “path”) defining its character strokes and pen motions. The coordinates are relative to an origin at the lower-left corner of the line, with the font’s capital-X height set to 1.0, so you apply a scale function to make them whatever size you want and hand them to the engrave library routine, which squirts the corresponding G-Code into the output file.

Such G-Code can annotate plots:

Guilloche 213478839
Guilloche 213478839

Given that the plots appear on relentlessly circular CDs and hard drive platters, It Would Be Nice to wrap text around a circular arc, thusly:

Diamond Scribe - LM3UU - arc text - first light
Diamond Scribe – LM3UU – arc text – first light

The scaled coordinates cover a distance L along a straight line, so putting them on an arc will cover the same distance. The arc is part of a circle with radius R and a circumference 2πR, so … polar coordinates to the rescue!

The total text length L corresponds to the total angle A along the arc:

A = 360° L / 2πR

It’s entirely possible to have a text line longer than the entire circumference of the circle, whereupon the right end overlaps the left. Smaller characters fit better on smaller circles:

Arc Lettering - Small radius test - NCViewer
Arc Lettering – Small radius test – NCViewer

The X coordinate of each point in the path (always positive from the X origin) in the path gives its angle (positive counterclockwise) from 0°:

a = 360° x / 2πR (say "eks")

You can add a constant angle of either sign to slew the whole text arc around the center point.

The letter baseline Y=0 sits at radius R, so the Y coordinate of each point (positive above and negative below the Y=0 baseline) gives its radius r:

r = R - y

That puts the bottom of the text outward, so it reads properly when you’re facing the center point.

Homework: Tweak the signs so it reads properly when you’re standing inside the circle reading outward.

Converting from polar back to XY:

x = r × cos(a) (say "times")
y = r × sin(a)

You can add an XY offset to the result, thereby plunking the point wherever you want.

This obviously works best for small characters relative to the arc radius, as the lines connecting the points remain resolutely straight. That’s probably what you wanted anyway, but letters like, say, “m” definitely manspread.

Overall, it looks pretty good:

Arc Lettering - test plot overview - NCViewer
Arc Lettering – test plot overview – NCViewer

A doodle helped lay out the geometry:

Arc Lettering - geometry doodles
Arc Lettering – geometry doodles

The GCMC source code as a GitHub Gist:

Advertisements

,

2 Comments