# Sphere and Cylinder vs Ellipsoid problem

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

## 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;
var
dir: TAffinevector;
ar1, ar2: single;
begin
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);
end;

##### Share on other sites
Oops, wrong forum. Feel free to reply just the same. :)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
634151
• Total Posts
3015825
×