Jump to content

How to calculate real distances?


Recommended Posts

If I have two points - specified by latitude and longitude, how can I determine the distance between those two points, assuming both points are at sea level? What is the maths to work that out? Will it be different depending on what body you are on? I'm interested in the Mun at the moment.

If my rover is at point x (lat/long available) and my base is at point y (lat/long available), how do I work out the distance between those two points, assuming both points are at sea level (which they won't be, but a margin of error is acceptable). Thx.

Edited by togfox
Link to comment
Share on other sites

You're looking for the great circle distance in spherical geometry: http://en.wikipedia.org/wiki/Great-circle_distance


d = r * acos( sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(|long2 - long1|) )

r is the radius of the sphere, you could use the average altitude of your two points plus the sea level radius to get a more accurate result than just using sea level radius. |long2 - long1| should be the included angle between the two longitudes (e.g. if the longitudes were 170 and -170, the difference would be 20 degrees).

Link to comment
Share on other sites

Don' take my word for it, but my assumption is this. The Mun is a sphere more or less. I'm pretty sure the info button about the planets gives the circumference(or it might be diameter) of the body. Either way, you can find the circumference from the diameter. Then there are how many longitude lines around a planet, is it 360 or 180?

Anyways, i believe the mun has a diameter of 200km. So the circumference would be 200 times pi, being 628.31. That is the circumference of the mun.

I think if you divide that circumference by the amount of latitude lines/ longitude lines around the whole body, you should be able to find the distance between two any two lines, sort-of?

If you know how many latitude and longitude lines are between your rover and your base, the rest should be easy. :D

Link to comment
Share on other sites

Don' take my word for it, but my assumption is this. The Mun is a sphere more or less. I'm pretty sure the info button about the planets gives the circumference(or it might be diameter) of the body. Either way, you can find the circumference from the diameter. Then there are how many longitude lines around a planet, is it 360 or 180?

Anyways, i believe the mun has a diameter of 200km. So the circumference would be 200 times pi, being 628.31. That is the circumference of the mun.

I think if you divide that circumference by the amount of latitude lines/ longitude lines around the whole body, you should be able to find the distance between two any two lines, sort-of?

If you know how many latitude and longitude lines are between your rover and your base, the rest should be easy. :D

This is all true if you're at the equator. But as you approach the poles, the longitude lines become closer together and you have to account for that (with the handy equation posted above).

Link to comment
Share on other sites

You may also like to investigate Rhumb Lines, which are a much easier way to navigate but somewhat longer than Great Circle routes. [says the man who once managed to miss the entire Caribbean and arrive in S. America instead]

Link to comment
Share on other sites

The great circle route is what passes for a "straight line" on the surface of a sphere. If you drive in a straight line in any direction you will do a great circle you just need to pick the initial direction so that you arrive at your target. This may be obvious, but, as long as your destination isn't too far around the other side of the planet/moon you can simply set the target to your destination and then steer to put the target marker on your navball vertically below the center spot. If you have to detour around a terrain feature then just put the target marker back under the center when you are past it.

Edit: This is also a useful when flying planes though if your plane is stable and flies a nice straight course you only really need to set the initial direction...

Edited by Padishar
Link to comment
Share on other sites

Stupid question I already know the answer to - if I use the formula in post #2 what unit will my answer be?

If r is in meters then surely my answer is in meters? I'm using r = 600,000 + altitude above sea level.

I'm drifting a very small amount (think of minor lateral movement when landing) and I'm getting values in the 10,000's. This would suggest my small wobble is moving me 10 km's. :mad:

Here are some values for fun:

lat 1: -0.059226971

lat 2: -0.075008348

long 1: -74.668487549

long 2: -74.658233643

altitude: 600286

This is hovering around KSP at 286m above sea level. And at this tiny speed I've found that 9 decimal places is absolutely necessary to get a meaningful result. (If you use excel, be sure to convert to radians before cos/sin) ;)

Link to comment
Share on other sites

If you drive in a straight line in any direction you will do a great circle you just need to pick the initial direction so that you arrive at your target.

No, that's the point of Rhumb Lines. Except at cardinal compass points a Great Circle route does not cross lines of latitude at a constant angle. If you follow a constant direction you'll follow a Rhumb Line, which is easier but longer than the equivalent Great Circle.

It's all a bit of obtuse navigation though - as you say, it's a lot simpler to set your destination as target if you can and just work by the navball.

Link to comment
Share on other sites

No, a rhumb line is a course of constant compass heading, which is not what you get if you drive in a "straight" line. You can see this easily if you put a ship in an inclined orbit and keep the ship pointing prograde with the horizon on the navball horizontal for a complete orbit. You will see your compass heading change as you go around the orbit, e.g. if, at the start of the orbit you are going north east (45 deg) then a quarter of the way round you will be going due east (90 deg) and on the other side of the planet you will be going south east (135 deg). Exactly the same thing happens if you "orbit" by driving a "straight" line on the surface...

The point of rhumb lines is that, in practice, you can't fly or sail in a straight line due to wind and currents etc. and all you have to measure your direction is a compass so a course that requires the same compass heading throughout the journey is much easier to do. These days, autopilot systems are easily capable of following great circle routes at variable compass headings though I believe commercial flights usually still use rhumb lines as it is easier for communicating course requirements from the ground.

Edited by Padishar
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...