Reputation: 5302
What I do to generate a random angle is this:
float rand_angle = (float)random_.NextDouble() * MathHelper.TwoPi;
But I want to generate a random angle from range [a;b], excluding everything in the middle.
Ho Can I do it?
Upvotes: 0
Views: 3508
Reputation: 1500035
But I want to generate a random angle from range [a;b], excluding everything in the middle.
Assuming b
is greater than a
, that's just a matter of getting a value in the range [0, b - a)
and then adding a
:
float randomAngle = (float) (random.NextDouble() * (b - a) + a);
Upvotes: 5