I need to implement a function that normalizes coordinates. I define normalization as (please suggest a better term if Im wrong):
Match records in a dataset from their natural range to values from 0 to 1.
Now it was easy in one dimension:
static List<float> Normalize(float[] nums)
{
float max = Max(nums);
float min = Min(nums);
float delta = max - min;
List<float> li = new List<float>();
foreach (float i in nums)
{
li.Add((i - min) / delta);
}
return li;
}
I also need a 2D version and you need to keep the aspect ratio unchanged. But I have some math problems.
Although the code is sent in C #, the answers do not have to be.
Thanks in advance.:)
source
share