Lurker News
I was wondering how I can arrange objects along a spherical helix path, and read some articles on it.

I ended up learning about parametric equations again, and make this visualization to document what I learned:
https://visualrambling.space/moving-objects-in-3d/
feel free to visit and let me know what you think!

Comments (132) 68 threads

srean5 replies#
These used to be super important in early oceanic navigation. It is easier to maintain a constant bearing throughout the voyage. So that's the plan sailors would try to stick close to. These led to let loxodromic curves or rhumb lines.

https://en.m.wikipedia.org/wiki/Rhumb_line
Mercator maps made it easier to compute what that bearing ought to be.
https://en.m.wikipedia.org/wiki/Mercator_projection
This configuration is a mathematical gift that keeps giving. Look at it side on in a polar projection you get a logarithmic spiral. Look at it side on you get a wave packet. It's mathematics is so interesting that Erdos had to have a go at it [0]
On a meta note, today seems spherical geometry day on HN.
https://news.ycombinator.com/item?id=44956297
https://news.ycombinator.com/item?id=44939456
https://news.ycombinator.com/item?id=44938622
[0] Spiraling the Earth with C. G. J. Jacobi. Paul Erdös
https://pubs.aip.org/aapt/ajp/article-abstract/68/10/888/105...

srean#
Great to see you. I look forward for your comments on geometry, multivariate calculus and rotations.

Edit: fantastic graphics. You should submit the other one as an HN post too.

egwor1 reply#
In my early teens I used to try to create something like a equirectangular projection because when drawing it, it looked cool. Obviously I had no idea that it was called this. I was trying to draw reflections of a square window onto a sphere, and then I moved on to trying to cover the sphere in a checkered pattern. This is awesome to see, thank you!
jacobolus#
An equirectangular projection just means plotting latitude and longitude in a rectangle.

Do you mean my diagonal grid that I projected back onto the sphere? I'm not sure that has a name.

srean#
I had missed this one ! Thanks.

It is indeed raining spherical geometry today.

mxfh1 reply#
Except the helix curve shown in OP is NOT a loxodrome or rhumb line.

It has equal spacing on the surface between lines, a loxodrome can't have that property since by definition it must cross the meridians at the same angle at all times. That means it always gets denser near the poles.
---
Start with the curve:
x = 10 · cos(π·t/2) · sin(0.02·π·t)
y = 10 · sin(π·t/2) · sin(0.02·π·t)
z = 10 · cos(0.02·π·t)
Convert to spherical coordinates (radius R=10):
λ(t) = π/2 · t (longitude)
φ(t) = π/2 - 0.02·π·t (latitude)
Compute derivative d(λ)/d(φ):
d(λ)/dt = π/2
d(φ)/dt = -0.02·π
d(λ)/d(φ) = (π/2)/(-0.02·π) = -25 (constant)
A true rhumb line must satisfy:
d(λ)/d(φ) = tan(α) · sec(φ)
which depends on latitude φ.
Since φ(t) changes, sec(φ) changes, so no fixed α can satisfy this.
Conclusion: the curve is not a rhumb line.
this is how one should look for varying intersection angles:
https://beta.dwitter.net/d/34223

srean#
Indeed. It is one of the many well known spherical spirals / seiffert spirals.
cwmoore#
To quote the storytelling quality of Erdos's abstract:

"The simple requirement that one should move on the surface of a sphere with constant speed while maintaining a constant angular velocity with respect to a fixed diameter, leads to a path whose cylindrical coordinates turn out to be given by the Jacobian elliptic functions."

patcon1 reply#
Jeez Erdos. This man was so prolific he was still publishing 4 years after he died :o
srean#
Many after he passed
sfink4 replies#
Awesome visualizations.

The part that I was expecting to see but didn't: how can you move at a constant speed? For the original purpose of positioning objects along a path, it doesn't matter. But when moving, you can see it's moving much more slowly at the beginning and end (mostly determined by the radius). What if I want it to travel at a constant rate? Or even apply an easing function to the speed?
I'm sure there's some fancy mathematical trick that would just do it. If I were only more comfortable with math... my handwavy sketch would be to compute the speed function by differentiating the formulas to get dx, dy, and dz and passing them through the Pythagorean equation, then reparameterize on a t' variable using the inverse of the speed function? Maybe? I feel like I'm speaking using words I don't understand.

Sharlin1 reply#
For constant speed you need a so-called “Euclidean parameterization” where the t value is proportional to s, the Euclidean distance traveled (and thus no matter the value of t, if you add some dt it always works out to the same ds). This is super commonly needed when animating motion along all sorts of curves, as you might guess.

Unfortunately, there’s usually no closed-form solution for it, so we have to do it numerically. And for doing that there’s in general no better way than at each t, binary/interpolation search a dt that roughly corresponds to the ds that you want (start with the previous dt, it’s likely a very good approximation).
In practice, you’d do that once and store the results, basically approximating the curve as a polyline of evenly-spaced points– at least assuming that the curve itself isn’t changing over time!

