LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need a random x,y coord inside a circle of radius r

I need a random (x,y) coordinate inside of a circle of radius r centered at the origin (0,0).  Been bashing my brain out over it for days.
Thanks.
0 Kudos
Message 1 of 5
(3,295 Views)
Forgot to give you what version i was using, Labview 7.0
0 Kudos
Message 2 of 5
(3,293 Views)
Here's a crude example.  It takes a random X coordinate between 0 and radius, and generates a Y coord from there.



The best I can do as a vi is 7.1 ...  Sorry.

Message Edited by Day on 08-31-2006 04:17 PM

0 Kudos
Message 3 of 5
(3,290 Views)
A more natural solution would be (IMHO):

Ton (in 8 you can combine the r/theta XY conversion into one function)

Message Edited by TonP on 08-31-2006 10:49 PM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 5
(3,278 Views)
First we need to know what you mean by "random". For example TonP's solution wil NOT give you a homogenous random distribution, but will give you more dense probabilities near the center. If you want a flat 2D distribution within the circle area, you need to do it differently.
 
The attached image shows the outcome of 10000 random tries for something similar to TonP's code (Left graph, upper code segment). An alternative approach is shown in the lower code, which gives a truly flat 2D distribution (right graph).
 
 

(In the above example, the radius was set to 2).

Message Edited by altenbach on 08-31-2006 02:50 PM

Message 5 of 5
(3,272 Views)