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 Distribution of Points about a sphere

Subject: Uniform Distribution of Points about a sphere

From: Christopher

Date: 23 Aug, 2010 08:34:04

Message: 1 of 9

Hello,

I am trying to distribute points uniformly about the surface of a sphere using the spiral distribution detailed in the following paper 'Comparison pf Various Spherical Antenna Array Element Distributions'.

It details a method by Rakhmanov et al, the details as follows:
0<theta<pi,
0<phi<2*pi,
Thetak=arccos(hk),
hk=-1+2(k-1)/(N-1), 1<k<N,
Phik=(Phik(-1)+((3.6)/sqrt(N))*1/sqrt(1-hk^2))*mod(2*pi), 2<k<N-1,
Phik(1)=Phik(N)=0

I have tried to implement this using the following code but the points are non-uniform down the opposing sides of the sphere:

N=100;
k=1:N;
k=fliplr(k);
hk=-1+(2.*(k-1))./(N-1);
Thetak=acos(hk);
Thetak=fliplr(Thetak);
Phik(1)=0;
for n=2:N-1;
   Phik(n)=mod((Phik(n-1)+(3.6./sqrt(N)).*1/sqrt(1-hk(n).^2)),2*pi);
end
Phik(1)=0;
Phik(N)=2*pi;
R=ones(size(Thetak));
[x1 y1 z1]=sph2cart(Thetak,Phik,R);
plot3(x1,y1,z1,'o')
axis equal
view([90 0])

Does anybody have an idea of where I might be going wrong? Thank you for your time in advance.

Subject: Uniform Distribution of Points about a sphere

From: Image Analyst

Date: 23 Aug, 2010 12:25:04

Message: 2 of 9

