Sign in to follow this  

Ray-Ellipsoid Intersection question

Recommended Posts

Hi, I've been [trying] to make a ray tracer, but am running into a problem. I've read, 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this