Two formula's with two unknown.

414184

New member
Joined
Jul 3, 2020
Messages
12
Hello. I am trying to convert an longitude and latitude (GPS coordinate) to x, y. And back from x, y to longitude and latitude.
The formulas:
x = R * cos(lat) * cos(lon)
y = R * cos(lat) * sin(lon)
R = radius of the earth = 6317000 meter

As far as i could come:
Formulas.png
In the last formula i would like to calculate lon. In this case i know the y and x axis. So lon is the only unknown factor.
But how to get the lon value out of this formula?

All help would be really appreciated
 
What do your x and y mean? What aren't you using x, y, and z? I think a geometrical understanding of what you are doing will help a lot.

And it looks like you used cosh where you meant the inverse cosine. Those are entirely different things.

If I were just trying to solve your two equations for lon as a function of x and y, I would first eliminate lat, perhaps by dividing one equation by the other ...
 
What do your x and y mean? What aren't you using x, y, and z? I think a geometrical understanding of what you are doing will help a lot.

And it looks like you used cosh where you meant the inverse cosine. Those are entirely different things.

If I were just trying to solve your two equations for lon as a function of x and y, I would first eliminate lat, perhaps by dividing one equation by the other ...
x, y are just for cartesian coordinate system in 2D and are known. I have tried to elimate lat as u see in the last formula. From there i need to get the lon value.. I indeed meant the inverse cosine.
 
x, y are just for cartesian coordinate system in 2D and are known. I have tried to elimate lat as u see in the last formula. From there i need to get the lon value.. I indeed meant the inverse cosine.

But a point on the globe is not on a plane! My best guess about your goal is that you are projecting the globe onto a plane using a polar orthographic projection.

Please try following my suggestion to eliminate lat, which is far, far simpler than what you did! Just divide your second equation by your first.
 
If you look in your trig book, you see y/x and some inverse tangent. Maybe try something simple like that?
 
Those formulas look weird to me. Perhaps they are approximations meant to apply to relatively small areas using one of the poles as the origin.

[MATH]x = r * cos ( \theta ) * cos( \phi ) \text { and } y = r * cos (\theta ) sin(\phi ).[/MATH]
Assuming I am right that the origin is at a pole, then

[MATH]x = 0 \implies \theta = 90 \text {degrees, and } \phi = 0 \text { degrees.}[/MATH]
So if x is zero, you know latitude and longitude without any math.

If x is not zero but y is zero, longitude is zero and

[MATH]\theta = arccos \left ( \dfrac{x}{r} \right ).[/MATH]
[MATH]x \ne 0 \text { and } y \ne 0 \implies \dfrac{y}{x} = tan(\phi) \implies \\ \phi = arctan \left ( \dfrac{y}{x} \right ) \implies \theta = arccos \left ( \dfrac{y}{r sin (\phi )} \right ).[/MATH]
 
Last edited:
Those formulas look weird to me. Perhaps they are approximations meant to apply to relatively small areas using one of the poles as the origin.

[MATH]x = r * cos ( \theta ) * cos( \phi ) \text { and } y = r * cos (\theta ) sin(\phi ).[/MATH]
Assuming I am right that the origin is at a pole, then

[MATH]x = 0 \implies \theta = 90 \text {degrees, and } \phi = 0 \text { degrees.}[/MATH]
So if x is zero, you know latitude and longitude without any math.

If x is not zero but y is zero, longitude is zero and

[MATH]\theta = arccos \left ( \dfrac{x}{r} \right ).[/MATH]
[MATH]x \ne 0 \text { and } y \ne 0 \implies \dfrac{y}{x} = tan(\phi) \implies \\ \phi = arctan \left ( \dfrac{y}{x} \right ) \implies \theta = arccos \left ( \dfrac{y}{r sin (\phi )} \right ).[/MATH]
Naamloos.png
Works perfect, thanks! I am indeed using this for areas of around 30x30 meters max. Do you have any idea how this method is called actually and how they derived these formula's? I found them on several sites but i would like to know how they did get these formula's.
 
Please tell us where you got the formulas, so we can have some idea what you think they are doing for you. They are not what you would use to map a small region, unless you live at the north pole. I can tell you the right formulas to use, once I am sure what you want to do.
 
Dr. Peterson told you what it is called, namely a polar orthographic projection, but with your formulas there is an implicit assumption that the origin is at either the north or south pole. (You can locate the origin anywhere, but the formulas become more complex.)


