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:
Plot latitude-longitude of a cone

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 24 Nov, 2010 11:24:04

Message: 1 of 17

Hello Matlab people!

I need to plot the latitude-longitude of a cone in my graphs (so essentially a circle).

But the funny thing is I know only the width of cone in degrees (e.g 60deg cone).

In reality if the cone (60deg) is placed at lets say 0lat, 0lon then on a latittude map it would appear as a circle having it's centre at 0lat, 180lon and radius 60 deg.

now my issue is how to get Matlab to plot the latitude-longitude of this circle (or in some cases a curve - depending on where the cone is placed) with following knowns;
1) width of the view cone in deg
2) origin

can someone give me a hint where to start?
should i consider doing it the easy way taking radius as 60deg straight away.. ?

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 24 Nov, 2010 13:05:05

Message: 2 of 17

I tried using "scircle1"
but it gives an error as 'not a valid map axes'
my map is already a latitude longitue plot!

how to go about this?

"Geant Bepi" <timothyschru_useonlywhatsbeforeunderscore@yahoo.co.uk> wrote in message <iciskk$rs1$1@fred.mathworks.com>...
> Hello Matlab people!
>
> I need to plot the latitude-longitude of a cone in my graphs (so essentially a circle).
>
> But the funny thing is I know only the width of cone in degrees (e.g 60deg cone).
>
> In reality if the cone (60deg) is placed at lets say 0lat, 0lon then on a latittude map it would appear as a circle having it's centre at 0lat, 180lon and radius 60 deg.
>
> now my issue is how to get Matlab to plot the latitude-longitude of this circle (or in some cases a curve - depending on where the cone is placed) with following knowns;
> 1) width of the view cone in deg
> 2) origin
>
> can someone give me a hint where to start?
> should i consider doing it the easy way taking radius as 60deg straight away.. ?

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 4 Dec, 2010 15:15:10

Message: 3 of 17

I still couldn't come up with a working algorithm for this problem..
appreciate if someone can shed some light in the right direction?

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 7 Dec, 2010 15:30:24

Message: 4 of 17

In other words how to represent following mathematical expression in Matlab;
let's represent the location of the 'cone' on the sphere with following angles,
theta1,2 = latitude
phi1,2 = longitude
alfa = cone width

theta1, phi1 and alfa are known values
so we have;
cos(theta1)*cos(theta2)*cos(phi1)*cos(phi2) + cos(theta1)*cos(theta2)*sin(phi1)*sin(phi2) + sin(theta1)sin(theta2) = cos(alfa)

now what I need is to draw the contour of, f(theta2,phi2) = LHS

I tried several methods on matlab without much help...
I think I missing something here in my attempt to expressing the function "f" with two unknowns in Matlab.

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 7 Dec, 2010 15:59:21

Message: 5 of 17

I really hope someone out there is able to understand this problem....I'm sitting on this far too long now :)

Subject: Plot latitude-longitude of a cone

From: Kelly Kearney

Date: 7 Dec, 2010 16:48:05

Message: 6 of 17

"Geant Bepi" <timothyschru_useonlywhatsbeforeunderscore@yahoo.co.uk> wrote in message <icj2i1$k8p$1@fred.mathworks.com>...
> I tried using "scircle1"
> but it gives an error as 'not a valid map axes'
> my map is already a latitude longitue plot!
>
> how to go about this?
>

> > now my issue is how to get Matlab to plot the latitude-longitude of this circle (or in some cases a curve - depending on where the cone is placed) with following knowns;
> > 1) width of the view cone in deg
> > 2) origin
> >
> > can someone give me a hint where to start?
> > should i consider doing it the easy way taking radius as 60deg straight away.. ?

If I'm clear on what you're attempting (not sure exactly what the cone you refer to looks like, but plotting a geographic circle I can do), then scircle1 should be the right function. That function itself only calculates the small circle coordinates, and doesn't plot them, so your error must be arising from a different command (plotm?).

When you say your plot is a longitude-latitude plot, do you mean it's a map axes, created via axesm? Or simply that it's a cartesian axis labeled with longitude and latitude? The plotm command can only target a map axis of the former type. If you don't need to worry about map projections for your purposes, just use plot on a regular axis.