Kennnan#
This pattern of stepping with different ds along a path has a lot of applications in control theory. Often we change the ds/dt ratio based on the known acceleration profile of a motor to minimize jerk and reach our destination as fast as possible.

Generally this idea is called motion profiling: https://www.motioncontroltips.com/what-is-a-motion-profile/

chaboud#
The instinct to sort of slow t is right, as the governing functions are maintaining angular velocity with respect to t but scaling radius also with respect to t.

It’s sort of like an Archimedean spiral. So, yeah, if you parameterize velocity and make that constant, you’re in better shape. Note that the radius starts at zero, though, so something is going to have to deal with limits.
A simpler path following approximation (e.g., for a game) might be to just give an iterative system path and tangent targets with respect to Z and then provide an iterative constraint on velocity with some sort of basic tweening (e.g., new = a * old + (1 - a) * target). Then just drag the thing along Z, like bead toys for toddlers.

meindnoch#
>I'm sure there's some fancy mathematical trick that would just do it. If I were only more comfortable with math... my handwavy sketch would be to compute the speed function by differentiating the formulas to get dx, dy, and dz and passing them through the Pythagorean equation, then reparameterize on a t' variable using the inverse of the speed function? Maybe? I feel like I'm speaking using words I don't understand.

What you're looking for is called arc length parameterization. Basically, you need to compose the curve with the inverse of its arc length function. Aside from a few special curve families, closed-form solutions don't exist.

damarberlari#
thanks!

currently the path is expressed as function of (t), and it's the t that progressed at the constant speed.
so the cube will finished one loop at the same duration, and thats why it moves much slowly at the beginning and end, where distance of one loop is smaller.
I have to admit I made it that way because it's simpler to implement:D. Making it move at constant speed require some more works, but others have provided some solutions here so I think I'll try

addaon3 replies#
> …which we know isn't actually chaotic. It's just a path defined by mathematical functions.

I don't know what function is being presented, so I can't speak to whether it demonstrates chaotic behavior -- but the whole /point/ of chaos is that it's an emergent property of deterministic mathematical functions. Perhaps the author meant "random" or "non-deterministic" rather than "chaotic"?

skalidindi31 reply#
^^^ This is an extremely underrated nitpick.

I am guessing that the HN audience would be / should be interested in that distinction. Mathematically speaking, chaos is an extreme sensitivity to initial conditions, and is very much still in line with deterministic systems. The resulting output, while seemingly random (since there is no easily identifiable pattern), is mathematically and conceptually different from actual randomness.

altruios2 replies#
'actual' or 'true' randomness is a rabbit hole.

https://en.wikipedia.org/wiki/Randomness
It really depends on the exact definition of what you are quantifying 'random' to be.
There is no proof (in the mathematical sense) of real randomness.

lotyrin1 reply#
I use "Random" to mean chaotic (extreme sensitivity to initial conditions) but with unknown (or unknowable) initial conditions.

Continue this thread — 1 reply

TheOtherHobbes#
There are a number of sophisticated tests for randomness. You can't prove absolute randomness in any Platonic sense, but you can certainly assess a source for different properties that are useful in applications that require randomness.

In this example the path is neither chaotic (in the formal sense) nor random, because a Fourier transform would identify the harmonic components.

latexr1 reply#
> the whole /point/ of chaos is that it's an emergent property of deterministic mathematical functions.

I believe you. But the colloquial definition (I’m looking at a dictionary right now) is “complete disorder and confusion”; “a state of things in which chance is supreme”; “the inherent unpredictability in the behavior of a complex natural system”. That path fits that apparent definition. The post is written in a way that a relative layman would understand, so it makes sense to speak/write in a way non-mathematicians would expect.

addaon#
> That path fits that apparent definition.

Then saying it "isn't actually chaotic" is mis-aligned with the layman's understanding, and the disagreement is not explained (either by explaining a more technical definition, or otherwise).
I continue to think that substituting "non-deterministic" or "random" would be more both understandable to the layman, and more correct to the advanced reader.

dcanelhas#
I just did a mental substitution for the word "stochastic" and moved on, since it wasn't the main point of the article. But you are correct. Computing the future states of a chaotic system, given the same initial conditions, will produce the same results every time but change the initial conditions ever so slightly and you have no guarante where you will end up next (unless you picked a state from a previous simulation, that is... But that's cheating;) )
RugnirViking#
It's a pretty basic primer to the subject, but good for kids learning maths. Could do with some callbacks to maths concepts like the circle equation ( x = r cos (t) and y = r sin (t) ).

Possible topics to branch further into would be polar coordinates and linear algebra basics (vectors, transformations, transformations in 3d space). If you the author aren't sure of such topics, I would recommend 3blue1brown yt videos on the matter
Possibly better for that than for programmers (given it doesn't include code or libraries used or anything about actually manipulating 3d objects like vertices, stretching and morphing to achieve the effect shown etc)

Load more comments