Jump to content
  • Advertisement
Sign in to follow this  
sandoicchi

Ray-Ellipsoid Intersection question

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

Hi, I've been [trying] to make a ray tracer, but am running into a problem. I've read, http://www.gamedev.net/community/forums/topic.asp?topic_id=308119 and implemented, but am having a problem. Basically, my ray-sphere intersection checker is receiving a lower value t for a sphere that *should* be farther away than another sphere. So I have two overlapping spheres, but wrong order. Here's my algorithm. Each sphere is only translated and scaled, so I manually set the values rather than invert the transformation matrix and multiply it. Translate and Scale: |Sx 0 0 Tx| |0 Sy 0 Ty| |0 0 Sz Tz| |0 0 0 1 | inverse of that is |1/Sx 0 0 -Tx/Sx| |0 1/Sy 0 -Ty/Sy| |0 0 1/Sz -Tz/Sz| |0 0 0 1 | So then I have my ray origin point and direction, and do the following newOrig.x = (1/Sx)*(ray.x - Tx) newOrig.y = (1/Sy)*(ray.y - Ty) newOrig.z = (1/Sz)*(ray.z - Tz) newD.x = (1/Sx)*rayD.x newD.y = (1/Sy)*rayD.y newD.z = (1/Sz)*rayD.z normalize(newDir) And then do the intersection with a unit sphere at origin with that ray. But like I said, this is returning smaller time values for the wrong sphere. Can anyone see a (likely obvious) problem I'm missing? Thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
Ah yes, that fixed the problem. Thanks very much! Oy, so much wasted time on that, can't believe I didn't realize what I had wrong.

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!