This commit is contained in:
gac-x11ma
2026-06-24 13:28:45 +02:00
parent b658ce0a15
commit 97ecbd2af2
113 changed files with 5193 additions and 456368 deletions
@@ -0,0 +1,76 @@
package sparseviewer.interp;
public class InterpolationResult {
private final Grid2D grid;
private final float[] pixels;
private final double zmin;
private final double zmax;
public InterpolationResult(Grid2D grid, float[] pixels) {
this.grid = grid;
this.pixels = pixels;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (int i = 0; i < pixels.length; i++) {
float v = pixels[i];
if (Float.isNaN(v) || Float.isInfinite(v)) {
continue;
}
if (v < min) {
min = v;
}
if (v > max) {
max = v;
}
}
if (min == Double.POSITIVE_INFINITY || max == Double.NEGATIVE_INFINITY) {
min = 0.0;
max = 1.0;
}
if (min == max) {
min -= 1.0;
max += 1.0;
}
this.zmin = min;
this.zmax = max;
}
public Grid2D getGrid() {
return grid;
}
public float[] getPixels() {
return pixels;
}
public double getZMin() {
return zmin;
}
public double getZMax() {
return zmax;
}
public float getValueAtIndex(int ix, int iy) {
if (ix < 0 || iy < 0 || ix >= grid.getWidth() || iy >= grid.getHeight()) {
return Float.NaN;
}
return pixels[iy * grid.getWidth() + ix];
}
public float getNearestValue(double x, double y) {
int ix = grid.xToIndex(x);
int iy = grid.yToIndex(y);
return getValueAtIndex(ix, iy);
}
}