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:
Distance calculation in sphere

Subject: Distance calculation in sphere

From: kamal abuhassan

Date: 8 Apr, 2010 20:55:23

Message: 1 of 3

I have used the following code to generate a sphere of radius 8:
[x,y,z] = sphere(30);
x=x*8;
y=y*8;
z=z*8;

for now, I am trying to calculate the distance between two points on the sphere, Can you please help me? I am also looking for a method to get all neighrong points of a certain point (on sphere) within a circle of radius 0.5 ?

Thanks,
Kamal.

Subject: Distance calculation in sphere

From: Roger Stafford

Date: 8 Apr, 2010 21:30:14

Message: 2 of 3

"kamal abuhassan" <kamal.abuhassan@hotmail.com> wrote in message <hplfrr$r8k$1@fred.mathworks.com>...
> I have used the following code to generate a sphere of radius 8:
> [x,y,z] = sphere(30);
> x=x*8;
> y=y*8;
> z=z*8;
>
> for now, I am trying to calculate the distance between two points on the sphere, Can you please help me? I am also looking for a method to get all neighrong points of a certain point (on sphere) within a circle of radius 0.5 ?
>
> Thanks,
> Kamal.

  I'll just answer your first question. If P1 = [x1,y1,z1] and P2 = [x2,y2,z2] are two vectors pointing from the center of the sphere to the two given points (x1,y1,z1) and (x2,y2,z2) on the sphere, what is the shortest great circle distance d between them?

 d = 8*atan2(norm(cross(P1,P2)),dot(P1,P2));

Roger Stafford

Subject: Distance calculation in sphere

From: kamal abuhassan

Date: 9 Apr, 2010 11:17:20

Message: 3 of 3

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hplht6$396$1@fred.mathworks.com>...
> "kamal abuhassan" <kamal.abuhassan@hotmail.com> wrote in message <hplfrr$r8k$1@fred.mathworks.com>...
> > I have used the following code to generate a sphere of radius 8:
> > [x,y,z] = sphere(30);
> > x=x*8;
> > y=y*8;
> > z=z*8;
> >
> > for now, I am trying to calculate the distance between two points on the sphere, Can you please help me? I am also looking for a method to get all neighrong points of a certain point (on sphere) within a circle of radius 0.5 ?
> >
> > Thanks,
> > Kamal.
>
> I'll just answer your first question. If P1 = [x1,y1,z1] and P2 = [x2,y2,z2] are two vectors pointing from the center of the sphere to the two given points (x1,y1,z1) and (x2,y2,z2) on the sphere, what is the shortest great circle distance d between them?
>
> d = 8*atan2(norm(cross(P1,P2)),dot(P1,P2));
>
> Roger Stafford


Thank you so much Roger
Kamal.

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