Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PiecewiseBicubicSplineInterpolatingFunction #509

Open
hondogo opened this issue Feb 14, 2023 · 2 comments
Open

Add PiecewiseBicubicSplineInterpolatingFunction #509

hondogo opened this issue Feb 14, 2023 · 2 comments
Labels
feature A new feature request good first issue The issue awaits its hero. Contributions are welcome

Comments

@hondogo
Copy link

hondogo commented Feb 14, 2023

Please add function (for multiplatform) like org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction.

Purpose:
To be able to interpolate points for surface given by points matrix there is a need for such function.

Link to Slack thread with initial request intent

@SPC-code SPC-code added the feature A new feature request label Feb 14, 2023
@SPC-code
Copy link
Contributor

It would be best if you could clarify what use case do you have. What input and output data formats and what additional parameters do you have. It it is quite easy to replicate CM behavior. But maybe we could do better.

@SPC-code SPC-code added this to the 0.4 milestone Feb 14, 2023
@hondogo
Copy link
Author

hondogo commented Feb 14, 2023

Here is a peace of code that uses interpolation function (Apache Commons Math implementation):

import org.apache.commons.math3.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction
import org.apache.commons.math3.exception.OutOfRangeException

class InterpolatingSurface(
    xPoints: DoubleArray,
    yPoints: DoubleArray,
    zPoints: Array<DoubleArray>
) : Surface {

    init {
        require(zPoints.size == xPoints.size)
        require(zPoints.all { it.size == yPoints.size })
    }

    private val interpolator = PiecewiseBicubicSplineInterpolatingFunction(
        /* x = */ xPoints,
        /* y = */ yPoints,
        /* f = */ zPoints
    )

    override fun z(x: Double, y: Double): Double {
        return try {
            interpolator.value(x, y)
        } catch (_: OutOfRangeException) {
            Double.NaN
        }
    }
}

@SPC-code SPC-code added the good first issue The issue awaits its hero. Contributions are welcome label Jun 11, 2023
@SPC-code SPC-code removed this from the 0.4 milestone Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature request good first issue The issue awaits its hero. Contributions are welcome
Projects
None yet
Development

No branches or pull requests

2 participants