Calculate distance

BlitzMax Forums/BlitzMax Beginners Area/Calculate distance

Moraldi(Posted 2007) [#1]
Hello,
I need to detect my mouse pointer(mx,my) is nearby a line let's say from (x1,y1) to (x2,y2)
I suppose it can be done like this:
a) Given mx (x1<mx<x2) as mouse coordinate calculate line's y
b) if abs(y-my) < distance then mouse is nearby line
Is there any better way?

Thanks!


Perturbatio(Posted 2007) [#2]


Thanks to Fredborg for the IsOnLine function (direct conversion from B3D)


Grey Alien(Posted 2007) [#3]
yowzer!


Moraldi(Posted 2007) [#4]
Thanks for the code. Thats what I was looking for! I will use this code in BMax with bbLine (SDK)
Grey: Can you please what "yowzer" means. Its a great moment to learn English idioms :)


TaskMaster(Posted 2007) [#5]
Yowzer is similar to wow! Nothing special. :)


Moraldi(Posted 2007) [#6]
yowzer!
Thanks TaskMaster


Grey Alien(Posted 2007) [#7]
Yeah a bit like Cor Blimey! Althought that's a bit old now.


Perturbatio(Posted 2007) [#8]
Yeah a bit like Cor Blimey! Althought that's a bit old now.


And limited to people like Chaz & Dave and Dick Van Dyk :)


Gnasher(Posted 2007) [#9]
i read some where that the parabolic distance is way faster to calculate then the traditional manhatan distance.. gone see if i find that article again

//Gnasher