Simple (or should be) Trigonomic question

  • Thread starter Thread starter Yay
  • Start date Start date
Click For Summary

Homework Help Overview

The discussion revolves around converting between Cartesian coordinates and latitude/longitude for an object moving on the surface of a sphere, specifically the Earth. The original poster is attempting to implement this in a programming context and is facing challenges with the conversion from a position vector back to latitude and longitude.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • The original poster describes their method for converting latitude and longitude to a Cartesian position vector and expresses difficulty in reversing this process. They explore the relationship between the Z component and the angle phi, questioning the correct approach to find theta from the X and Y components.

Discussion Status

Some participants suggest reconsidering the use of spherical coordinates, while the original poster confirms they are required to use Cartesian coordinates. The original poster later reports resolving their issue regarding the relationship between secant and cosine, indicating progress in their understanding.

Contextual Notes

The original poster mentions a requirement to use Cartesian coordinates, which may influence their approach and understanding of the problem.

Yay
Messages
6
Reaction score
0

Homework Statement



I'm making a program that tracks an object moving along the surface of a sphere (earth). I'm using a set of Cartesian coordinates who origin is the center of the Earth and Z directed through the north pole, X the greenwich meridian at the equator, and Y is 90 degrees to everyone else.

Given a Lat/Long value I can convert into a position vector by doing:

phi = (90 - lat)*pi/180
theta = long*pi/180

vector.x = sin(phi)*cos(theta)
vector.y = sin(phi)*sin(theta)
vector.z = cos(phi)

After moving my object around I need to convert it back into lat / long. At the moment I'm just trying to take a position in Lat/long, convert it into my position vector, draw it on a sphere , then convert it back.

I know my conversion TO the position vector is working properly since it points to the right spot on a sphere. What I can't get right is the conversion FROM the vector back to lat long.

Homework Equations


See above.


The Attempt at a Solution



I thought I could find phi from the Z component, then solve X and Y simultaneously for theta. So since Z = cos(phi), I thought easy phi = 1/cos(Z).

Only that didn't work. Sat down, thought for a bit, played around with cos and sec, and realized cos and sec aren't inverse operations (which I thought for sure they were) so sec(cos(a)) != a.

There's a simple little rule for finding going from A = cos(angle), to an expression for the angle, when you know A. Can someone please tell me what it is ? I've spent hours on something I thought I learned back in Highschool !
 
Physics news on Phys.org
Is there a reason you aren't using spherical coordinates instead of cartesian coordinates? Seems like you're making it extra hard on yourself.

Here are some trig notes from wikipedia if they help:

http://en.wikipedia.org/wiki/Trig

.
 
We were told to use Cartesian, not spherical. Gonna have another read through the wiki page, its got to be there somewhere.
 
I worked it out. Turns out sec is the reciprocal of cos, arccos is the inverse function. I'm annoyed I forgot something so basic, but at least its all working now.
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 11 ·
Replies
11
Views
1K
Replies
1
Views
1K
Replies
6
Views
2K
Replies
3
Views
2K
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 70 ·
3
Replies
70
Views
6K