A (set of) magic tool(s) for drawing centered trochoids (a form of roulette curves) -- i.e.. epitrochoids & epicycloids (aka hypercycloids), hypotrochoids & hypocycloids. Basically, ways to draw art similar to that produced by a Spirograph.
Given a fixed circle with radius R
, and another circle rolling around that circle with radius r
(if negative, on the inside), with a point at d
distance from center of the interior circle, looping through angles θ
, the position of the points (lines) to plot (relative to the fixed circle's center) are calculated as:
x = ((R - r) * cos(θ)) + d * cos(((R - r) / r) * θ)
y = ((R - r) * sin(θ)) - d * sin(((R - r) / r) * θ)
θ
must go through the range 0
to 2π * (least_common_multiple(r, R) / R)
(see https://en.wikipedia.org/wiki/Least_common_multiple) to generate a complete shape. Depending on the relation between R
, r
, and d
, different trochoids will be generated.
Thoughts on how to get all this working in Tux Paint's interface (limits of the Magic tool API):
* click to set the center of the fixed circle
* drag horizontally to set the radius of the fixed circle (R
); drag vertically to change the distance of the plot point (d
) (see behavior of "Waves" and "Wavelets")
* a click-and-release (without dragging) should draw a satisfying shape (see behavior of "3D Glasses", "Flower", and "Tornado")
* size option could be used to set the radius of the rolling circle (r
); it would need to be relative to the radius of the fixed circle (R
)
* separate tools for positive r
vs negative r
values -- e.g., epitrochoid ("flower petals") vs hypotrochoid ("star")
* if size option is unavailable (--nomagicsizes
), perhaps provide additional tool variations with some useful r
values (R * 1.5
, R
, R * 0.5
)
Done!
Bill, just played a little with them, I don't understand those maths, just speaking from what I see in the screen, so sorry if I am making noise, but looks as the titles and definitions are inversed, and that the xor fixed circles too(inside/outside), see the attached drawing
Nope, it doesn't look like I swapped them :D
See https://en.wikipedia.org/wiki/Centered_trochoid
(Thanks, Google)
Just try to draw an epi with two coins, the pattern is very different, the sharp angles go inside and the loops outside
Ah! I think I see what you mean! I wonder if I have a neg-vs-positive swapped!!!
Ref: https://mathworld.wolfram.com/Hypotrochoid.html
and: https://mathworld.wolfram.com/Epitrochoid.html
(via https://www.durangobill.com/Trochoids.html)
Ok fixed I think :)
Yes, only rests review the icons to match the tools, and the hypo, when both circles equals, it doesn't draw anything, maybe don't allow equal circles and jump from low size to upper one directly.
Sorry for the noise :)
Found another problem, Tux Paint freezes when trying to draw a BIG trochoid,no matter epi or hypo.
Ack! Stupid bug I just introduced. Fixed in https://sourceforge.net/p/tuxpaint/tuxpaint/ci/4496e007a15b9e077b3fa83ebcdecd413077baa1/
Thanks as always!