Jump to content
  • Advertisement
Sign in to follow this  
KKTHXBYE

Sphere line intersection at edge + rotation

This topic is 979 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

SO i want to do some kind of arcball rotation with usage of angles (pitch, yaw, roll)

however i need to convert screen coords to sphere coords,

 

so i make a ray from screen to world, and now i need to find proper coordinate on sphere ( the closest point that lies on sphere edge to the ray)

 

like in this pic: (top view)

 

sphrray.png

Edited by WiredCat

Share this post


Link to post
Share on other sites
Advertisement

Add two vectors to your eye ray to construct an orthogonal basis. A lengthy but straight forward calculation gives you what ever numericals you need. Consult numerous post on this site to check that your version of the formulas is optimal.

Share this post


Link to post
Share on other sites
Sorry, but I don't have time to figure out the precise math right now. At global level, the simplest starting point seems to be the right figure.

Set up a line orthogonal to the eye ray. It must also go through the center of the circle (let's call the center of the circle C).
Compute the point where the orthogonal line crosses with the ray line. Let's call that point P.
Compute the distance between P and C.

If it is longer than the radius of the circle, you are in the right picture situation.
Compute the point at the circle at the orthogonal line then (from C towards P, with length the radius of the circle).

If the distance is shorter, you have the left situation. Let's call the points where the ray line intersects with the circle A and B.
P is in the middle of line-piece A-B.
Distance between C and P is known already. Distance between C and both A and B is the radius of the circle. Pythagoras will tell you the length of line-pieces A to P (and B to P which is equally long).
Finally, compute length of eye to A, and length of eye to B, and take the smallest distance. Edited by Alberth

Share this post


Link to post
Share on other sites

yeah i did sphere ray intersection test if nothing was hit then i do closest poin on line test then get the fdirection from sphere center to that point normalize it and multiple by radius,

 

 

still however i have no idea how to use that data, the best thing would be if rotation matrix is identity and points -z forward +y up

now i will have to convert that to rotation i need to compute yaw pitch and roll angles out of these two points ( i reckon camera position will be in equation too. because it needs somehow to know where i hooked and where to i rotate, and then when theres rotation applied and i change camera position i can still compute points on sphere but how then apply that to modified yaw pitch roll, that confuses me as hell

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!