Click here to Skip to main content
15,889,034 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Selective randomization Pin
Luc Pattyn21-Aug-07 1:39
sitebuilderLuc Pattyn21-Aug-07 1:39 
GeneralRe: Selective randomization Pin
Kevnar21-Aug-07 8:26
Kevnar21-Aug-07 8:26 
GeneralRe: Selective randomization Pin
cp987621-Aug-07 13:47
cp987621-Aug-07 13:47 
Question2D random generator Pin
vlasto7715-Aug-07 23:02
vlasto7715-Aug-07 23:02 
AnswerRe: 2D random generator Pin
cp987616-Aug-07 0:15
cp987616-Aug-07 0:15 
AnswerRe: 2D random generator Pin
El Corazon16-Aug-07 3:54
El Corazon16-Aug-07 3:54 
AnswerRe: 2D random generator Pin
yoaz18-Aug-07 9:12
yoaz18-Aug-07 9:12 
AnswerRe: 2D random generator Pin
Russell'19-Aug-07 3:07
Russell'19-Aug-07 3:07 
Simple way:
Assuming
r = random number from 0 to 1
Xmin and Xmax = limit value of X
Ymin and Ymax = limit value of Y
Then
generate X = Xmin + r * (Xmax - Xmin) [and Y = Ymin + r * (Ymax - Ymin) ]
test if the distance from (X,Y) to the last valid (X,Y) generated is great than a the desired value, if not generate another point (X,Y)

Complex way:
Use the polar coordinates (it will become a not uniform distribution)
Start point is the last valid point (X,Y) found, now you need to generate the new point as a direction and a distance to move it.
First generate a random angle uniformely from 0 to 360 degrees.
Then generate a random distance uniformely from a minimal to a maximal distance: the minimal distance is the desired minimal distance from 2 consecutive points. The max distance is the simple calculation of the border of the rectangle moving with the found angle.
(when the maximal apceptable distance is less then the minimal distance then this means that this angle is not valid, the rectangle border is too near,...so the solution is simply to generate another random angle value)




Russell

QuestionColour Shades ( Quick...before Luc / CPallini answers.) Pin
Malcolm Smart15-Aug-07 2:24
Malcolm Smart15-Aug-07 2:24 
AnswerRe: Colour Shades ( Quick...before Luc / CPallini answers.) Pin
IdUnknown15-Aug-07 4:29
IdUnknown15-Aug-07 4:29 
AnswerRe: Colour Shades ( Quick...before Luc / CPallini answers.) Pin
Luc Pattyn15-Aug-07 4:42
sitebuilderLuc Pattyn15-Aug-07 4:42 
GeneralRe: Colour Shades ( Quick...before Luc / CPallini answers.) Pin
mabo4216-Aug-07 0:59
mabo4216-Aug-07 0:59 
GeneralRe: Colour Shades ( Quick...before Luc / CPallini answers.) Pin
Luc Pattyn16-Aug-07 1:02
sitebuilderLuc Pattyn16-Aug-07 1:02 
GeneralRe: Colour Shades ( Quick...before Luc / CPallini answers.) Pin
mabo4216-Aug-07 1:16
mabo4216-Aug-07 1:16 
NewsThe origins of calculus Pin
73Zeppelin14-Aug-07 12:49
73Zeppelin14-Aug-07 12:49 
GeneralRe: The origins of calculus Pin
Luc Pattyn14-Aug-07 14:15
sitebuilderLuc Pattyn14-Aug-07 14:15 
GeneralRe: The origins of calculus Pin
73Zeppelin14-Aug-07 21:21
73Zeppelin14-Aug-07 21:21 
GeneralRe: The origins of calculus Pin
A Noteworthy Programmer22-Aug-07 16:05
A Noteworthy Programmer22-Aug-07 16:05 
GeneralRe: The origins of calculus Pin
73Zeppelin23-Aug-07 0:19
73Zeppelin23-Aug-07 0:19 
GeneralRe: The origins of calculus Pin
A Noteworthy Programmer24-Aug-07 7:14
A Noteworthy Programmer24-Aug-07 7:14 
GeneralRe: The origins of calculus Pin
A Noteworthy Programmer24-Aug-07 8:05
A Noteworthy Programmer24-Aug-07 8:05 
GeneralRe: The origins of calculus Pin
73Zeppelin24-Aug-07 10:31
73Zeppelin24-Aug-07 10:31 
GeneralRe: The origins of calculus Pin
A Noteworthy Programmer25-Aug-07 3:52
A Noteworthy Programmer25-Aug-07 3:52 
GeneralRe: The origins of calculus Pin
Dan Neely23-Aug-07 2:40
Dan Neely23-Aug-07 2:40 
GeneralRe: The origins of calculus Pin
Maximilien15-Aug-07 3:17
Maximilien15-Aug-07 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.