Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
988 views
in Technique[技术] by (71.8m points)

math - how map 2d grid points (x,y) onto sphere as 3d points (x,y,z)

I have a set of 2d grid points (x,y) that I want to map/project onto a sphere as 3d points (x,y,z).

I realize there will be some warping towards the poles as abs(y) increases but my grid patch will only cover a portion of the sphere near the equator so severe warping will be avoided.

I'm having trouble finding the right equations for that.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Paraphrased from the wikipedia article on Mercator projection:

Given a "mapping sphere" of radius R,
the Mercator projection (x,y) of a given latitude and longitude is:
   x = R * longitude
   y = R * log( tan( (latitude + pi/2)/2 ) )

and the inverse mapping of a given map location (x,y) is:
  longitude = x / R
  latitude = 2 * atan(exp(y/R)) - pi/2

To get the 3D coordinates from the result of the inverse mapping:

Given longitude and latitude on a sphere of radius S,
the 3D coordinates P = (P.x, P.y, P.z) are:
  P.x = S * cos(latitude) * cos(longitude)
  P.y = S * cos(latitude) * sin(longitude)
  P.z = S * sin(latitude)

(Note that the "map radius" and the "3D radius" will almost certainly have different values, so I have used different variable names.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...