In order to have pantograph be “SVG complete”, i.e. supporting all the SVG path options, I still need to implement arcs of ellipses and Bézier curves.
I have never really studied ellipses, just used the formulas when needed without building an intuition for them. And, obviously they are trickier than what I assumed (isn’t it always).
Ellipses data model
The first big choice to make is the data model I want to store them into. The SVG documentation has a good primer on the two approaches it offers:
- the center parametrisation
- the endpoints parametrisation
Because I am only interested in arcs of ellipses, the endpoint parametrisation looks quite good - I want to keep the endpoints as part of the model.
I do have an issue with it though, the center is a value that will need to be
computed in any case - most operation on the ellipse will need us to transform
it as a “standard ellipse” with axes aligned with the reference frame and
center at (0, 0)
.
I think I should go with an approach that has slightly too much information defined:
- endpoints
- center
- tiltAngle
- both radii (i.e. half axes)
- orientation
I have also been thinking of how I model arcs of circle, where the radius is deduced from the endpoints. The equivalent would be to use only the excentricity of ellipse as a parameter and compute both half axes from it.
- endpoints
- center
- tiltAngle (of the major axis)
- exentricity
- orientation
I am not 100% convinced of this approach as the tilt angle might be different than the tilt angle of a SVG parametrisation. Also exentricity is not as intuitive than the radii.
Distance between a point and an ellipse
In the chapter of things that I have learnt about ellipses there is the fact that the exact distance of a point to an ellipse is not easy to compute.
I have found a nice algorithm, have a read if you are interested in these kind of things.
Distractions!
While I wanted to focus on ellipses stuff has been distracting me!
dielines are so much fun
The implementation of the box I did with dielines gave me an itch to scratch. I have had in my mind to implement the dielines of this clock for which I have found a scanned PDF. It could be cut with my Silhouette Cameo and could be a fun project.
So I have improved the Dieline
class from the previous week and implemented
some of the generic shapes I could see used in the book.
I stopped myself before going too deep, but the result so far live in a branch of pantograph
I have learnt an important lesson for pantograph - that loops are sometimes
just strands that are closed on themselves - a one dimensional entity. I have
therefore extended the erase
and confine
operation to all Strokes
.
When I find the time, I should extract the Dieline
class as its own project
and publish it separately. This could be a cleaner base for things like
deckinabox.
A new toy
I also have received a Bambulab P1P. It has been distracting.