Skip to content

Incorrect linear interpolation in MathUtils.interpolateNonZeroValues #237

Description

@herwinvw

contour[j] = contour[j-1] + ((contour[index] - contour[i-1]) / (index - i)) ;
should be
contour[j] = contour[j-1] + ((contour[index] - contour[i-1]) / (index - i + 1)) ;
As the interpolation is between index and i-1. The current code has a too big increment on contour[j-1], resulting in setting the value of contour[i-1] in contour[i].

e.g.
MathUtils.interpolateNonZeroValues(new double[]{1,0,3})) results in
[1,3,3] rather than [1,2,3].

Activity

  1. seblemaguer commented on Oct 29, 2014

    @seblemaguer
    Member

    Hello,

    thank you for the report.

    Kind regards

  2. self-assigned this
    on Oct 29, 2014
  3. psibre commented on Nov 3, 2014

    @psibre
    Member

    A unit test highlighting the issue would be great! =)

  4. added this to the 5.2 milestone on Jun 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions