[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pixel Location in 3D Space?



You need to look at map projections. The bottom line is there is more than one way to do it. Probably the easiest is to divide your 2D image into length of -180 to 180 degrees of longitude and height -90 to 90 degrees of latitude.

x = r * cos(lon) * sin(lat)
y = r * sin(lon) * sin(lat)
z = r * cos(lat)

where:
[x, y, z] are the 3D coords
r = radius of sphere
lat = latitude
lon = longitude

double check me on this, this is just off the top of my head.

Justin

----- Original Message ----- From: "HandyGM" <klachemin@xxxxxxxxxxx>
To: <pygame-users@xxxxxxxx>
Sent: Tuesday, December 20, 2005 8:45 PM
Subject: Re: [pygame] Pixel Location in 3D Space?



Knapp wrote:
I think I don't understand you question.
Are you maping a 2d pixel map to a 3d triangle surface and want to know how
to do it?

Basically, yes. I have a polygon defined in the texture map (2d), and a polygon defined in the model (3d). For each pixel in the texture map, what would its 3D vertices be?