quaternion-nursery icon indicating copy to clipboard operation
quaternion-nursery copied to clipboard

Python library **splines**

Open stla opened this issue 4 years ago • 7 comments

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

stla avatar Oct 24 '21 12:10 stla

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 avatar Oct 26 '21 19:10 mgeier

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

mgeier avatar Oct 26 '21 19:10 mgeier

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

stla avatar Oct 27 '21 00:10 stla

I implemented this in R but this is slow.

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

mgeier avatar Nov 15 '21 19:11 mgeier

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

stla avatar Nov 15 '21 20:11 stla

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.

mgeier avatar Nov 16 '21 18:11 mgeier

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).

stla avatar Dec 14 '21 17:12 stla