E1M1 Posted October 10, 2011 Posted October 10, 2011 I am supprised that in 1st test value of $__ is 90 with out any or. it's exactly 90 but $__ = 90 returns false. Does anyone know how what causes this problem in my test? for somereason it thinks that $__ is greater than 90 but when you look at console output you can clearly see that it isn't. You can run code below. expandcollapse popupMsgBox(0, 0, Test("1 0 2 0 1 2")) ;MsgBox(0, 0, Test("3 0 4 2 5 0")) ;MsgBox(0, 0, Test("6 0 7 0 8 2")) ;~ $TriangleCoords = "x1 xy x2 y2 x3 y3" ;~ Angles: If 1 of the angles are: ; < 90 acute angle ; > 90 obtuse angle ; = 90 square corner Func Test($TriangleCoords) ConsoleWrite(@CRLF) $Triangle = $TriangleCoords $Triangle = StringSplit($Triangle, " ") Dim $A[2], $B[2], $C[2], $AB[2], $BC[2], $CA[2] $A[0] = Number($Triangle[1]) $A[1] = Number($Triangle[2]) $B[0] = Number($Triangle[3]) $B[1] = Number($Triangle[4]) $C[0] = Number($Triangle[5]) $C[1] = Number($Triangle[6]) $AB[0] = $B[0] - $A[0] $AB[1] = $B[1] - $A[1] $BC[0] = $C[0] - $B[0] $BC[1] = $C[1] - $B[1] $CA[0] = $A[0] - $C[0] $CA[1] = $A[1] - $C[1] $A = Sqrt($AB[0] ^ 2 + $AB[1] ^ 2) $B = Sqrt($BC[0] ^ 2 + $BC[1] ^ 2) $C = Sqrt($CA[0] ^ 2 + $CA[1] ^ 2) $pi = 3.14159265358979323846264338327950288419716939937510 $radToDeg = 180 / $pi $_ = ACos(($B ^ 2 + $C ^ 2 - $A ^ 2) / (2 * $B * $C)) * $radToDeg $__ = ACos(($A ^ 2 + $C ^ 2 - $B ^ 2) / (2 * $A * $C)) * $radToDeg $___ = ACos(($A ^ 2 + $B ^ 2 - $C ^ 2) / (2 * $A * $B)) * $radToDeg ConsoleWrite($_ & @CRLF) ConsoleWrite($__ & @CRLF) ConsoleWrite($___ & @CRLF) MsgBox(0,$__,$__ = 90) ;If $_ = 90 or $__ = 90 Or $___ = 90 Then Return "Täisnurk" ;If $_ > 90 or $__ > 90 Or $___ > 90 Then Return "nürinurk" EndFunc ;==>Test edited
E1M1 Posted October 10, 2011 Author Posted October 10, 2011 I figured that when I change $__ = 90 to String($__) = String(90) then it returns true edited
bogQ Posted October 10, 2011 Posted October 10, 2011 (edited) you can use string comparation$__ == 90 orInt($__) = 90 Edited October 10, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
E1M1 Posted October 10, 2011 Author Posted October 10, 2011 just wondering why it doesnt work with numbric versions of variables? Is it because 1 is float and other is int? edited
Yashied Posted October 10, 2011 Posted October 10, 2011 Because ACos(...) * 180 / 3.14... <> 90 and Pi <> 3.14159265358979323846264338327950288419716939937510. Am I right? For a correct comparison of the values you need to round a float value with an accuracy of its type. For the FLOAT type it should be about seven digits, DOUBLE - about 15 digits. MsgBox(0, $__, Round($__, 7) = 90) 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...
happytc Posted October 10, 2011 Posted October 10, 2011 (edited) Try this: $Num = 1 For $i = 0 To 100 $Num += 0.1 ConsoleWrite($Num & @CRLF) Next Edited October 10, 2011 by happytc
UEZ Posted October 10, 2011 Posted October 10, 2011 (edited) Instead of using the long floating number for pi just use Const $pi = ACos(-1) instead. Br, UEZ Edited October 10, 2011 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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