If this doesn't solve the problem, try posting a small snippet of code that causes the error.

-Kelly

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 13 Dec, 2010 16:40:26

Message: 7 of 17

"Kelly Kearney" <kakearney@nospamgmail.com> wrote in message <idlog5$rdc$1@fred.mathworks.com>...
> "Geant Bepi" <timothyschru_useonlywhatsbeforeunderscore@yahoo.co.uk> wrote in message <icj2i1$k8p$1@fred.mathworks.com>...
> > I tried using "scircle1"
> > but it gives an error as 'not a valid map axes'
> > my map is already a latitude longitue plot!
> >
> > how to go about this?
> >
>
> > > now my issue is how to get Matlab to plot the latitude-longitude of this circle (or in some cases a curve - depending on where the cone is placed) with following knowns;
> > > 1) width of the view cone in deg
> > > 2) origin
> > >
> > > can someone give me a hint where to start?
> > > should i consider doing it the easy way taking radius as 60deg straight away.. ?
>
> If I'm clear on what you're attempting (not sure exactly what the cone you refer to looks like, but plotting a geographic circle I can do), then scircle1 should be the right function. That function itself only calculates the small circle coordinates, and doesn't plot them, so your error must be arising from a different command (plotm?).
>
> When you say your plot is a longitude-latitude plot, do you mean it's a map axes, created via axesm? Or simply that it's a cartesian axis labeled with longitude and latitude? The plotm command can only target a map axis of the former type. If you don't need to worry about map projections for your purposes, just use plot on a regular axis.
>
> If this doesn't solve the problem, try posting a small snippet of code that causes the error.
>
> -Kelly

THANK YOU for the reply Kelly.

Well 'scircle1' works but not quite the way I want.

I want to find a way to have matlab use my calculation when determining the latitude longitude of the boundary.

For e.g., i calculate the point in space as a 1x3 matrix;
n=[sin(theta);0;cos(theta)] % theta is known!
now how can I convert this matrix 'n' to latitude and longitude so that I can use it as the input to 'scircle1'

appreciate your help!
thx

Subject: Plot latitude-longitude of a cone

From: Rob Comer

Date: 14 Dec, 2010 14:15:26

Message: 8 of 17

"Geant Bepi" <timothyschru_useonlywhatsbeforeunderscore@yahoo.co.uk> wrote in message <ie5i9q$bja$1@fred.mathworks.com>...> For e.g., i calculate the point in space as a 1x3 matrix;
> n=[sin(theta);0;cos(theta)] % theta is known!
> now how can I convert this matrix 'n' to latitude and longitude so that I can use it as the input to 'scircle1'

It looks as if theta is an angle in radians, but you need to provide a complete definition.

It looks as if n is a unit vector in some 3-D Cartesian system, but which system? That's critical.

If the system is ECEF, for example (see the definition here: http://www.mathworks.com/help/toolbox/map/ref/geodetic2ecef.html), and theta is the distance from the north pole on a unit sphere (such that 0 <= theta <= pi), then you'd in the y == 0 plane and, more specifically, on the prime meridian. So longitude would be 0. And latitude (in radians) would be pi/2 - theta. Try to verify this for yourself. But bear in mind that while self-consistent this interpretation is just a wild guess, because you haven't defined your angle or coordinates.

Rob Comer
Mapping Toolbox Development
Mathworks

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 15 Dec, 2010 13:51:15

Message: 9 of 17

"Rob Comer" <rob.comer.nospam@mathworks.com> wrote in message <ie7u5u$cs2$1@fred.mathworks.com>...

Ok I'll try to elaborate everything I mentioned in above posts.

There's a circle above a sphere ( for e.g., a view-cone of a satellite orbiting the Earth). I have to plot the area covered by the circle (so, essentially a small-circle with a radius "r" (scircle1)) on a latitude-longitude map.

There are several view-cones (circles) looking at the Earth in different angles.
<<<< for e.g., if it's only one circle then the calculation becomes simpler.
theta1,2 = latitude
phi1,2 = longitude
alfa = cone width (radius)

theta1, phi1 and alfa are known values
Thus;
cos(theta1)*cos(theta2)*cos(phi1)*cos(phi2) + cos(theta1)*cos(theta2)*sin(phi1)*sin(phi2) + sin(theta1)sin(theta2) = cos(alfa)

then I can draw the corresponding circle in Matlab as;
[atheta1, aphi1] = antipode(theta1,phi1) % antipode of theta1 and phi1
[theta2, phi2]=scircle1(atheta1,phi1,alfa)
plot(theta2,phi2,'-k') >>>>

Therefore, I have the following rotation matrix from which I calculate the position and attitude of the view-cones.

R1=[cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)]
R2=[cos(pi/4) sin(pi/4) 0; -sin(pi/4) cos(pi/4) 0; 0 0 1]
so as you can see we rotate only on x and z axes.
R1R2=[3x3MATRIX]

