2D coordinate coordination

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.:)

+3
source share
2 answers

, , (1D, 2D ND) <= 1.
, .

double max = maximum (|vector| for each vector in 'data');
foreach (Vector v : data) {
    li.add(v / max);
}

1.

, . , no delta.

+5

. , . , . , 0 1.

+1

Source: https://habr.com/ru/post/1768028/


All Articles