public static Vector3 GetNormalSquared(Vector3 v)
{
float h = 0.001f;
if (ImageData != null)
{
v = new Vector3((int)Math.Round(v.X), (int)Math.Round(v.Y), (int)Math.Round(v.Z));
h = 1.0f;
}
float dxp = Sample(new Vector3(v.X + h, v.Y, v.Z));
float dxm = Sample(new Vector3(v.X - h, v.Y, v.Z));
float dyp = Sample(new Vector3(v.X, v.Y + h, v.Z));
float dym = Sample(new Vector3(v.X, v.Y - h, v.Z));
float dzp = Sample(new Vector3(v.X, v.Y, v.Z + h));
float dzm = Sample(new Vector3(v.X, v.Y, v.Z - h));
//Vector3 gradient = new Vector3(map[x + 1, y] - map[x - 1, y], map[x, y + 1] - map[x, y - 1]);
Vector3 gradient = new Vector3(dxp - dxm, dyp - dym, dzp - dzm);
return gradient;
}