n1=[sin(theta);0;cos(theta)] % n1 is the first circle and correspond to the 3rd column of R1R2 matrix (z axis).

angle theta is the latitude in degrees. We are on the prime meridian, so longitude is 0.
radius of the circle is also known in degrees.

Now the issue I'm confronted with is to draw n1. any ideas?
Please let me know if the information is not clear to you...

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 17 Dec, 2010 16:42:08

Message: 10 of 17

-----------------------------------
Need your attention!

help me please

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 18 Dec, 2010 16:50:28

Message: 11 of 17

anyone at least today?

Subject: Plot latitude-longitude of a cone

From: Walter Roberson

Date: 18 Dec, 2010 17:36:35

Message: 12 of 17

On 18/12/10 10:50 AM, Geant Bepi wrote:
> anyone at least today?

None of the regular posters has (to my recollection) ever given evidence
of having used the Mapping Toolbox, so I am not surprised that you have
not received any responses.

You should consider contacting Mathworks Technical Support.

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 18 Dec, 2010 17:47:04

Message: 13 of 17

Walter Roberson <roberson@hushmail.com> wrote in message <Di6Po.4415$2G7.482@newsfe13.iad>...
> On 18/12/10 10:50 AM, Geant Bepi wrote:
> > anyone at least today?
>
> None of the regular posters has (to my recollection) ever given evidence
> of having used the Mapping Toolbox, so I am not surprised that you have
> not received any responses.
>
> You should consider contacting Mathworks Technical Support.

Do you think (in your opinion) I explicitly 'have' to use the Mapping Toolbox in order to perform this task?

I'm a kindaa novice matlab user but I thought this is fairly easy task on Matlab well, at least the mathematics involved are basic and easy....

Subject: Plot latitude-longitude of a cone

From: Walter Roberson

Date: 18 Dec, 2010 18:40:20

Message: 14 of 17

On 18/12/10 11:47 AM, Geant Bepi wrote:

> Do you think (in your opinion) I explicitly 'have' to use the Mapping
> Toolbox in order to perform this task?
>
> I'm a kindaa novice matlab user but I thought this is fairly easy task
> on Matlab well, at least the mathematics involved are basic and easy....

Myself, I would prefer not to have to replicate the functionality of the
Mapping Toolbox to be able to plot arbitrary shapes on to lattitude /
longitude plots, having to take in to account the irregular spheroid
shape of the Earth.

Though in typing that, I realize that it was not clear to me whether the
circles you wanted to plot should be in Euclidean geometry or in Earth
geometry? I did not grasp from your question what the circles represent.
If they represent things that equidistant from a given surface point,
then they could be quite irregular indeed if elevation is taken in to
account (e.g., in a canyon) and need to take in to account the curvature
of the Earth even if distance from the center of the Earth is considered
to be fixed.

Subject: Plot latitude-longitude of a cone

From: Rob Comer

Date: 19 Dec, 2010 23:26:04

Message: 15 of 17

