Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#4218 closed enhancement (fixed)

[PATCH] Split bicubicInterpolation to 1D and 2D so both are available

Reported by: FeXoR Owned by: FeXoR
Priority: Nice to Have Milestone: Alpha 22
Component: Maps Keywords: patch
Cc: Patch:

Description

This is just an improvement of BicubicInterpolation.js. It splits the 1D part and uses it in the 2D part. That way it is much more readable as well as the 1D function is now also available.

Also the swapped x/y coordinates where fixed.

Thanks Vladislav for the changes!

Attachments (5)

interpolationSplit2016_9_16.diff (3.6 KB ) - added by FeXoR 8 years ago.
Splits 1D and 2D interpolation, fixes x/y swaping
interpolationSplit2016_9_16b.diff (5.2 KB ) - added by FeXoR 8 years ago.
Removed some unneeded vars, removed licence links, changed eol to native
interpolationSplit2016_9_17.diff (6.5 KB ) - added by FeXoR 8 years ago.
Added non-spline implementation , renamed file to interpolation.js
interpolationSplit2016_9_24.diff (5.5 KB ) - added by FeXoR 8 years ago.
Patch as I think should be committed (removed "convolution" argument)
interpolationSplit2016_9_26.diff (5.5 KB ) - added by FeXoR 8 years ago.
Some style and comment changes, removed a wrong colon

Download all attachments as: .zip

Change History (13)

by FeXoR, 8 years ago

Splits 1D and 2D interpolation, fixes x/y swaping

by FeXoR, 8 years ago

Removed some unneeded vars, removed licence links, changed eol to native

comment:1 by elexis, 8 years ago

Milestone: BacklogAlpha 21

Tested the first version and couldnt notice a difference to the previous algorithm. Didn't solve the equations, so I don't know if there are hidden bugs. Like Vladislav said, the interpolation file could be renamed to mention the most common denominator of the functions present (perhaps interpolation?).

comment:2 by FeXoR, 8 years ago

We are using the algorithm e.g. described at https://en.wikipedia.org/wiki/Bicubic_interpolation (see "Bicubic convolution algorithm")

An alternative would be using simple bicubic interpolation 2 times. That would be more precise throughout fx, fy in [-1; 2] but also slower. It's also more prone for oscillations (Runge's phenomenon) but that should'nt be a problem at 3rd degree polynimials.

Third degree polynomial: f(x) = ax^3^ + bx^2^ + cx + d
f(-1) = p0 <=> -a + b - c + d = p0
f(0)  = p1 <=>              d = p1
f(1)  = p2 <=>  a + b + c + d = p2
f(2)  = p3 <=> 8a +4b +2c + d = p3
<=> (Matrix)
-1  1 -1  1 = p0 | -II
 0  0  0  1 = p1
 1  1  1  1 = p2 | -II
 8  4  2  1 = p3 | -II
<=>
-1  1 -1  0 = p0 -p1 | +III
 0  0  0  1 = p1
 1  1  1  0 = p2 -p1
 8  4  2  0 = p3 -p1 | -2III
<=>
 0  2  0  0 = p0 -2p1 + p2
 0  0  0  1 =      p1
 1  1  1  0 =    - p1 + p2     | *2 -I
 6  2  0  0 =      p1 -2p2 +p3 | -I
<=>
 0  2  0  0 =  p0 -2p1 + p2
 0  0  0  1 =       p1
 2  0  2  0 = -p0      + p2     | *3 -IV
 6  0  0  0 = -p0 +3p1 -3p2 +p3
<=>
 0  2  0  0 =   p0 -2p1 + p2
 0  0  0  1 =       p1
 0  0  6  0 = -2p0 -3p1 +6p2 -p3
 6  0  0  0 = - p0 +3p1 -3p2 +p3
Last edited 8 years ago by FeXoR (previous) (diff)

by FeXoR, 8 years ago

Added non-spline implementation , renamed file to interpolation.js

comment:3 by elexis, 8 years ago

Milestone: Alpha 21Alpha 22

Feature freeze in 2 days.

by FeXoR, 8 years ago

Patch as I think should be committed (removed "convolution" argument)

comment:4 by fatherbushido, 8 years ago

L2

  • Perhaps replace "Two dimensional interpolation within four equidistant points using polynomials of 3rd degree." by "One dimensional interpolation within four uniformly spaced points using polynomials of 3rd degree.
  • Perhaps add somewhere it's a Catmull-Rom spline.

L31

  • To be remove (useless now)

L18-L19

  • Use the same case for x and y

Else you can commit.

by FeXoR, 8 years ago

Some style and comment changes, removed a wrong colon

comment:5 by fatherbushido, 7 years ago

@FeXoR: You can commit it. (We waited for a21 release).

comment:6 by FeXoR, 7 years ago

Resolution: fixed
Status: newclosed

In 18925:

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

comment:7 by FeXoR, 7 years ago

Keywords: review removed

comment:8 by elexis, 6 years ago

In 20383:

Extend the cubicInterpolation function to consume a tension argument allowing to modulate the smoothness of the interpolation.

Thereby unify the chordal Catmull-Rom spline interpolation of the ClumpPlacer (C++ rP2378, JS rP9096),
the copy of that in the PathPlacer (rP11152, refs #892) and
the centripetal Catmull-Rom spline of the bicubicInterpolation function from rP18925, refs #4218
and don't claim the latter to be a uniform Catmull-Rom spline.

Reviewed in part by fatherbushido, discussed in rP18925.

Note: See TracTickets for help on using tickets.