• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

How to pick random points within radius

Status
Not open for further replies.
Level 12
Joined
Mar 24, 2011
Messages
1,082
  • Var_Real_Random_Angle = Math(random(0, 360))
  • Var_Real_Random_Distance = MAth(random(0, 1000))
  • Var_Random_Point = Offset by angle and distance(Var_Real_Random_Angle, Var_Real_Random_Distance) from Var_Centre_Point
This is close to how it should look in GUI. No WE underhand so syntax may vary but you get the idea.
 
Level 5
Joined
Jul 14, 2014
Messages
115
  • Var_Real_Random_Angle = Math(random(0, 360))
  • Var_Real_Random_Distance = MAth(random(0, 1000))
  • Var_Random_Point = Offset by angle and distance(Var_Real_Random_Angle, Var_Real_Random_Distance) from Var_Centre_Point
This is close to how it should look in GUI. No WE underhand so syntax may vary but you get the idea.
Thanks. Although I'm pretty sure that isn't the most accurate way since the angle is an integer and some points will probably never be picked especially at bigger radii. Are there any other ways?
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
You could do the math yourself lol. Is it worth the trouble though for some accuracy ? Perhaps.

Pseudo code:
Get a randomized angle
Get a randomized distance
Get X of start point
Get Y of start point
X of end point = X of start point + (dist * cos(angle))
Y of end point = Y of start point + (dist * sin(angle))
Set end point X
Set end point Y


Some of those would be custom scripts like Set X for point ;)
Also, sin & cos in war3 may or may not ;) work in rads instead of deg so you may or may not ;) have to do a conversion of the angle or use it as rad from the beginning;)
 
Level 5
Joined
Jul 14, 2014
Messages
115
You could do the math yourself lol. Is it worth the trouble though for some accuracy ? Perhaps.

Pseudo code:
Get a randomized angle
Get a randomized distance
Get X of start point
Get Y of start point
X of end point = X of start point + (dist * cos(angle))
Y of end point = Y of start point + (dist * sin(angle))
Set end point X
Set end point Y


Some of those would be custom scripts like Set X for point ;)
Also, sin & cos in war3 may or may not ;) work in rads instead of deg so you may or may not ;) have to do a conversion of the angle or use it as rad from the beginning;)
I see thanks. Looks like jass will be handy here. Is this way any slower than just picking a random point in region with a native function?
 
Status
Not open for further replies.
Top