"Geant Bepi" <timothyschru_useonlywhatsbeforeunderscore@yahoo.co.uk> wrote in message <ieah4j$m02$1@fred.mathworks.com>...
> There's a circle above a sphere ( for e.g., a view-cone of a satellite orbiting the Earth). I have to plot the area covered by the circle (so, essentially a small-circle with a radius "r" (scircle1)) on a latitude-longitude map.
>
> There are several view-cones (circles) looking at the Earth in different angles.
> <<<< for e.g., if it's only one circle then the calculation becomes simpler.
> theta1,2 = latitude
> phi1,2 = longitude
> alfa = cone width (radius)
>
> theta1, phi1 and alfa are known values
> Thus;
> cos(theta1)*cos(theta2)*cos(phi1)*cos(phi2) + cos(theta1)*cos(theta2)*sin(phi1)*sin(phi2) + sin(theta1)sin(theta2) = cos(alfa)

It's not clear to my why this would be true.

> then I can draw the corresponding circle in Matlab as;
> [atheta1, aphi1] = antipode(theta1,phi1) % antipode of theta1 and phi1
> [theta2, phi2]=scircle1(atheta1,phi1,alfa)

Why construct a circle about the antipode. How does this work?

> Therefore, I have the following rotation matrix from which I calculate the position and attitude of the view-cones.
>
> R1=[cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)]
> R2=[cos(pi/4) sin(pi/4) 0; -sin(pi/4) cos(pi/4) 0; 0 0 1]
> so as you can see we rotate only on x and z axes.

But what _are_ the x and z axes? I asked about that earlier, but you didn't answer my question.

> n1=[sin(theta);0;cos(theta)] % n1 is the first circle and correspond to the 3rd column of R1R2 matrix (z axis).

> Now the issue I'm confronted with is to draw n1. any ideas?

As I explained, it looks like n1 is a unit vector, but you're calling it a circle. I'm puzzled about that.

-- Rob

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 2 Feb, 2011 16:05:04

Message: 16 of 17

Ok! I'll try to break the problem in to simpler parts.

There's a circle above a sphere ( for e.g., a view-cone of a satellite orbiting the Earth).
Plot the area covered by the circle (so, essentially a small-circle with a radius "r" (scircle1)) on a latitude-longitude map.
Consider an orbit around a perfect sphere.

We know the location of the satellite (i.e., latitude (theta), longitude(phi), altitude) and the radius of the circle (alfa). Throughout the calculation longitude and altitude remain constant.

The position and attitude of the five windows (above mentioned view-cone) of the satellite looking at different directions (one is pointed upwards and the other four are perpendicular to the one pointed upwards and perpendicular to each other) is calculated from the following rotation matrix;

 R1=[cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)]
 R2=[cos(pi/4) sin(pi/4) 0; -sin(pi/4) cos(pi/4) 0; 0 0 1]

from R1R2 matrix we get five unit vectors;
n1=[sin(atheta1); 0; cos(atheta1)];
n2=[cos(atheta1)/sqrt(2); -1/sqrt(2); -sin(atheta1)/sqrt(2)];
n3=[cos(atheta1)/sqrt(2); 1/sqrt(2); sin(atheta1)/sqrt(2)];
n4=-n2;
n5=-n3;

My problem starts here.
For n1 I used a different method and drew the area covered by the circle as follows;

Since we know latitude, longitude and radius of the circle,

[atheta1,aphi1]=antipode(theta1,phi1);
[theta2,phi2]=scircle1(atheta1,aphi1,alfa);
H = plot(phi2,theta2,'--k');

This part of the code does exactly what I want and plot the boundary of the area covered by the first circle (represented by n1), on the latitude-longitude map that I am generating. It is important to note that our final projection should be on this latitude-longitude map.

But I have no clue as to how to repeat this to n2 through n5.

Probably you already noticed that we did not need any help from the rotation matrix or n1 unit vector to draw the area covered by the first circle. Since we have five circles I calculated the above five unit vectors (n1 - n5) that represent each of the circles.

How do I move forward from here. How do I get MATLAB to solve n1 so that I can plot the area covered by it.

I hope i explained the problem clearly. Any tip, help is greatly appreciated.

Thanks

Subject: Plot latitude-longitude of a cone

From: Geant Bepi

Date: 21 Feb, 2011 12:20:21

Message: 17 of 17

"Rob Comer" <rob.comer.nospam@mathworks.com> wrote in message <iem4ac$8ef$1@fred.mathworks.com>...

>>

Is there anyone who can look at the problem I am having...
please

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