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:
Uniform spiral shape creation

Subject: Uniform spiral shape creation

From: Noa Armon

Date: 15 May, 2012 10:30:07

Message: 1 of 5

Hi,

I've the following lines in order to define a spiral shape:
>> t = linspace(0,10*pi,400);
>> x = t.*cos(t)/(10*pi)*0.5;
>> y = t.*sin(t)/(10*pi)*0.5;
>> plot(x,y,'.')

How can I change the distribution of the points along the track of the spiral, so that eventually I'll have a uniform area density of point.
I assume linspace is not the answer...

Thanks,
Noa

Subject: Uniform spiral shape creation

From: Matt J

Date: 15 May, 2012 13:44:15

Message: 2 of 5

"Noa Armon" wrote in message <jotb7f$jpr$1@newscl01ah.mathworks.com>...
> Hi,
>
> I've the following lines in order to define a spiral shape:
> >> t = linspace(0,10*pi,400);
> >> x = t.*cos(t)/(10*pi)*0.5;
> >> y = t.*sin(t)/(10*pi)*0.5;
> >> plot(x,y,'.')
>
> How can I change the distribution of the points along the track of the spiral, so that eventually I'll have a uniform area density of point.
==============

You really do mean 2D "area" density? You're not just trying to have the points evenly spaced along the path of the spiral?

If so, how would you choose to quantify area density? If you define it based on the number of points occupying a square patch of area, then if you make the squares small enough, eventually you'll get uniformly 1 point per patch for any finite set of points.

Subject: Uniform spiral shape creation

From: Roger Stafford

Date: 15 May, 2012 20:24:05

Message: 3 of 5

"Noa Armon" wrote in message <jotb7f$jpr$1@newscl01ah.mathworks.com>...
> I've the following lines in order to define a spiral shape:
> >> t = linspace(0,10*pi,400);
> >> x = t.*cos(t)/(10*pi)*0.5;
> >> y = t.*sin(t)/(10*pi)*0.5;
> >> plot(x,y,'.')
>
> How can I change the distribution of the points along the track of the spiral, so that eventually I'll have a uniform area density of point.
- - - - - - - - - -
  In your equations if 's' denotes the arc length along the spiral, the following can be derived:

 dsdt = sqrt(dxdt^2+dydt^2) = k*sqrt(1+t^2)

where dsdt, dxdt, and dydt refer to derivatives of s, x, and y with respect to t and where k = 1/(10*pi)*0.5 . It does have a known integral:

 s = k/2*(t*sqrt(1+t^2)+log(t+sqrt(1+t^2)))

but this does us no good since we need the inverse of such a function and that does not seem to be readily available in explicit form.

  However we can achieve an inverse by taking the reciprocal

 dtds = 1/k/sqrt(1+t^2)

which defines a differential equation that can be solved using one of the ode solvers where s is regarded as the independent variable.

  In other words, using some kind of evenly-spaced values for s you can derive corresponding values for the parameter t that become more and more tightly spaced as you trace out the spiral so as to provide even spacing along the spiral's path.

  You can further refine this so that the intervals in s are approximately equal to the orthogonal distance between successive winds of the spiral in order to achieve some kind of approximate area-wise uniformity of points. Of course it won't be exact because arc length between points is not precisely the same as the chord length between them.

Roger Stafford

Subject: Uniform spiral shape creation

From: ImageAnalyst

Date: 15 May, 2012 22:43:08

Message: 4 of 5

Noa:
Try John D'Errico's "interparc":
http://www.mathworks.com/matlabcentral/fileexchange/34874-interparc
I think you can give it any curve and it will give you evenly spaced
coordinates along the curve.

Subject: Uniform spiral shape creation

From: Bruno Luong

Date: 16 May, 2012 06:28:08

Message: 5 of 5

"Noa Armon" wrote in message <jotb7f$jpr$1@newscl01ah.mathworks.com>...
> Hi,
>
> I've the following lines in order to define a spiral shape:
> >> t = linspace(0,10*pi,400);
> >> x = t.*cos(t)/(10*pi)*0.5;
> >> y = t.*sin(t)/(10*pi)*0.5;
> >> plot(x,y,'.')
>
> How can I change the distribution of the points along the track of the spiral, so that eventually I'll have a uniform area density of point.
> I assume linspace is not the answer...

Try this:

rmax = 30;
thetamax = 10*pi;
n = 400;

theta = sqrt(linspace(1,thetamax^2,n));
r = sqrt(linspace(1,rmax^2,n));
x = r.*cos(theta);
y = r.*sin(theta);
plot(x,y,'.')

 %Bruno

% Bruno

Tags for 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