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.
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.
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?
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 ;)
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?