I’ve posted this question on the Planetarion forums too ( http://pirate.planetarion.com/forum/showthread.php?s=&threadid=154550 ) and I’ve gotten a formula that detects intersection of two ellipsoids:
[(x1-x2)/(w1+w2)]^2 + [(y1-y2)/(h1+h2)]^2 + [(z1-z2)/(d1+d2)]^2 <= 1
The slight problem is that the ellipsoids HAVE to be alligned to the axes for the formula to work, but I also want to detect collisions when the objects are rotated randomly in space.
Does anyone happen to know how to accomplish this… how to alter the width/height/depth of the ellipsoid to be able to use the formula, or any other formula that’d work?
Given an ellipsoid equation of
you can parameterize any ellipsoid by x,y and z. Therefore if you are rotating or translating your ellipsoid you are changing the x,y and z parameters (ex. (x-1)^2 should translate x coord by +1). If you are changing the shape of it you are changing the a,b and c parameters (which are semi-axes).
My guess is that you are simply translating your ellipsoids using TranslateF() and RotateF() and therefore the actual equations remain constant.
You should change your code around so you affect the parameters of the equation rather than the vertices that are drawn.
Then you will have to solve two quadratic equations (ellipsoid is a quadratic surface) in order to obtain an intersection.
Hope this makes sense
PS. Check this out: http://mathworld.wolfram.com/Ellipsoid.html
[This message has been edited by EPHERE (edited 11-29-2002).]