corgano Posted April 17, 2009 Share Posted April 17, 2009 (edited) I need a simple way to mesure the distance between 2 points. Couldnt find in help file or in search. Say I wanted to find the distance (in pixles) between 200,300, and 400, 100. How would I do it? Edited April 17, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
GregThompson Posted April 17, 2009 Share Posted April 17, 2009 Subtraction! Link to comment Share on other sites More sharing options...
martin Posted April 17, 2009 Share Posted April 17, 2009 Subtraction!Nonsense!The distance between points x,y and a,b is((a-x)2 + (b-y)2)0.5it's just the hypotenuse of the triangle (or the diagonal of the square) made by the line between the points and the vertical and horizontal lines through the points. lordofthestrings 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
darkmaster071 Posted April 17, 2009 Share Posted April 17, 2009 (edited) http://freespace.virgin.net/hugo.elias/routines/r_dist.htm Edited April 17, 2009 by darkmaster071 Link to comment Share on other sites More sharing options...
trancexx Posted April 17, 2009 Share Posted April 17, 2009 Yes, but for example, how do I calcuate the distance between, let's say, three points?Come on, this is a joke... you got that, right? :Р ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted April 17, 2009 Share Posted April 17, 2009 (edited) You can use Pythagoras to calculate distance between 2 points (2D): Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem for 2D Local $a, $b, $c If $x2 = $x1 And $y2 = $y1 Then Return 0 Else $a = $y2 - $y1 $b = $x2 - $x1 $c = Sqrt($a * $a + $b * $B) Return $c EndIf EndFunc ;==>Pixel_Distance If you want to calculate the distance for more than 2 point just calculate it between each points and sum the results. The slope of two points: m = (y2 - y1) / (x2 - x1) Just have a look to my GDI+ examples "Simple Ball Collision Simulation" where I used it! UEZ Edited April 17, 2009 by UEZ lordofthestrings 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
corgano Posted April 17, 2009 Author Share Posted April 17, 2009 You can use Pythagoras to calculate distance between 2 points (2D): Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem for 2D Local $a, $b, $c If $x2 = $x1 And $y2 = $y1 Then Return 0 Else $a = $y2 - $y1 $b = $x2 - $x1 $c = Sqrt($a * $a + $b * $B) Return $c EndIf EndFunc ;==>Pixel_Distance If you want to calculate the distance for more than 2 point just calculate it between each points and sum the results. Just have a look to my GDI+ examples "Simple Ball Collision Simulation" where I used it! UEZ Thankyou all, i have found what i have been looking for. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now