How Can I Handle Collisions with Ovals in My Code?

0
13
Asked By CuriousCoder42 On

I'm trying to incorporate oval (or elliptical) collisions into my existing project, where I currently handle collisions with circles and rectangles. My main goal is to use elongated circles, or ovals, identified in my 'circ' tables with properties for each axis elongation (xl and yl). While I'm pretty solid with math, I'm finding it challenging to figure out how to approach the coding aspect of detecting these collisions. Can anyone suggest strategies or techniques to make this work?

3 Answers

Answered By GeometryGuru On

Have you looked into using swept circles or capsules? They can often simplify collision detection and manage interactivity better, especially if you're not strictly tied to using ovals. It might open up some flexibility in your coding without complicating your mathematics too much!

Answered By CodeCruncher On

This seems like more of a math problem than strictly a programming one. While circle collision detection is simple, doing the same for ellipses can be really complicated. For example, finding the perimeter of a circle is straightforward, but for an ellipse, it involves solving an elliptic integral which isn’t simple at all.

If you have two aligned ellipses of the same shape, you might transform them back into circles for easier intersection calculation, but this won't work generally. Here's a [link to a Math Stack Exchange post](https://math.stackexchange.com/questions/655619/intersection-of-ellipse-with-circle) that discusses reducing circle/ellipse intersections into polynomial terms, which could help you out!

Answered By MathematicsMaverick On

You might want to reconsider using ovals for collision detection. Circles are preferred because the calculations are quite straightforward—just a couple of right-angled triangles with their hypotenuses representing the distances. With rectangles, the math gets slightly more complex, but it's still manageable.

When it comes to ovals, accurately calculating their radius at various angles becomes tricky and computationally heavy since you need the exact angle and to employ more complex formulas. Just a thought before diving in too deep!

CuriousCoder42 -

I see what you mean! I was hoping it would be easier since I thought I could just add functionality with ovals, but it sounds like it might not be worth the computing effort. Thanks for the insight!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.