I'm working on a 3d sphere as accepted Earth, when mouse pointer over sphere, want to show earth longitude and latitude
in degrees, therefore must know how i can convert 3d object to 2d object
need anybody help
Printable View
I'm working on a 3d sphere as accepted Earth, when mouse pointer over sphere, want to show earth longitude and latitude
in degrees, therefore must know how i can convert 3d object to 2d object
need anybody help
First you'd have to do a ray-sphere colision detect, then you'd have to translate cartesian to spherical coordinates then to longitude and latitude.
Good luck.
what do you mean about "ray-sphere colision detect", sorry about me, i'm not have enough knowledge about 3d graphics.
i'm using flat cartesian and spherical coordinates for my app. I am drawing a sphere with longitude and latitude on screen, but I could not succeed in reading inverse coordinate, i thing my formulas which i used to calculate longtitude and latýtude is not corrcect, because result is not true.
if you could explain in detail, you will be much more help me
How are you drawing your globe? DX? or something else.?
My Globe program is as follow
Public Sub Globe3D()
For teta = 0 To 180 Step 10
stepalfa = 1
For alfa = 0 To 180 Step 10
GlobePoint(stepteta, stepalfa).x = GlobeRadius_
* HSin(teta) * HCos(alfa)
GlobePoint(stepteta, stepalfa).y = GlobeRadius_
* HSin(teta) * HSin(alfa)
GlobePoint(stepteta, stepalfa).z = GlobeRadius * HCos(teta)
stepalfa = stepalfa + 1
Next alfa
stepteta = stepteta + 1
Next teta
End Sub
Public Sub Rotate(anglex,angley)
For m = 1 To 19
For p = 1 To 19
GlobeRotated(m, p).y = GlobePoint(m, p).z * HSin(anglex)_
+ GlobePoint(m, p).y * HCos(anglex)
GlobeRotated(m, p).z = GlobePoint(m, p).z * HCos(anglex_
) - GlobePoint(m, p).y * HSin(anglex)
GlobeRotated(m, p).x = GlobeRotated(m, p).z * HSin(angley_
) + GlobePoint(m, p).x * HCos(angley)
GlobeRotated(m, p).z = GlobeRotated(m, p).z * HCos(angley_
) - GlobePoint(m, p).x * HSin(angley)
GlobeScreen(m, p).x = centerx + GlobeRotated(m, p).x
GlobeScreen(m, p).y = centery + GlobeRotated(m, p).z
Next p
Next m
End Sub
and the image on the screen is attached to e-mail
my globe is 3d globe and is rotated
On my project the important point is the MOUSE POINTER
when mouse pointer is on the globe, i must calculate long & latitude coords where the mouse pointer is, this means my ray is mouse pointer and always is hitting the globe.
because mouse pointer always is moving on screen so my aim is to calculate long & latitude from mouse screen coords, but i don't know where can i start.
thanks riis for your valuable answer, is the (x,y) screen coords?
in LatLong2XYZ x, y and z are spherical coordinates (in 3d space)
in Arctan2 x and y are just two variables, which are not related to coordinates