What toolboxes do you have (type ver on the command line)? Do you have the Mapping toolbox? (I don't but perhaps there is something in there that might help.)

Subject: Uniform Distribution of Points about a sphere

From: Christopher

Date: 23 Aug, 2010 18:05:09

Message: 3 of 9

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <i4tpb0$m5f$1@fred.mathworks.com>...
> What toolboxes do you have (type ver on the command line)? Do you have the Mapping toolbox? (I don't but perhaps there is something in there that might help.)

Hi, thanks for replying.

No I don't have that tool box. The code/equation derivation is supposed to just give uniformly spaced spherical coordinates. Not looking for anything to fancy just wondering if there is anything obviously wrong with my code. I was thinking it might have something to do with how I have implemented the mod function?

Subject: Uniform Distribution of Points about a sphere

From: someone

Date: 23 Aug, 2010 18:57:21

Message: 4 of 9

"Christopher " <chris_quested@yahoo.co.uk> wrote in message <i4tbps$oii$1@fred.mathworks.com>...
> Hello,
>
> I am trying to distribute points uniformly about the surface of a sphere using the spiral distribution detailed in the following paper 'Comparison pf Various Spherical Antenna Array Element Distributions'.
>
> It details a method by Rakhmanov et al, the details as follows:
> 0<theta<pi,
> 0<phi<2*pi,
> Thetak=arccos(hk),
> hk=-1+2(k-1)/(N-1), 1<k<N,
> Phik=(Phik(-1)+((3.6)/sqrt(N))*1/sqrt(1-hk^2))*mod(2*pi), 2<k<N-1,
> Phik(1)=Phik(N)=0
>
> I have tried to implement this using the following code but the points are non-uniform down the opposing sides of the sphere:
>
> N=100;
> k=1:N;
> k=fliplr(k);
> hk=-1+(2.*(k-1))./(N-1);
> Thetak=acos(hk);
> Thetak=fliplr(Thetak);
> Phik(1)=0;
> for n=2:N-1;
> Phik(n)=mod((Phik(n-1)+(3.6./sqrt(N)).*1/sqrt(1-hk(n).^2)),2*pi);
> end
> Phik(1)=0;
> Phik(N)=2*pi;
> R=ones(size(Thetak));
> [x1 y1 z1]=sph2cart(Thetak,Phik,R);
> plot3(x1,y1,z1,'o')
> axis equal
> view([90 0])
>
> Does anybody have an idea of where I might be going wrong? Thank you for your time in advance.

Just a guess, but are you sure about using the fliplr
function on k to compute hk which in turn is used on Phik?
(Thetak then gets flipped again.)

It seems to me that Phik and Thetak are not
indexed to the same k, but I could be wrong.

Subject: Uniform Distribution of Points about a sphere

From: Roger Stafford

Date: 23 Aug, 2010 19:42:05

Message: 5 of 9

"Christopher " <chris_quested@yahoo.co.uk> wrote in message <i4tbps$oii$1@fred.mathworks.com>...
> Hello,
>
> I am trying to distribute points uniformly about the surface of a sphere using the spiral distribution detailed in the following paper 'Comparison pf Various Spherical Antenna Array Element Distributions'.
>
> It details a method by Rakhmanov et al, the details as follows:
> 0<theta<pi,
> 0<phi<2*pi,
> Thetak=arccos(hk),
> hk=-1+2(k-1)/(N-1), 1<k<N,
> Phik=(Phik(-1)+((3.6)/sqrt(N))*1/sqrt(1-hk^2))*mod(2*pi), 2<k<N-1,
> Phik(1)=Phik(N)=0
>
> I have tried to implement this using the following code but the points are non-uniform down the opposing sides of the sphere:
>
> N=100;
> k=1:N;
> k=fliplr(k);
> hk=-1+(2.*(k-1))./(N-1);
> Thetak=acos(hk);
> Thetak=fliplr(Thetak);
> Phik(1)=0;
> for n=2:N-1;
> Phik(n)=mod((Phik(n-1)+(3.6./sqrt(N)).*1/sqrt(1-hk(n).^2)),2*pi);
> end
> Phik(1)=0;
> Phik(N)=2*pi;
> R=ones(size(Thetak));
> [x1 y1 z1]=sph2cart(Thetak,Phik,R);
> plot3(x1,y1,z1,'o')
> axis equal
> view([90 0])
>
> Does anybody have an idea of where I might be going wrong? Thank you for your time in advance.
- - - - - - - -
  Your quoted ranges for theta and phi are:

  0<theta<pi and 0<phi<2*pi,

whereas the ranges for theta and phi in sph2cart are:

 0<=theta<=2*pi and -pi/2<=phi<=+pi/2.

This suggests to me that phi and theta are reversed from what you are assuming in using sph2cart and also that sph2cart's phi is off by pi/2. The fact that sqrt(1-hk^2)) (= sin(theta)) occurs in the denominator of the increment for Phik would also strongly imply that; it should make the increments of Phik larger near the two extremes of theta at: 0 and pi. You had better check your authors' definitions for theta and phi. There are varying definitions for spherical coordinates.

  I have not been able to figure out where the constant 3.6 comes from in the authors' formula for incrementing Phik. Do you know?

  I should point out that doing a mod(~,2*k) ought to be unnecessary if you are transforming coordinates back to cartesian. Taking sines and cosines would automatically do that for you since they have a period of 2*pi.

Roger Stafford

Subject: Uniform Distribution of Points about a sphere

From: Roger Stafford

Date: 23 Aug, 2010 20:18:04

Message: 6 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i4uiuc$9ah$1@fred.mathworks.com>...
> Your quoted ranges for theta and phi are:
>
> 0<theta<pi and 0<phi<2*pi,
>
> whereas the ranges for theta and phi in sph2cart are:
>
> 0<=theta<=2*pi and -pi/2<=phi<=+pi/2.
>
> This suggests to me that phi and theta are reversed from what you are assuming in using sph2cart and also that sph2cart's phi is off by pi/2. The fact that sqrt(1-hk^2)) (= sin(theta)) occurs in the denominator of the increment for Phik would also strongly imply that; it should make the increments of Phik larger near the two extremes of theta at: 0 and pi. You had better check your authors' definitions for theta and phi. There are varying definitions for spherical coordinates.
>
> I have not been able to figure out where the constant 3.6 comes from in the authors' formula for incrementing Phik. Do you know?
>
> I should point out that doing a mod(~,2*k) ought to be unnecessary if you are transforming coordinates back to cartesian. Taking sines and cosines would automatically do that for you since they have a period of 2*pi.
>
> Roger Stafford
- - - - - - - -
  I should have given you what I would consider the appropriate transformation to cartesian coordinates (for unit radius) in your problem.

 x = cos(Phik).*sin(Thetak);
 y = sin(Phik).*sin(Thetak);
 z = cos(Thetak);

  You will note that this causes the increments in z to be of uniform size (as I suspect they should be.)

Roger Stafford

Subject: Uniform Distribution of Points about a sphere

From: Christopher

Date: 23 Aug, 2010 21:09:20

Message: 7 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i4ul1s$rc6$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i4uiuc$9ah$1@fred.mathworks.com>...
> > Your quoted ranges for theta and phi are:
> >
> > 0<theta<pi and 0<phi<2*pi,
> >
> > whereas the ranges for theta and phi in sph2cart are:
> >
> > 0<=theta<=2*pi and -pi/2<=phi<=+pi/2.
> >
> > This suggests to me that phi and theta are reversed from what you are assuming in using sph2cart and also that sph2cart's phi is off by pi/2. The fact that sqrt(1-hk^2)) (= sin(theta)) occurs in the denominator of the increment for Phik would also strongly imply that; it should make the increments of Phik larger near the two extremes of theta at: 0 and pi. You had better check your authors' definitions for theta and phi. There are varying definitions for spherical coordinates.
> >
> > I have not been able to figure out where the constant 3.6 comes from in the authors' formula for incrementing Phik. Do you know?
> >
> > I should point out that doing a mod(~,2*k) ought to be unnecessary if you are transforming coordinates back to cartesian. Taking sines and cosines would automatically do that for you since they have a period of 2*pi.
> >
> > Roger Stafford
> - - - - - - - -
> I should have given you what I would consider the appropriate transformation to cartesian coordinates (for unit radius) in your problem.
>
> x = cos(Phik).*sin(Thetak);
> y = sin(Phik).*sin(Thetak);
> z = cos(Thetak);
>
> You will note that this causes the increments in z to be of uniform size (as I suspect they should be.)
>
> Roger Stafford


Roger thank you so much for such a concise answer. Simply placing the standard spherical to cartesian transform that you detailed above has done the job. I should have tried this in the first place!

With regards to the constant 3.6, the author uses this to assign the packing density. The constant is not the optimum but is a good compromise due to the distances in the hexagonal lattice that the derivation is based on shrinking at certain points.

Many thanks for your help again.

Chris

Subject: Uniform Distribution of Points about a sphere

From: Bruno Luong

Date: 23 Aug, 2010 21:59:07

Message: 8 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message
> I have not been able to figure out where the constant 3.6 comes from in the authors' formula for incrementing Phik. Do you know?

Roger,

I find the reference here, section 5: http://www.math.vanderbilt.edu/~esaff/texts/155.pdf

Bruno

Subject: Uniform Distribution of Points about a sphere

From: Roger Stafford

Date: 23 Aug, 2010 23:03:08

Message: 9 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <i4uqvb$k62$1@fred.mathworks.com>...
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message
> > I have not been able to figure out where the constant 3.6 comes from in the authors' formula for incrementing Phik. Do you know?
>
> Roger,
>
> I find the reference here, section 5: http://www.math.vanderbilt.edu/~esaff/texts/155.pdf
>
> Bruno
- - - - - - - -
  Thanks, Bruno. I suspected there was something of a heuristic nature to that constant, 3.6 .

Roger Stafford

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