SteveNi Posted December 3, 2016 Share Posted December 3, 2016 Hi I want to randomly select two points from a geo input in a VEX wrangle, so far I have this: int _selectedPts[]; _selectedPts[0] = rand(@numpt); _selectedPts[1] = rand(@numpt); setattrib(geoself(),"point", "Cd", _selectedPts[0], 0, {1,0,0}, "set"); setattrib(geoself(),"point", "Cd", _selectedPts[1], 0, {1,0,0}, "set"); I searched on the VEX docs but every random function I found could only return float numbers, but I need integer numbers. How can I solve this? Quote Link to comment Share on other sites More sharing options...
Atom Posted December 3, 2016 Share Posted December 3, 2016 What about something like this..? int _selectedPts[]; _selectedPts[0] = int(fit01(rand(@ptnum),0,@numpt)); _selectedPts[1] = int(fit01(rand(@ptnum+311),0,@numpt)); setattrib(geoself(),"point", "Cd", _selectedPts[0], 0, {1,0,0}, "set"); setattrib(geoself(),"point", "Cd", _selectedPts[1], 0, {1,0,0}, "set"); rand() returns a float between 0 and 1. The fit01() remaps that into a range between 0 and number of points. Use the current point number as a random seed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.