Burgs Posted April 16, 2022 Posted April 16, 2022 Greetings, I have a need to use a Tan function to a power of "-1". On a calculator this is normally the "INV" key or possibly the "2nd" key. The "Tan ^ -1" should return a value in degrees. This seems to not be exactly possible using AutoIT. Here is a sample script: #include <MsgBoxConstants.au3> #include <Math.au3> Local $_value = .25 ConsoleWrite("tan convert to degrees value is: " & _Degree(Tan($_value)) & @CRLF) ;returns 14.63 *....SEEMS CLOSE...* should be 14.036 And I also attempted: ConsoleWrite("inverse tan of value is: " & Tan($_value) ^ -1 & @CRLF) ;returns 3.916 however should be 14.036 ConsoleWrite("inverse tan of value is: " & _Degree(Tan($_value) ^ -1) & @CRLF) ;returns 224.388 however should be 14.036 ConsoleWrite("inverse tan of value is: " & (Tan ^ -1) * ($_value) & @CRLF) ;returns 1.#INF As can be seen in the code...the closest answer (from what I get on a calculator) is "14.63"...when the calculator indicates it should be "14.036"...is there some reason for the discrepancy? Is simulation of a "INV" or "2nd" key on the calculator possible using AutoIT? I thank you in advance for any suggestion.
ahmet Posted April 16, 2022 Posted April 16, 2022 Try with ATan(). I think this function is mentioned in the helpfile for Tan function, under Related functions.
jchd Posted April 16, 2022 Posted April 16, 2022 3 hours ago, Burgs said: _Degree(Tan($_value)) This doesn't make sense! Tan($x) is a scalar value, not an angle. As @ahmet just said, you need ATan($x) 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)
Burgs Posted April 16, 2022 Author Posted April 16, 2022 Thanks to both of you that replied. I have attempted the ATan function, however I am seeing a value returned of "0.244978663126864", which is not what my Windows 11 calculator is returning (using '2nd' and 'Tan ^ -1'). Sorry about the "Degree(Tan($_value))" I mis-read the documentation and thought the value was returned in radians and I wanted to convert to degrees...however I see the INPUT is in radians. I am trying to reproduce the values in this information, "https://www.usgs.gov/educational-resources/determine-percent-slope-and-angle-slope". Specifically the information located in the second part of the page beginning at "Angle of Slope" in a bold font.
Moderators Melba23 Posted April 16, 2022 Moderators Posted April 16, 2022 Burgs, These are my results for Tan-1(.25) in radians: AutoIt ATan function: 0.244978663126864 My Sharp scientific calculator: 0.24497866 My Windows 10 calculator: 0.24497866312686415417208248121128 The 26.5 degrees mentioned for ATan(.5) on the page to which you linked is obviously floored from the actual value of 26.565051. All 3 methods mentioned above match to 6 decimal places. Do you still have a problem? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Burgs Posted April 16, 2022 Author Posted April 16, 2022 Thanks for your input Melba, I think I have it now...just need to convert those results to degrees, which the calculator did automatically. I am old also...hahaha . Regards to you and the others that replied.
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