circle - triangle collision

Advanced game related topics
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

circle - triangle collision

Post by Heathen »

Does anyone know of an elegant method for checking for a collision between a triangle and a circle?

Thanks in advance.
I love Purebasic.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

in the Coding Questions forum was a thread about line-point collision,
there were some solutions working with distance to the line.
http://www.purebasic.fr/english/viewtopic.php?t=32780

... performing this check for the center of the circle and all three line of your triangle
and comparing the distance with the radius may be an approach for you...

just an idea.. perhaps there are better ways...
oh... and have a nice day.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

@Heathen, perhaps this is useful to you:
http://www.purebasic.fr/english/viewtop ... 023#250023
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post by Heathen »

Hey guys, thanks for the responses. I figured out a good method myself already. I was going to use triangle collision as a sort of 2d FOV. The idea is, as the objects rotate, the triangle also rotates and anyone within the triangle is considered 'seen'. instead I'm just comparing the angle difference and doing a distance check. Seems to work pretty well.
I love Purebasic.
Post Reply