mgeier / quaternion-nursery

24 stars 5 forks source link

Python library **splines** #1

Open stla opened 3 years ago

stla commented 3 years ago

Hello,

Thank you for this repo, it is nice. It seems to me you never mention the splines Python library. It provides several types of quaternions interpolation. In particular, there is a "constant speed adapter" of splines. I realized this animation with it:

WavyCylinderRotatingAtConstantSpeed

mgeier commented 3 years ago

I'm not sure if you are aware of that, but I'm also the author of the splines module.

In fact, this quaternion-nursery is a collection of notes and experiments that I have used as preparation for creating the "rotation" section of the splines project.

But you are right, I should probably mention that in the README ...

BTW, I'm glad you like the "constant speed adapter"!

mgeier commented 3 years ago

I've just updated the README, I hope the situation is now clearer.

stla commented 3 years ago

Ah that's you lol. OK. Here is a Hopf Torus filmed by a camera following a spherical curve at constant speed. I implemented this in R but this is slow.

HopfConstantSpeed

mgeier commented 2 years ago

I implemented this in R but this is slow.

What is slow? Evaluating the spline or the whole 3D rendering?

stla commented 2 years ago

Evaluating the spline, with the root finder and the integral.

mgeier commented 2 years ago

I'm not sure which spline type you are using, but if you are using BarryGoldman (as shown in https://splines.readthedocs.io/en/latest/rotation/barry-goldman.html#Constant-Angular-Speed), this is known to be very slow. You should use DeCasteljau instead, which gives very similar results and is much faster for calculating constant angular speed.

If you are already using DeCasteljau there are certainly still options for optimization. The splines library is very much not optimized at all. Both the root finding and the integration can certainly be optimized. I just took the first functions that I found in SciPy which did what I wanted. I'm sure there are more optimized algorithms available.

stla commented 2 years ago

I'm using Kochanek-Bartels because it has some parameters. I made a JavaScript application these days: HopfApplication which uses this algorithm (that I reimplemented in JS).