• Advertisement
Sign in to follow this  

simple math problem

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

If you intended to correct an error in the post then please contact us.

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, [url="http://imageshack.us/photo/my-images/405/problem1a.png/"]http://imageshack.us.../problem1a.png/[/url]

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement