Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of GPS coordinates #10

Open
N445 opened this issue Dec 21, 2022 · 6 comments
Open

Support of GPS coordinates #10

N445 opened this issue Dec 21, 2022 · 6 comments

Comments

@N445
Copy link

N445 commented Dec 21, 2022

Is your feature request related to a problem? Please describe.
Nope

Describe the solution you'd like
Possibility to use GPS coordinates like : 24.59017° S, 104.89785° E or 24.59017° N, 104.89785° O

Describe alternatives you've considered
No alternative, but maybe use mathematical equation like : https://stackoverflow.com/a/1185413/8714792

@fsiegwald
Copy link

+1

@shiipou
Copy link

shiipou commented Dec 21, 2022

To convert Lat, Long coordinates to X, Y, Z coordinates, you can use the following steps:

  • First, you need to obtain the latitude and longitude coordinates in decimal degrees.
  • Then, you can convert the latitude and longitude coordinates to radians by using the following formulas:

lat_rad = lat * (math.pi / 180)
lon_rad = lon * (math.pi / 180)

  • Next, you can use the radius of the planet (in meters) and the latitude and longitude in radians to calculate the X, Y, and Z coordinates using the following formulas:

x = radius * math.cos(lat_rad) * math.cos(lon_rad)
y = radius * math.cos(lat_rad) * math.sin(lon_rad)
z = radius * math.sin(lat_rad)

Here is an example code snippet in python that demonstrates how to convert Star Citizen Lat, Long coordinates to X, Y, Z coordinates:

import math

def lat_long_to_xyz(lat, lon, radius):
  lat_rad = lat * (math.pi / 180)
  lon_rad = lon * (math.pi / 180)
  x = radius * math.cos(lat_rad) * math.cos(lon_rad)
  y = radius * math.cos(lat_rad) * math.sin(lon_rad)
  z = radius * math.sin(lat_rad)
  return (x, y, z)

# Example usage
lat = 37.7749
lon = -122.4194
radius = 6371e3 # radius of Earth in meters
x, y, z = lat_long_to_xyz(lat, lon, radius)
print(f'X: {x}, Y: {y}, Z: {z}')

This code will convert the latitude and longitude coordinates for San Francisco (37.7749, -122.4194) to X, Y, Z coordinates using the radius of the Earth (6371 km). The output should be:

X: -4497386.945769128, Y: -5391794.184545608, Z: 3966723.4312408617

Note that the X, Y, and Z coordinates are in meters. You may need to adjust the radius value depending on the planet or celestial body you are working with.

@Valalol
Copy link
Owner

Valalol commented Dec 21, 2022

Thanks, you all for the comment, I will add that in the next update.
@shiipou In Star Citizen, it's a bit more complicated tho because you have to account for the height of the POI.
Some edge cases are Bennyhenge or any space wrecks that can't be located with your formulas.
Good thing is that I already have the frontend inputs for lat long height and OMs I just don't have the logic behind it.
image
image

@shiipou
Copy link

shiipou commented Dec 23, 2022

@shiipou In Star Citizen, it's a bit more complicated tho because you have to account for the height of the POI.
@Valalol

You probably can just add the altitude, save the radius of each moon/planet, and addition the altitude to the radius to get the radius to use in the formula of my previous comment.

I think that'll work.

OM still a good way, because used by many databases but it's disabled in your app currently.

I don't think you need height when you use OM, because triangulating already take care of the 3D if you use precise value of OM distance.

If you need help for the algorithm, you can mention me with your needs.

@Valalol
Copy link
Owner

Valalol commented Dec 23, 2022

I don't think you need height when you use OM, because triangulating already take care of the 3D if you use precise value of OM distance.

You do because doing triangulation with 3 spheres still gives you 2 possible points

@shiipou
Copy link

shiipou commented Dec 23, 2022

@Valalol You're right, that's needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants