corgano Posted April 17, 2009 Share Posted April 17, 2009 (edited) How do I find a point's angle from center of screen? Say I had a point at 200,300, How would i get the point in degrees from the center of the screen? Right is 0 degrees, Down is 90, Left is 180, Up is 270. Edited April 17, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Mat Posted April 17, 2009 Share Posted April 17, 2009 (edited) Count pixels from @DesktopHeight/2 to the height of the pixel found...do same for width...you know know 2 sides of a right angled triangle. Maths does the rest!Now let's look at the problem of finding angles if you know the sides. You use the trig functions, but in reverse. Here's an example. Suppose a = 12.3 and b = 50.1. Then tan A = a/b = 12.3/50.1 = 0.2455. On a calculator, we use the inverse trig functions named arctangent, arcsine, and arccosine. Usually there's a button on the calculator labelled "inv" or "arc" that you press before pressing the appropriate trig button. The arctangent of 0.2455 is 13.79, so the angle A is 13.79°.get angle, then chack if its negative, sorry forgot to add that, you must know which quarter of the screen it is in. Edited April 17, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
corgano Posted April 17, 2009 Author Share Posted April 17, 2009 Count pixels from @DesktopHeight/2 to the height of the pixel found...do same for width...you know know 2 sides of a right angled triangle. Maths does the rest!get angle, then chack if its negative, sorry forgot to add that, you must know which quarter of the screen it is in.I don't know the maths. How? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Mat Posted April 17, 2009 Share Posted April 17, 2009 (edited) I don't know the maths. How? Right... not perfect... PS: bedtime over here! Mine is probs wrong (getting x + y the wrong way round etc), so just post here and someone else could probably be able to help you, if not PM me and I'll answer when I get round to it. Maths is a good subject to know. edit2: what I said about finding negatives still aplies, and you may have to do more than that, an if test maybe on if $x > @Deskheight/2....I haven't checked edit3: you don't need aa + bb = cc...I put it in there becouse I felt like it. Edited April 17, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
UEZ Posted April 17, 2009 Share Posted April 17, 2009 (edited) Try this ;center coordinate $x1 = 200 $y1 = 300 ;second coordinate $x2 = 200 $y2 = 500 $a = $y2 - $y1 $c = $x2 - $x1 $alpha = Round(ATan($a / $c) * 180 / 3.1415926535897932384626, 2) ;convert to from rad to deg ConsoleWrite("Angle = " & $alpha & "°" & @CRLF)Check this out: http://en.wikipedia.org/wiki/TrigonometryUEZ Edited April 17, 2009 by UEZ 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...
Yashied Posted April 17, 2009 Share Posted April 17, 2009 (edited) How do I find a point's angle from center of screen? Say I had a point at 200,300, How would i get the point in degrees from the center of the screen? Right is 0 degrees, Down is 90, Left is 180, Up is 270.func Angle($X, $Y) local $CX = @DesktopWidth / 2, $CY = @DesktopHeight / 2 if ($CX = $X) and ($CY = $Y) then return SetError(1, 0, -1) endif local $Grad = ($Y <= $CY) * 180 - ATan(($CX - $X) / ($CY - $Y)) * 180 / 3.1415926535897932384626 + 90 if $Grad = 360 then $Grad = 0 endif return $Grad endfunc; Angle Edited April 17, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
UEZ Posted June 25, 2009 Share Posted June 25, 2009 (edited) func Angle($X, $Y) local $CX = @DesktopWidth / 2, $CY = @DesktopHeight / 2 if ($CX = $X) and ($CY = $Y) then return SetError(1, 0, -1) endif local $Grad = ($Y <= $CY) * 180 - ATan(($CX - $X) / ($CY - $Y)) * 180 / 3.1415926535897932384626 + 90 if $Grad = 360 then $Grad = 0 endif return $Grad endfunc; Angle One question regarding your notation: local $Grad = ($Y <= $CY) * 180 - ATan(($CX - $X) / ($CY - $Y)) * 180 / 3.1415926535897932384626 + 90 What does the notation in red means? I know <,>, >=, <= only for conditions using If...Then, etc. Thanks, UEZ Edited June 25, 2009 by UEZ 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...
sb1920alk Posted June 25, 2009 Share Posted June 25, 2009 func Angle($X, $Y) local $CX = @DesktopWidth / 2, $CY = @DesktopHeight / 2 if ($CX = $X) and ($CY = $Y) then return SetError(1, 0, -1) endif local $Grad = ($Y <= $CY) * 180 - ATan(($CX - $X) / ($CY - $Y)) * 180 / 3.1415926535897932384626 + 90 if $Grad = 360 then $Grad = 0 endif return $Grad endfunc; AngleoÝ÷ Ûú®¢×¡×zÉ-¢¢vØZÐÞ²Kh¤w¢r^wÝ«¢+ØÀÌØí½©]5%MÉÙ¥ô=©Ð ÅÕ½ÐíÝ¥¹µµÑÌèÀäÈìÀäÈì¸ÀäÈíɽ½ÐÀäÈí¥µØÈÅÕ½Ðì¤(ÀÌØí½±%ѵÌôÀÌØí½©]5%MÉÙ¥¹áEÕÉä ÅÕ½ÐíM±Ð¨É½´]¥¸ÌÉ}¥ÍÁ±å ½¹¥ÕÉÑ¥½¸ÅÕ½Ðì¤)½ÈÀÌØí½©%Ñ´¥¸ÀÌØí½±%ѵÌ($ÀÌØíÍÉ¹Ý¥Ñ ôÀÌØí½©%Ñ´¹A±Í]¥Ñ ($ÀÌØíÍɹ¡¥¡ÐôÀÌØí½©%Ñ´¹A±Í!¥¡Ð)9á ...too much vbscript lately. Link to comment Share on other sites More sharing options...
UEZ Posted June 25, 2009 Share Posted June 25, 2009 @sb1920alk: what do you want to say now? UEZ 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...
sb1920alk Posted June 25, 2009 Share Posted June 25, 2009 @sb1920alk: what do you want to say now? UEZonly that I didn't think of @DesktopHeight/Width when I needed them because I'm stuck using vbscript most if the time right now. The WMI query works in vbscript, so I used that instead. @DesktopHeight is much simpler.Regarding ($Y <= $CY)...my guess is True/False becomes 1 (True) or 0 (False) times 180 to make the math work. Link to comment Share on other sites More sharing options...
UEZ Posted June 25, 2009 Share Posted June 25, 2009 (edited) only that I didn't think of @DesktopHeight/Width when I needed them because I'm stuck using vbscript most if the time right now. The WMI query works in vbscript, so I used that instead. @DesktopHeight is much simpler. Regarding ($Y <= $CY)...my guess is True/False becomes 1 (True) or 0 (False) times 180 to make the math work. I was confused why you are writing something about WMI. Anyway, yes you are right! As long as $CY is equal or greater than it is true (1) otherwise false (0)! A simple code showed what it means. $Grad = 0 $CY = 10 $y = 0 While Sleep(30) and $y < 20 $Grad = ($Y <= $CY) ConsoleWrite($y & ": " & $Grad & @CRLF) $y += 1 WEnd It is really too late to ask such questions... UEZ Edited June 25, 2009 by UEZ 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...
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