# Orientated ellipse collision

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

## Recommended Posts

Hi there. I made some ellipse to mesh collision code and it worked ok so then I wanted to make it work with an orientated ellipse. This is where it got tricky. In my original ellipse code I used a radius vector to define the ellipse and then scaled it by the inverted plane normal to get the closest point on the ellipse to a plane. For the orientated ellipse the only way I can think of to achieve this is the following procedure: 1) Take the inverse of the ellipse orientation matrix. 2) Multiply the plane normal by it. 3) Invert the rotated plane normal. 4) Scale the ellipse radius vector by the inverted, rotated plane normal. 5) Multiply the result of this by the ellipse original orientation matrix. This works but is very slow and I have to do a similar procedure to test if the closest point on a triangles edge collides with the sphere. I cant help thinking there is a simpler and faster way to do this. Any comments would be much appreciated.

##### Share on other sites
Well, to be honest, I'd take the same approach in this. The problem is far less complicated when trying to solve it in a frame of reference, where the ellipse is parallel to the system's X/Y axes.

I can think of something, but it's kinda raw and I'm not sure whether you have the required functionality from your gfx api. It should be fast though...
Since we're talking 2d, you could define a surface in memory, identical to your viewport, like a fullscreen buffer. Whenever you think that there is a possibility of collision between two objects, you can draw them in that buffer using a single color value for each. If you try to set a pixel that is not clear or its color is other than that object's color, this means that you're trying to draw over another object, thus you've found a collision. Furthermore, you have found the point of impact too.
Needless to say, it is far less accurate than the approach mentioned earlier, but speed doesn't come cheap!

##### Share on other sites
I'm trying a few different things to see what works well for me at the minute so i will definitly give your suggestion a try. I have never thought of it that way.

##### Share on other sites

http://www.gamedev.net/reference/articles/article1026.asp

• ### What is your GameDev Story?

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

• 31
• 16
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
634117
• Total Posts
3015601
×