00:00
00:00
Newgrounds Background Image Theme

ravchka just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Circle To Line Hit Testing

8,424 Views | 33 Replies
New Topic Respond to this Topic

Response to As: Circle To Line Hit Testing 2006-01-19 13:08:49


a lot of other people did get the thread. some others suggested alternatives.

this thread was written to provide you with the most logical form of code, not the most optimized.

Response to As: Circle To Line Hit Testing 2006-01-19 14:36:19


At 1/19/06 01:08 PM, Inglor wrote: a lot of other people did get the thread. some others suggested alternatives.

this thread was written to provide you with the most logical form of code, not the most optimized.

no I mean it doesnt work. You used pythagoras with variables a and b which where gradient and -1. I copied and pasted the code and it still didnt work. Have I messed up or have you?


- Matt, Rustyarcade.com

Response to As: Circle To Line Hit Testing 2006-09-08 19:23:12


I too understand the maths behind this example, but admit to being lazy enough to copy and paste your code (although I did have to change a lot of it to fit in with what I was doing). When tesing the code, I was confused to find that it wasn't working as I expected too.

For people who copied and pasted the code for finding the distance from the example given, I found that it worked if the Math.abs() brackets were expanded to encompass the whole statement, not just the part before the division sign.

Not sure if this is a fault, or something that I don't understand, but changing it to

distance:Number= Math.abs(a*x + b*y + c / Math.sqrt(a*a + b*b));

worked for me, so I hope it helps ;)

Response to As: Circle To Line Hit Testing 2009-03-22 14:13:44


Is it just me, or does this not work on lines with negative slope? Also, is there a way to only test against line segments, not a full line?


BBS Signature