edu.mines.jtk.interp.NearestGridder3 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edu-mines-jtk Show documentation
Show all versions of edu-mines-jtk Show documentation
Java packages for science and engineering
/****************************************************************************
Copyright 2009, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.interp;
import java.util.logging.Logger;
import edu.mines.jtk.dsp.Sampling;
import edu.mines.jtk.mesh.TetMesh;
import edu.mines.jtk.util.Check;
import static edu.mines.jtk.util.ArrayMath.*;
/**
* Nearest neighbor gridding of scattered samples of 3D functions f(x1,x2,x3).
* Each gridded value is the value of the nearest known (scattered) sample.
* This gridder can also compute distances to those nearest known samples.
* @author Dave Hale, Colorado School of Mines
* @version 2009.07.22
*/
public class NearestGridder3 implements Gridder3 {
/**
* Constructs a nearest neighbor gridder with specified known samples.
* The specified arrays are copied; not referenced.
* @param f array of known sample values f(x1,x2,x3).
* @param x1 array of known sample x1 coordinates.
* @param x2 array of known sample x2 coordinates.
* @param x3 array of known sample x3 coordinates.
*/
public NearestGridder3(float[] f, float[] x1, float[] x2, float[] x3) {
setScattered(f,x1,x2,x3);
}
/**
* Computes nearest neighbor distances and values.
* @param s1 sampling for coordinate x1.
* @param s2 sampling for coordinate x2.
* @param s3 sampling for coordinate x3.
* @param d array of distances to nearest known samples.
* @param g array of nearest known sample values.
*/
public void computeDistancesAndValues(
Sampling s1, Sampling s2, Sampling s3, float[][][] d, float[][][] g)
{
int n1 = s1.getCount();
int n2 = s2.getCount();
int n3 = s3.getCount();
for (int i3=0; i3