Jump to content
  • Advertisement
Sign in to follow this  

Sphere and Cylinder vs Ellipsoid problem

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

I managed to come up with an Ellipsoid vs Ellipsoid intersection test that seems to work perfectly. But when one of the ellipsoids has the same radius on all axis (ie. a sphere) it doesn't work correctly. Is a sphere not just an ellipsoid like I described? The effect I get is like testing a sphere against 2 other spheres one on top of the other, kinda like a figure 8. I have the same problem with Cylinders. My Cylinder/Sphere test works fine, but I'm not sure how to transform the cylinder into ellipsoid space. Any pointers would be appreciated..
function ellipsoidVellipsoid(pos1, pos2: TAffinevector; r1, r2: TAffinevector): single;
    dir: TAffinevector;
    ar1, ar2: single;
    pos1 := vectordivide(pos1, r1);
    pos2 := vectordivide(pos2, r1);
    r2 := vectordivide(r2, r1);
    r1 := affinevectormake(1, 1, 1);

    dir := vectornormalize(vectorsubtract(pos2, pos1));
    ar1 := Sqrt(sqr(r1[0] * dir[0]) +
        sqr(r1[1] * dir[1]) +
        sqr(r1[2] * dir[2]));
    ar2 := Sqrt(sqr(r2[0] * dir[0]) +
        sqr(r2[1] * dir[1]) +
        sqr(r2[2] * dir[2]));

    result := SphereVSphere(pos1, pos2, ar1, ar2);

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!