static void sphere_scale_error(double[] xi, double[] fi, object obj)
{
double xofs = xi[0];
double yofs = xi[1];
double zofs = xi[2];
double xscale = xi[3];
double yscale = xi[4];
double zscale = xi[5];
// double avg_samples = xi[6];
// scale out of range
//if (xscale < 0.8 || yscale < 0.8 || zscale < 0.8)
// xscale = yscale = zscale = 1;
int a = 0;
foreach (var d in (List<Tuple<float, float, float>>) obj)
{
double x = d.Item1;
double y = d.Item2;
double z = d.Item3;
double err = avg_samples -
Math.Sqrt(Math.Pow((x + xofs)*xscale, 2) + Math.Pow((y + yofs)*yscale, 2) +
Math.Pow((z + zofs)*zscale, 2));
fi[a] = err;
a++;
}
}
}