HomeWildfire Games

Split the 1D and 2D interpolation into 2 Functions. Renamed…

Description

Split the 1D and 2D interpolation into 2 Functions. Renamed BicubicInterpolation.js to interpolation.js. Original patch by Vladislav. Reviewed by fatherbushido. Fixes #4218

Details

Committed
FeXoRNov 13 2016, 6:34 PM
Parents
rP18924: Add parenthesis suggested by gcc 5.4 following r18921, refs #4278.
Branches
Unknown
Tags
Unknown

Event Timeline

elexis added inline comments.
/ps/trunk/binaries/data/mods/public/globalscripts/interpolation.js
3

@fatherbushido are you sure this is a uniform Catmull-Rom spline?

According to this wiki article, this is a centripetal Catmull-Rom spline, because this uses alpha = 0.5, while uniform supposedly uses alpha = 0.

I'm asking because the ClumpPlacer and PathPlacer use a chordal Catmull-Rom spline (alpha = 1), so I can unify this by making alpha an argument.

fatherbushido added a comment.EditedOct 30 2017, 3:20 PM

(Well I didn't really speak of uniform iirc (2016-09-26-QuakeNet-#0ad-dev.log and #4278). But that's not the point.)

(I don't know if uniform refers to the same thing.
I guess FeXoR uses uniform to refers that the point are uniformly spaced (I don't know where it's used).
But well.)

Indeed, just add that tension parameter, it's a good idea, even more if you need it. I don't have the original Catmull-Rom article but I guess they used 1/2. The generic name (depends of many things :p) may be cardinal splines.
The formula provided at the end of your second ref is ok.

edit: I wasn't explicit, but indeed we use the 1/2 tension parameter (take care sometimes, the inverse parameter is used)

Ah, you're right with regards to the ticket.
Thanks for the quick feedback!
Do you prefer to be mentioned in the commit message (and if yes, how) or avoided, or eager to review an according diff to interpolation.js?
(Should the tension become the first argument of the function?)

fatherbushido added a comment.EditedOct 30 2017, 6:53 PM

Ah, you're right with regards to the ticket.
Thanks for the quick feedback!
Do you prefer to be mentioned in the commit message (and if yes, how) or avoided, or eager to review an according diff to interpolation.js?
(Should the tension become the first argument of the function?)

Back. I read again the two refs.

For the tension parameter, I guess it fits better at the end (with 0.5 as default perhaps). We used 0 in the current function.

But there is also that other parameter for the spacing of control points. The one mentioned in the first article. For that one, we actually use 0 in the current function (uniform). 0.5 is indeed for centripetal and 1 is for chordal. (I wasn't aware of that.)

I can/will look at those ClumpPlacer and PathPlacer to understand what is used exactly.

I can indeed review an interpolation diff if you want.

(Else no need to mention my name)

I looked a bit.
Matlab have such a function https://fr.mathworks.com/matlabcentral/fileexchange/7078-cardinal-spline--catmull-rom--spline?requestedDomain=www.mathworks.com and https://fr.mathworks.com/matlabcentral/fileexchange/7326-n-dimensional-cardinal-spline--catmull-rom--spline-interpolation
In fact, just while writing, I notice it's just a contributor's suggestion, the guy chooses to place the tensor arg just after the control points (but he also chooses to place the evaluation value at the end (fexor/vlad did at the begin)... enjoy the choice.

Good.