简体   繁体   中英

Mapping 3d coordinates to 2d coordinates using equirectangular projection

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM