Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
generate random points from a given point and given distance

Subject: generate random points from a given point and given distance

From: sh

Date: 20 Jun, 2013 08:11:07

Message: 1 of 5

Hi,
How can i generate a random point from a given point (x,y) and in a distance of R?
thanks

Subject: generate random points from a given point and given distance

From: Nasser M. Abbasi

Date: 20 Jun, 2013 08:22:11

Message: 2 of 5

On 6/20/2013 3:11 AM, sh wrote:
> Hi,
> How can i generate a random point from a given point (x,y) and in a distance of R?
> thanks
>

may be:

random points inside circle of radius R, centered at (x,y):

----------------------
x =.5;
y =.6;
R =2;

theta = 2*pi*rand(1);
randx = x+R*cos(theta);
randy = y+R*sin(theta);
-------------------------

--Nasser

Subject: generate random points from a given point and given distance

From: sh

Date: 20 Jun, 2013 09:08:10

Message: 3 of 5

thanks Nasser,
but i want to generate these points on the perimeter of the circle.
i.e. points that are exactly have R distance from center
thanks

Subject: generate random points from a given point and given distance

From: Barry Williams

Date: 20 Jun, 2013 10:25:13

Message: 4 of 5

"sh " <lolipopkitty@yahoo.com> wrote in message <kpugpq$4ve$1@newscl01ah.mathworks.com>...
> thanks Nasser,
> but i want to generate these points on the perimeter of the circle.
> i.e. points that are exactly have R distance from center
> thanks

How about:

>> t = rand(100,1)*2*pi;
>> x = cos(t);
>> y = sin(t);
>> plot(x,y,'b.')

Barry

Subject: generate random points from a given point and given distance

From: sh

Date: 20 Jun, 2013 12:19:10

Message: 5 of 5

"Barry Williams" <barry.r.williamsnospam@saic.com> wrote in message <kpula9$ec3$1@newscl01ah.mathworks.com>...
> "sh " <lolipopkitty@yahoo.com> wrote in message <kpugpq$4ve$1@newscl01ah.mathworks.com>...
> > thanks Nasser,
> > but i want to generate these points on the perimeter of the circle.
> > i.e. points that are exactly have R distance from center
> > thanks
>
> How about:
>
> >> t = rand(100,1)*2*pi;
> >> x = cos(t);
> >> y = sin(t);
> >> plot(x,y,'b.')
>
> Barry

That`s it ;)
many thanks dear friends...

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us