It is a conformal projection, a weird name because it means that areas and shapes can be weirdly distorted. I had thought (but based on Dr. Peterson's most recent post, my thought was apparently in error) that for small areas, the relative distortion would be trivial. My intuition cannot explain why the relative distortion in a very small area would not be trivial, but Dr. Peterson undoubtedly knows more about it than I do because I have never studied projective geometry.

The basic idea is that the earth is sliced in two to make a transparent hemisphere put on a piece of graph paper, and we plot the shadows on the piece of graph paper of the points on the sphere in which we are interested.
 
Please tell us where you got the formulas, so we can have some idea what you think they are doing for you. They are not what you would use to map a small region, unless you live at the north pole. I can tell you the right formulas to use, once I am sure what you want to do.
I want to calculate the position of a unknown node. As reference i got at least three known nodes with a GPS coordinate. I will use triangulation or trilateration algorithm to calculate the unknown node (based on my IRL measurements which has the best results, measuring the angle or measuring the distance by using signal strength). The know nodes stands on random spots around 30 meter apart. So in a area of like 30x30m with 3 known nodes with a GPS coordinate (lat/lon) and knowns distances or angles from the known nodes to the unknown node i would like to calculate the position of the unknown node using trilateration or triangulation.
 
Dr. Peterson told you what it is called, namely a polar orthographic projection, but with your formulas there is an implicit assumption that the origin is at either the north or south pole. (You can locate the origin anywhere, but the formulas become more complex.)


It is a conformal projection, a weird name because it means that areas and shapes can be weirdly distorted. I had thought (but based on Dr. Peterson's most recent post, my thought was apparently in error) that for small areas, the relative distortion would be trivial. My intuition cannot explain why the relative distortion in a very small area would not be trivial, but Dr. Peterson undoubtedly knows more about it than I do because I have never studied projective geometry.

The basic idea is that the earth is sliced in two to make a transparent hemisphere put on a piece of graph paper, and we plot the shadows on the piece of graph paper of the points on the sphere in which we are interested.
long_lat1.jpg
Naamloos.png

I see what u mean. the y-as is always unique but the x-as actually mirrors.. That might cause problems. U have maybe a other formula which give unique numbers.
 
Naamloos.png


The deviation is quit big aswell..
Above example is 15.16m and the formula gives me 12.9.

I did the same with a distance of 30m in google maps and the answer gave me 25.6.

Hope u guys have a better solution.
 
You haven't really answered my questions.

First, you aren't using these formulas to "calculate the position of a unknown node"; you will have done that already. You're trying to plot the point you've located on a map, right? And you need to use some appropriate projection.

Second, you haven't told me where you found the formulas. It's essential that we know what was said about the formulas, in order to show you whether they were claimed to do what you want to do.

I told you (and JeffM really agrees) that the projection you are using is good near its origin, which is at the north pole. It is terrible in other locations, unless it is modified. He gave you the Wikipedia link for this general type of projection; if you read it, you should have seen the appropriate formulas for a map whose origin is at a different location (namely, yours). Here are the formulas, where the center of the map is at long0, lat0:

x = R cos(lat) sin(long - long0)​
y = R (cos(lat0) sin(lat) - sin(lat0) sin(lat) cos(long - long0))​

Then they show the inverse formulas.
 
I am not disagreeing with Dr. Peterson at all. What I said was that my initial intuition was wrong. That is not surprising because I have never studied projective geometry.

A sphere is curved; a paper map is not. That means that any attempt to model a sphere on a plane will introduce distortions. Different projections minimize different distortions, at least locally, but this minimization of one thing distorts something else. For example, Mercator's projection preserves local shapes, but grossly distorts relative areas at different latitudes.

This is why Dr. Peterson keeps asking you what you are trying to do. Is it important to preserve distances or angles or what? What will be the eventual scale of what you are trying to do: errors of a millimetre will not matter if your eventual scale is going to be kilometres. I think he is trying to elicit from you what error is most important for you to minimize. Then he can tell you what projection is best for your purposes.

Now, according to my son, who knows all sorts of things that I do not but is terrible at explaining them, modelling the earth as a sphere is, as is well known, a source of error in itself. You can reduce those errors by modelling the earth as an oblate spheroid, but this model too is not error free. Apparently, what is actually used in GPS systems is something called the World Geodetic System 84. At this point, he loses me, but there almost certainly is a whole literature on the math needed to develop good maps from GPS coordinates.
 
You haven't really answered my questions.

First, you aren't using these formulas to "calculate the position of a unknown node"; you will have done that already. You're trying to plot the point you've located on a map, right? And you need to use some appropriate projection.

Second, you haven't told me where you found the formulas. It's essential that we know what was said about the formulas, in order to show you whether they were claimed to do what you want to do.

I told you (and JeffM really agrees) that the projection you are using is good near its origin, which is at the north pole. It is terrible in other locations, unless it is modified. He gave you the Wikipedia link for this general type of projection; if you read it, you should have seen the appropriate formulas for a map whose origin is at a different location (namely, yours). Here are the formulas, where the center of the map is at long0, lat0:

x = R cos(lat) sin(long - long0)​
y = R (cos(lat0) sin(lat) - sin(lat0) sin(lat) cos(long - long0))​

Then they show the inverse formulas.
No i know im not using these formula's to calculate the position of a unknown node. But i need the translation from lat/lon to x, y to do my triangulation or trilateration algorithm. To get my new x, y coordinate (position of my system). From there i will translate it back to lat/lon to find my new position on earth.

I have here found the formula's:

The fixed and unknown nodes are in an area of like 30x30 meter. The translation from lat/lon to x/y would be nice to get <1 meter deviation.
 
I am not disagreeing with Dr. Peterson at all. What I said was that my initial intuition was wrong. That is not surprising because I have never studied projective geometry.

A sphere is curved; a paper map is not. That means that any attempt to model a sphere on a plane will introduce distortions. Different projections minimize different distortions, at least locally, but this minimization of one thing distorts something else. For example, Mercator's projection preserves local shapes, but grossly distorts relative areas at different latitudes.

This is why Dr. Peterson keeps asking you what you are trying to do. Is it important to preserve distances or angles or what? What will be the eventual scale of what you are trying to do: errors of a millimetre will not matter if your eventual scale is going to be kilometres. I think he is trying to elicit from you what error is most important for you to minimize. Then he can tell you what projection is best for your purposes.

Now, according to my son, who knows all sorts of things that I do not but is terrible at explaining them, modelling the earth as a sphere is, as is well known, a source of error in itself. You can reduce those errors by modelling the earth as an oblate spheroid, but this model too is not error free. Apparently, what is actually used in GPS systems is something called the World Geodetic System 84. At this point, he loses me, but there almost certainly is a whole literature on the math needed to develop good maps from GPS coordinates.
I am trying to get the position of a unknown node by using known nodes. I am getting the unknown node by trilateration (i know the location of the known nodes by GPS coordinate and i calculate the distance with signal strength). This is in a area of like 30x30m. So an error of <1 meter would be nice. I will look into your links later today. I got to go for now.
 
No i know im not using these formula's to calculate the position of a unknown node. But i need the translation from lat/lon to x, y to do my triangulation or trilateration algorithm. To get my new x, y coordinate (position of my system). From there i will translate it back to lat/lon to find my new position on earth.

I have here found the formula's:

The fixed and unknown nodes are in an area of like 30x30 meter. The translation from lat/lon to x/y would be nice to get <1 meter deviation.
That article is written by an idiot, for idiots. It never even states what it is actually about!

Did you notice a mention that "x, y and z values are specified in Cartesian coordinate system"? This tells me that my initial guess in post #2 was correct: It is not about mapping at all, but about conversion between Cartesian coordinates and spherical coordinates, which are about location anywhere in space, not on the surface of the earth. (I'm confused, though: This article doesn't give the formulas you said you found there.)

I get the impression that you are totally unaware of the concept of map projections; that isn't surprising given that your source doesn't mention them, and as I said isn't about mapping at all. What you need to do is not to "convert to x and y", but to choose a projection that will map a small region of earth as accurately as you need (as JeffM has mentioned) and find the formulas appropriate to that.

I suggest you read this article: https://en.wikipedia.org/wiki/Map_projection . I'd check the external links at the end for other sources.

But as I've said, the orthographic projection centered at your location seems like a good choice for your purposes, and we've given you the information you need to use it.

On the other hand, you need to be aware that (a) no projection is perfectly accurate, because the earth is not flat; (b) any simple formulas will be less accurate than the ideal because the earth also is not a perfect sphere; and (c) if you are judging your results against any particular map, such as Google's, you will only get the same measurements if you use the same projection they use, since their maps have the same deficiencies that all maps have. A map is not reality. Oh yes: (d), your GPS itself may not give coordinates to as much accuracy as you want. (Distances from signal strength, or directions for greatest signal strength, probably aren't as accurate as you're expecting, either.)
 
May I interject... I believe DrP is trying to tell you that the x and y in your formula are not what you think they are.

The surface of the globe is 2-dim but sitting in 3-dim space and formulas you have are precisely the x and y components of a point in spherical coordinates (wiki that for a picture). The z component is z=R•sin(lat) Without it, you don't have latitude information. If z is unspecified, then neither is lat.

I believe what you are envisioning is a linearization near a point of interest. As earth appears flat locally. You want local coordinate for the tangent plane to the sphere, in terms of latitudes and longitudes. If that's so, people can also help you with that.
 
Top