1
votes

I am currently working on eeg signals, so here basically we have electrodes which are placed on head of a person and we get 3d coordinates of each electrodes so basically i am trying to find 2d coordinates from these 3d coordinates but with the help of equirectangular projection ( the same way how we project globe on a plane paper). Here are the few links for better understanding: https://www.earthdatascience.org/courses/use-data-open-source-python/intro-vector-data-python/spatial-data-vector-shapefiles/geographic-vs-projected-coordinate-reference-systems-python/

https://www.coursera.org/lecture/introduction-gis-mapping/associating-points-from-3d-to-2d-y7kIx

https://mathworld.wolfram.com/MercatorProjection.html

1
with 3d coordinates you mean (x,y,z) right? and the 2d coordinates should be longitude latitude on a sphere?joostblack
or not longitude latitude but x,y on a 2d planejoostblack
yes, the same, x and y.thanksNeil

1 Answers

1
votes

I think it should be the following but maybe you can confirm if this is correct:

import math

def cartesian_to_spherical(x,y,z):
    r=math.sqrt(x**2+y**2+z**2)
    theta=math.acos(z/r)
    phi=math.atan(y/x)
    return r,theta,phi

def spherical_to_mercator(r,theta,phi):
    x=theta
    y=0.5*math.log((1+math.sin(phi))/(1-math.sin(phi)))
    return x,y


r,theta,phi=cartesian_to_spherical(2,3,1) # fill in your x,y,z here
x,y=spherical_to_mercator(r,theta,phi)
print("x = ",x," y = ",y)