HELP!! 3D --> 2D math problems..
- To: mathgroup at smc.vnet.net
- Subject: [mg24399] HELP!! 3D --> 2D math problems..
- From: * <keen at ulster.net>
- Date: Wed, 12 Jul 2000 23:13:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
hello!! i'm having a little problem with what i guess would be spherical trig.. i divided the Earth into 12 identical pentagons - 3 at each pole and 6 around the equator.. using Lightwave i rendered an image of each of the pentagons face on.. i know the coordinates, in latitude and longitude, of each point of each pentagon.. so given the coordinates of a location somewhere on the globe - NYC (40N42, 74W00) for example - i can tell which pentagon it's in.. my problem is plotting an accurate representation of the location on the rendered image.. i was given very helpful math on how to convert 3D coordinates to 2D which i translated (roughly) into this code: -- -- -- -- -- -- -- -- -- -- loc = location coord centre = pentagon centre coord sloc = loc - centre -- subtract centre from loc coord to make it relative to the centre of the pentagon theta = (PI * sloc.horz) / 180 -- convert coord to radians.. phi = (PI * sloc.vert) / 180 r = 3.5530 -- radius of the sphere in Lightwave x = r * sin(theta) * cos(phi) y = r * sin(phi) z = r * cos(theta) * cos(phi) f = .4696 -- focal length in Lightwave d = 6.3682 -- the distance between the centre of the sphere and the viewer in Lightwave sx = (f * x) / (d - z) -- 2D coords of the loc.. sy = (f * y) / (d - z) -- -- -- -- -- -- -- -- -- -- the problem i am encountering now is that this doesn't account for the way latitude curves around the globe - this is especially noticable around the poles where it would be most severe.. it is treating all locations as if the pentagon is centred on the equator and prime meridian.. does this make sense?? any help to get this routine to work would be greatly appreciated.. thanks!! y'r pal -kK