Quantcast
Viewing all articles
Browse latest Browse all 40524

ofVec3f the closest value in the array

you can also do:

ofVec3f col;
auto nearest = std::min_element(colors.begin(), colors.end(), [&](Colors&c){
    return c.squareDistance(col);
});

which returns an iterator to nearest element in the original vector so later you can do:

nearest->x = ...;

or

ofVec3f v = *nearest;

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>