qwertylol Posted May 9, 2007 Posted May 9, 2007 (edited) We can get the three red points by default, and we draw two lines, from point 1 to point 2, and from point 2 and point 3. from the center of those two lines draw two lines perpenticular to the the two lines. and then at the intersection of these two new lines, this is the center of the circle. ok, so we get coordinates of 3 (x,y) points, how do we program au3 to find the center of the circle? Edited May 9, 2007 by qwertylol
evilertoaster Posted May 9, 2007 Posted May 9, 2007 http://mathforum.org/library/drmath/view/55233.htmlhttp://mathforum.org/library/drmath/sets/s...ter_circle.html for more options
qwertylol Posted May 9, 2007 Author Posted May 9, 2007 it's the au3 technique I am not sure of. for instance, how do you get the perpendicular lines which will intersect at the center? that's the last step, and the only one I am not sure of.
evilertoaster Posted May 9, 2007 Posted May 9, 2007 (edited) Converted the code posted at http://mathforum.org/library/drmath/view/54323.htmlfunc Center($bx,$by,$cx,$cy,$dx,$dy) $temp=$cx*$cx+$cy*$cy $bc=($bx*$bx+$by*$by-$temp)/2.0 $cd=($temp-$dx*$dx-$dy-$dy)/2.0 $det=($bx-$cx)*($cy-$dy)-($cx-$dx)*($by-$cy) $det=1/$det $CenterX=($bc*($cy-$dy)-$cd*($by-$cy))*$det $CenterY=(($bx-$cx)*$cd-($cx-$dx)*$bc)*$det dim $Center[2] $Center[0]=$CenterX $Center[1]=$CenterY Return $Center EndFunctakes 3 points (x and y of each) returns a 2 element array with the x in element 0 and y in elemment 1.Haven't nested it except for syntax but it should work... Edited May 9, 2007 by evilertoaster
qwertylol Posted May 10, 2007 Author Posted May 10, 2007 Converted the code posted at http://mathforum.org/library/drmath/view/54323.html func Center($bx,$by,$cx,$cy,$dx,$dy) $temp=$cx*$cx+$cy*$cy $bc=($bx*$bx+$by*$by-$temp)/2.0 $cd=($temp-$dx*$dx-$dy-$dy)/2.0 $det=($bx-$cx)*($cy-$dy)-($cx-$dx)*($by-$cy) $det=1/$det $CenterX=($bc*($cy-$dy)-$cd*($by-$cy))*$det $CenterY=(($bx-$cx)*$cd-($cx-$dx)*$bc)*$det dim $Center[2] $Center[0]=$CenterX $Center[1]=$CenterY Return $Center EndFunc takes 3 points (x and y of each) returns a 2 element array with the x in element 0 and y in elemment 1. Haven't nested it except for syntax but it should work... I really appreciate that you wrote this for me, but I am still confused LOL can you explain for me, how this works?
ame1011 Posted May 10, 2007 Posted May 10, 2007 (edited) your script would look something like this: $center = Center(1,2,2,4,2,5) MsgBox(0,$center[0] + " " + $center[1] ) func Center($bx,$by,$cx,$cy,$dx,$dy) $temp=$cx*$cx+$cy*$cy $bc=($bx*$bx+$by*$by-$temp)/2.0 $cd=($temp-$dx*$dx-$dy-$dy)/2.0 $det=($bx-$cx)*($cy-$dy)-($cx-$dx)*($by-$cy) $det=1/$det $CenterX=($bc*($cy-$dy)-$cd*($by-$cy))*$det $CenterY=(($bx-$cx)*$cd-($cx-$dx)*$bc)*$det dim $Center[2] $Center[0]=$CenterX $Center[1]=$CenterY Return $Center EndFunc i would reccomend that you quickly read up on methods in the helpfile so that you understand better. the method above accepts 3 points on the circle, in the form (x1,y1,x2,y2,x3,y3) and returns an array of the x/y coordinates of the center. Edited May 10, 2007 by ame1011 [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
qwertylol Posted May 10, 2007 Author Posted May 10, 2007 I know how to use it, but I want to be through. What are the mathmetical medthod?
qwertylol Posted May 10, 2007 Author Posted May 10, 2007 Can you tell me how it work, mathematically? because there is no way I'd understand the code without knowing that.
qwertylol Posted May 10, 2007 Author Posted May 10, 2007 Can you tell me how it work, mathematically? because there is no way I'd understand the code without knowing that.
evilertoaster Posted May 10, 2007 Posted May 10, 2007 (edited) read what is already posted.... i just said all I did was convert what was already posted at http://mathforum.org/library/drmath/view/54323.htmlThe process is already explained on that page and several others listed on http://mathforum.org/library/drmath/sets/s...ter_circle.html decribe how to find a center point of a circle with 3 points... I'm no more mathmatically inclined than the next guy, I went form knowing nothing about it to knowing how to do it from what's psoted there. Edited May 10, 2007 by evilertoaster
acidfear Posted May 10, 2007 Posted May 10, 2007 If you want to get the mid without knowing the coordinates, make the circle a specific color. Then do a pixel search for it. Once it has that one coordinate, have the mouse coords - or + to the next step up until you have an average circle. Then take the 4 point coordinates, add them by pairs, and divide by 2. I think you should get the x,y of the mid dot. Just a creative idea. Dunno if it'd work.
enaiman Posted May 10, 2007 Posted May 10, 2007 Can you tell me how it work, mathematically?because there is no way I'd understand the code without knowing that.Take a pen and a piece of paper, remember some basic geometry stuff (like how to find a triangle side by knowing the other 2) and you will find the explanation by yourself. To ask so many times for mathematical explanations in an AutoIt forum seem to be a little ... hmmm ... inappropriate. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
qwertylol Posted May 12, 2007 Author Posted May 12, 2007 Take a pen and a piece of paper, remember some basic geometry stuff (like how to find a triangle side by knowing the other 2) and you will find the explanation by yourself. To ask so many times for mathematical explanations in an AutoIt forum seem to be a little ... hmmm ... inappropriate.well, i wanted to know how the code works.math is fundamental for programmers too.
martin Posted May 12, 2007 Posted May 12, 2007 well, i wanted to know how the code works.math is fundamental for programmers too.I haven't read the previous posts carefully but the basic approach doesn't seem to be explained anywhere. You don't need to go looking up mathematical rules because all the information is there.Take the first line. It's centre which is Xc,Yc = 0.5*(X1 + X2), 0.5*(Y1 + Y2)Find the slope . Angle = atan ((y2-y1)/(X2 - X1))So, the slope of the line at right angles is atan((X2-X1)/(Y2-Y1))The equation for the line at right angles is Y = M*x + K we know M = (X2-X1)/(Y2-Y1) and we can work out K becauseK = Yc - M*XcSo then you can get the two equations for the 2 lines.The next step is just to solve simulatious equations. The solution is where they cross which is the centre of the circle. 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.
qwertylol Posted May 12, 2007 Author Posted May 12, 2007 expandcollapse popupFunc radar_center( $ax, $ay, $bx, $by, $cx, $cy ) ;slopes $m1 = ( ( $by - $ay ) / ( $bx - $ax ) ) $m2 = ( ( $cy - $by ) / ( $cx - $bx ) ) $m1 = -$m1 $m2 = -$m2 ;midpoints $ab_mid_x = ( $bx + $ax ) / 2 $ab_mid_y = ( $by + $ay ) / 2 $bc_mid_x = ( $cx + $bx ) / 2 $bc_mid_y = ( $cy + $by ) / 2 ;c = y - mx ; y = mx + c $c1 = $ab_mid_y - $m1 * $ab_mid_x $c2 = $bc_mid_y - $m2 * $bc_mid_x ;center of the circle ;shift signs for perpendicular functions. $center_x = ( $c1 - $c2 ) / ( $m2 - $m1 ) $center_y = $m1 * $center_x + $c2 MsgBox ( 0 , "title", $center_x ) MsgBox ( 0 , "title", $center_y ) ;Return $center_x & $center_y EndFunc for some reason this wouldn't work.
qwertylol Posted May 12, 2007 Author Posted May 12, 2007 I haven't read the previous posts carefully but the basic approach doesn't seem to be explained anywhere. You don't need to go looking up mathematical rules because all the information is there.Take the first line. It's centre which is Xc,Yc = 0.5*(X1 + X2), 0.5*(Y1 + Y2)Find the slope . Angle = atan ((y2-y1)/(X2 - X1))So, the slope of the line at right angles is atan((X2-X1)/(Y2-Y1))The equation for the line at right angles is Y = M*x + K we know M = (X2-X1)/(Y2-Y1) and we can work out K becauseK = Yc - M*XcSo then you can get the two equations for the 2 lines.The next step is just to solve simulatious equations. The solution is where they cross which is the centre of the circle.I am not sure about the Angle = atan ((y2-y1)/(X2 - X1))is atan arcTan ? ,also, can you illustrate with paint how the equation looks like ?
martin Posted May 12, 2007 Posted May 12, 2007 I am not sure about the Angle = atan ((y2-y1)/(X2 - X1))is atan arcTan ? ,also, can you illustrate with paint how the equation looks like ?atan and arctan are the same thing to me. Some programming languages use one some the other.Doesn't look to me like you need a diagram.In your previous post $center_y = $m1 * $center_x + $c2 should be $center_y = $m2 * $center_x + $c2 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.
qwertylol Posted May 13, 2007 Author Posted May 13, 2007 expandcollapse popupDim $ax = 48 Dim $ay = 396 Dim $bx = 275 Dim $by = 497 Dim $cx = 486 Dim $cy = 326 radar_center( $ax, $ay, $bx, $by, $cx, $cy ) Func radar_center( $ax, $ay, $bx, $by, $cx, $cy ) ;slopes $m1 = ( ( $by - $ay ) / ( $bx - $ax ) ) $m2 = ( ( $cy - $by ) / ( $cx - $bx ) ) $m1 = -$m1 $m2 = -$m2 ;midpoints $ab_mid_x = ( $bx + $ax ) / 2 $ab_mid_y = ( $by + $ay ) / 2 $bc_mid_x = ( $cx + $bx ) / 2 $bc_mid_y = ( $cy + $by ) / 2 ;c = y - mx ; y = mx + c $c1 = $ab_mid_y - $m1 * $ab_mid_x $c2 = $bc_mid_y - $m2 * $bc_mid_x ;center of the circle ;shift signs for perpendicular functions. $center_x = ( $c1 - $c2 ) / ( $m2 - $m1 ) $center_y = $m2 * $center_x + $c2 MsgBox ( 0 , "title", $center_x ) MsgBox ( 0 , "title", $center_y ) ;Return $center_x & $center_y EndFunc for some reason this still doesn't work, I can't figure out why.
qwertylol Posted May 13, 2007 Author Posted May 13, 2007 $center = Center(48,396,275,497,486,326) Msgbox ( 0, "x", $center[0] ) MsgBox ( 0, "y", $center[1] ) func Center($bx,$by,$cx,$cy,$dx,$dy) $temp=$cx*$cx+$cy*$cy $bc=($bx*$bx+$by*$by-$temp)/2.0 $cd=($temp-$dx*$dx-$dy-$dy)/2.0 $det=($bx-$cx)*($cy-$dy)-($cx-$dx)*($by-$cy) $det=1/$det $CenterX=($bc*($cy-$dy)-$cd*($by-$cy))*$det $CenterY=(($bx-$cx)*$cd-($cx-$dx)*$bc)*$det dim $Center[2] $Center[0]=$CenterX $Center[1]=$CenterY Return $Center EndFunc This doesn't work either
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