samedi 4 août 2018

Sorting std::vector of vec2(x, y) points [duplicate]

This question already has an answer here:

How can I sort std::vector<vec2> containing vec2(x, y) coordinates based on their distance from point 0.0?

Example: I'd like to sort this:

std::vector<vec2> vec = { vec2(9,9), vec2(1,1), vec2(5,5), vec2(4,4) };

Into this:

std::vector<vec2> vec = { vec2(1,1), vec2(4,4), vec2(5,5), vec2(9,9) };

Aucun commentaire:

Enregistrer un commentaire