Author |
Message |
wOOhooo
|
Posted: Thu Feb 28, 2008 5:10 pm Post subject: Collision Detection : oval+rectagle |
|
|
well i have a problem. Ive looked all over the fourms and have not found an rectangle, oval collision. Could some one just post the code for a rectangle, oval collision? thx in advance |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu Feb 28, 2008 5:28 pm Post subject: RE:Collision Detection : oval+rectagle |
|
|
try harder, we most definitely have both available in the tutorials section. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
wOOhooo
|
Posted: Thu Feb 28, 2008 5:57 pm Post subject: RE:Collision Detection : oval+rectagle |
|
|
-_- ive been searching for like and hour, and trying to figure it out.. i just cant find it |
|
|
|
|
![](images/spacer.gif) |
richcash
|
Posted: Thu Feb 28, 2008 6:00 pm Post subject: Re: Collision Detection : oval+rectagle |
|
|
Do you mean intersection between an oval and a rectangle? Well, for horizontal/vertical ovals (the ones you can draw in Turing using Draw.Oval) and rectangles it's not too hard.
First, you have to check if one of the four corners of the rectangle are inside the oval. Then, you have to check if the highest or lowest point on the oval is inside the rectangle or if the furthest left or furthest right point on the oval is inside the rectangle. I call these the central points of the oval because they are the points on the oval which share the same x OR y coordinate as the center.
If you don't know how to check if a point is inside of a rectangle/oval(ellipse) then you should search for collision detection tutorials on this site. This tutorial contains a point vs ellipse section.
Post back if you can't figure out which points on the oval I am talking about or if you can't figure out how to find the 4 corners of your rectangle. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
richcash
|
Posted: Thu Feb 28, 2008 7:07 pm Post subject: Re: Collision Detection : oval+rectagle |
|
|
Well, if he is talking about oval vs. rectangle intersection, then there is no tutorial on these forums to my knowledge that specifically covers that. But I still don't know for sure if that's what he's talking about. If it is, I think the easiest way to do it would be the way I described above.
But I did miss one condition in my above post. You would also have to check if the center of the oval/ellipse is inside of the rectangle. |
|
|
|
|
![](images/spacer.gif) |
|