tyzer Posted March 20, 2017 Share Posted March 20, 2017 Can someone post me a function whicb returns an angle after I gave the function two X/Y coordinates. The angle it should return should be in a specific format, guess this picture will explain it better Till now I used this function which works in most cases but sometimes it returns in angle which leads to the opposite direction expandcollapse popupFunc _CalcAngle($PosX, $PosY, $targetPosX, $targetPosY) If $PosX < $targetPosX And $PosY < $targetPosY Then $gegenkathete = $PosX - $targetPosX $ankathete = $PosY - $targetPosY $Quotient = $ankathete / $gegenkathete $x = ATan(0.5) $pi = 4 * ATan(1) $radToDeg = 180 / $pi $y = ATan($Quotient) * $radToDeg $y = $y + 90 $y = $y - 180 $y = $y * -1 $y = $y - 180 $y = $y * -1 Return $y ElseIf $PosX < $targetPosX And $PosY > $targetPosY Then $gegenkathete = $PosX - $targetPosX $ankathete = $PosY - $targetPosY $Quotient = $ankathete / $gegenkathete $x = ATan(0.5) $pi = 4 * ATan(1) $radToDeg = 180 / $pi $y = ATan($Quotient) * $radToDeg $y = $y + 90 $y = $y - 180 $y = $y * -1 $y = $y - 180 $y = $y * -1 Return $y ElseIf $PosX > $targetPosX And $PosY > $targetPosY Then $gegenkathete = $PosX - $targetPosX $ankathete = $PosY - $targetPosY $Quotient = $ankathete / $gegenkathete $x = ATan(0.5) $pi = 4 * ATan(1) $radToDeg = 180 / $pi $y = ATan($Quotient) * $radToDeg $y = $y + 90 $y = $y - 180 Return $y ElseIf $PosX > $targetPosX And $PosY < $targetPosY Then $gegenkathete = $PosX - $targetPosX $ankathete = $PosY - $targetPosY $Quotient = $ankathete / $gegenkathete $x = ATan(0.5) $pi = 4 * ATan(1) $radToDeg = 180 / $pi $y = ATan($Quotient) * $radToDeg $y = $y + 90 $y = $y - 180 Return $y EndIf EndFunc Link to comment Share on other sites More sharing options...
tyzer Posted March 20, 2017 Author Share Posted March 20, 2017 Link to comment Share on other sites More sharing options...
jchd Posted March 20, 2017 Share Posted March 20, 2017 (edited) "Angle between two points" is an unspecified problem. Rephrase your question with "angle between two lines (or vectors)" and you'll get correct answers. (Also upper 91 and 90 are badly placed in your drawing) Edited March 20, 2017 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Luigi Posted March 20, 2017 Share Posted March 20, 2017 see this, Visit my repository Link to comment Share on other sites More sharing options...
UEZ Posted March 20, 2017 Share Posted March 20, 2017 This might give you an idea: 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...
czardas Posted March 21, 2017 Share Posted March 21, 2017 (edited) On 20/03/2017 at 7:48 AM, jchd said: "Angle between two points" is an unspecified problem. 180 degrees (*int) Edited March 21, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jchd Posted March 21, 2017 Share Posted March 21, 2017 (edited) What I mean is that, given only points A and B there are two very different angles one may consider. The first is α the angle formed by vectors from the origin O to point A and to point B. The angle α doesn't depend on the length of vectors OA and OB as soon as A and B are distinct from O. The second angle may be the angle γ between a reference direction (say North for instance) and the line AB. Note that then B is moved to B' this angle becomes β while at the same time, α remains constant. Edited March 21, 2017 by jchd czardas 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
czardas Posted March 22, 2017 Share Posted March 22, 2017 @jchd = best operator64 ArrayWorkshop 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