simple math problem

This topic is 2463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

unfortunately my math skill is a bit lacking

I need to find the latitude and longitude of the intersection of a ray coming from the center of a sphere to the radius/surface.

What I have right now is lat=atan(z,x) and lon=asin(y) (after normalization)

Now this doesn't provide a very convincing sky-sphere, since usually you aren't in the core of the earth. What I want to do is move the origin of the ray upward closer to the surface. I guess this only changes the longitude, and it can be computed with a table.

I just need a formula to convert angle a to b, http://imageshack.us.../problem1a.png/

edit: and what is known is 'a' (or the actual ray), the radius of the sphere, and Y or height of the ray from the center of the circle

Share on other sites
Intersect the ray with the sphere, then use the formulas you already have to compute latitude and longitude.

Share on other sites
Hi Bimm,

You can determine 'b' using the law of sines. From your figure this can be expressed as,

R * sin( c) = Y * sin(pi/2 + a)

where 'c' is the angle opposite the side of length, Y. Rearranging the above expression gives,

c = asin(Y * sin(pi/2 + a) / R).

Since the internal angles of a triangle add up to pi (or 180 degrees if you prefer), we can determine b

b = a - pi/2 + asin(Y * sin(pi/2 + a) / R)

-Josh

Share on other sites
Thanks a lot, this is much better than the code I shoveled into my shader... I didn't even notice that my figure was actually a triangle lol

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 10
• Forum Statistics

• Total Topics
633652
• Total Posts
3013147
×