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;
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Sphere and Cylinder vs Ellipsoid problem
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..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement