Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Collision Detection : oval+rectagle
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wOOhooo




PostPosted: 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? Smile thx in advance
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
wOOhooo




PostPosted: 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
richcash




PostPosted: 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.
Tony




PostPosted: Thu Feb 28, 2008 6:44 pm   Post subject: RE:Collision Detection : oval+rectagle

we have a search page.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
richcash




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: