Still plotting.
It's been ages since I've made a new plot worth posting. I guess that's the nature of side projects--you work on them when you feel like it, or even if you have the time, rather than through external compulsion. Plus recently I spent some more time on my toy compiler and not so much on the pen plotting.
And even then it's taken me ages to write the code to do the current image. Partly because the algorithms involved are tricky and partly because I was hamstringing myself with my own tools.
Here are 25 randomly rotated toruses.
It's only a test to prototype the rendering algorithm and it's unoptimised, hence all the annoying bumps and dots and wiggles. They should be nice curves, but because the lines are drawn completely out of order the pen is lifting and dropping constantly and making a mess. And so an image like that should take 30 seconds to plot, but instead took nearly 10 minutes.
In my last plotter item I had written code to draw 3d shapes. But they were simple convex polyhedra so finding their occluded faces and the occlusion contour--the outline--for them is simple. Just draw any edge where one of its adjoining faces is visible and the other is not.
A torus or any other non-convex shape will need extra processing to remove hidden edges. To remove the hidden contours the mesh must be projected into 2D. Then any collision between any 2D lines must be found and those lines are split at that collision point, in both 2D and the original 3D. Then rays can be cast from the eye in 3D space to determine which of those lines are actually visible.
This took me a while to get working because I didn't twig that the rays definitely needed to be in the 3D space and not just the 2D space--I thought I could fudge it and do everything with the 2D projection.
I also wasted time thinking about (and researching) optimised algorithms for both the line collision detection and the ray casting. For the former a sweep line algorithm can be used for O(log(n)) results and for the latter acceleration techniques like BVH are well tread. But so far I've been able to brute force everything very simply, with no real performance problems, so heh. Maybe later for more elaborate models or scenes.
And also everything so far I've written in Janet, with a C++ auxiliary library for the 3D maths. But generating the view graph for the visible contours was too complicated for Janet and so I wrote that in C++. Yikes. For the first 25 years of my career C++ was all I wrote professionally and I became an expert. But in the last few years I've written none and used Rust. Going back to C++ was initially fine, I was surprised how much I didn't mind it... until eventually I did. Ugh. So I started to dread working on the view graph stuff because it was less that pleasant C++ I'd have to deal with. So that's the other reason it's taken so long.
Now I'm keen to redo it all again, which is fine when it's a side project you're doing for fun in your spare time. :) This time I'm dropping Janet and C++ and will do it in Rust, and script it with my own little language, which is something I've done many times in the past and should be easy/fun.
Hopefully soon I'll have the same toruses generated via the new engine and also optimised for 30 second smooth as butter plots.