Converting longitude/latitude to x,y,z coord's

   6511   7   2
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi all,

I'm trying to convert longitude and latitude data to x,y,z coordinates but am having some problems (I'm having a “senior moment” I suppose).

After trying to recall it from memory I broke down and looked it up in a reference book but am still not getting it right.

Given a=longitude and b=latitude, the book says (for a z up world):

x = sin(b)*cos(a)
y = sin(a)*sin(b)
z = cos(b)

Intuitively it doesn't seem right for x, because I wouldn't think that latitude should be a term in the equation.

Can someone help my fading memory … ?

Thanks!


–Mark
========================================================
You are no age between space
User Avatar
Member
27 posts
Joined: July 2005
Offline
Hi Mark,

I just checked my Physics text and it has the same under “spherical coordinates”–except with theta and phi, of course. “z” is on sphere's axis. x and y depend on latitude because as you go from the equator to the poles you decrease the distance to the z axis.

What I really need is a diagram. If only I had my scanner available I could take one out of this copyrighted textbook :roll:

hope that helps,

Mike Anderson

ps. how is the realflow obj plugin coming?
User Avatar
Member
412 posts
Joined: July 2005
Offline
hey mark,

i replied to you on listserv as well but if you wanna be able to convert, you are going to need ellipsoidal height as well.

good converting resources…


http://www.ngs.noaa.gov/cgi-bin/xyz_getxyz.prl [ngs.noaa.gov]

http://www.ngs.noaa.gov/cgi-bin/xyz_getgp.prl [ngs.noaa.gov]

http://www.ga.gov.au/nmd/geodesy/datums/calcs.jsp [ga.gov.au]

hth,

dave
Dave Quirus
User Avatar
Member
543 posts
Joined: July 2005
Offline
mikela
I just checked my Physics text and it has the same under “spherical coordinates”–except with theta and phi, of course. “z” is on sphere's axis. x and y depend on latitude because as you go from the equator to the poles you decrease the distance to the z axis.

ps. how is the realflow obj plugin coming?

Hi Mike,

Thanks for the reply, I had a feeling that what I was really trying to do was convert a parametric function, surface(u,v), into x,y,z coord's, so I looked in “Advanced RenderMan” and sure ‘nough there it was! (chapter 2.2.1)

The Real Flow plugin’s new code is about half done, I just started a new job about 3 weeks ago and have been absolutely saturated with it, thus my “spare time” has been cut done significantly. I'm hoping to have the rest coded up this weekend, maybe next week. I'll have it released by the end if the month but can send you a copy as I know you've been patiently waiting; sorry for the delay, I'm feeling rather guilty getting behind on my task list. ops:

Take care,
Mark
========================================================
You are no age between space
User Avatar
Member
543 posts
Joined: July 2005
Offline
deecue
http://www.ngs.noaa.gov/cgi-bin/xyz_getxyz.prl [ngs.noaa.gov]
http://www.ngs.noaa.gov/cgi-bin/xyz_getgp.prl [ngs.noaa.gov]
http://www.ga.gov.au/nmd/geodesy/datums/calcs.jsp [ga.gov.au]

Hi Dave,

Yea, I found these the first 2 of these links too, but they didn't have the formula which is what I was after. Thanks for your help!


–Mark
========================================================
You are no age between space
User Avatar
Member
27 posts
Joined: July 2005
Offline
convert a parametric function, surface(u,v), into x,y,z coord's

Those expressions work for a unit sphere, but it gets trickier when you want to convert (u,v) to (x,y,z) for an arbitrary surface. Mario Marengo helped me think through this case, and I'd give a link to it if the odforce server weren't down… It was in the odforce VEX forum under “(u,v) to (x,y,z)”.

hoping to have the rest coded up this weekend, maybe next week

No worries! Sounds like you're plenty busy over there. At this point I only need it for my demo reel, and there are plenty of other things I can work on for now.

Mike
User Avatar
Member
321 posts
Joined: July 2005
Offline
xionmark
Hi all,

I'm trying to convert longitude and latitude data to x,y,z coordinates but am having some problems (I'm having a “senior moment” I suppose).
Given a=longitude and b=latitude, the book says (for a z up world):

x = sin(b)*cos(a)
y = sin(a)*sin(b)
z = cos(b)

-Mark

If you're in a Vex SOP, you can do:

vector uvw;
if (import(“uv”, uvw, 0)) {
// import uvw as polar coordinates
rmat = ident();
rotate(rmat, uvw.x*2*PI, {0,1,0});
rotate(rmat, (uvw.y-.5)*PI, normalize(cross({0,1,0}, {1,0,0}*rmat)));
N = {1,0,0}*rmat*uvw.z;
}


I just grabbed this from some stuff I wrote a couple of years ago, which takes U and V and converts it to an N that points in the right direction (assuming a polar-y mapping, which should be more-or-less the same as lattitude-longitude).

– Antoine
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
543 posts
Joined: July 2005
Offline
Hi Antoine,

I was in fact just in the middle of coding some of this up in VEX and you saved me some time!

This looks quite interesting and different from the translation of lat/lon to x,y,z. I think I follow it but will have to experiment a bit.


Thanks!


–Mark
========================================================
You are no age between space
  • Quick Links