public class CoordinateTransform
extends java.lang.Object
out_o = sum_i ( a_io * in_i )where in_i are input coordinates,
The optimum coefficients minimize this least squares error:
sum_oj [ sum_i ( a_io * in_ij ) - out_oj ]^2where in_ij is an input array of different coordinates,
Normal equations (indexed by k) are solved independently for each o:
sum_ij ( in_kj * in_ij * a_io ) = sum_j ( in_kj * out_oj )The Hessian is
H = sum_j ( in_kj * in_ij )
and the gradient b = - sum_j ( in_kj * out_oj )
The solution is undamped and may not behave as you want for degenerate solutions.
If the linear transform needs a translation shift, then include a constant as one of the input coordinates.
| Constructor and Description |
|---|
CoordinateTransform(int dimensionOut,
int dimensionIn)
Constructor sets number of input and output coordinates.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(double[] out,
double[] in)
Add an observation of a set of input and output coordinates
You should add enough of these to determine (or overdetermine)
a unique linear mapping.
|
double[] |
get(double[] in)
For a given set of input coordinates,
return the linearly predicted output coordinates.
|
public CoordinateTransform(int dimensionOut,
int dimensionIn)
dimensionOut - Number of output coordinates.dimensionIn - Number of input coordinates.public void add(double[] out,
double[] in)
out - A set of observed output coordinates
with an unknown linear relationship to input coordinates.in - A set of observed input coordinates
that should be linearly combined to calculate each of the
output coordinates.
To allow translation, include a constant 1.public double[] get(double[] in)
in - A set of input coordinates