Jonas93 Posted September 13, 2011 Share Posted September 13, 2011 Hi, Take a look at this script Func _getTurnLine($a,$x,$y,$m) local $turnLine[2] $deg = 4*Atan(1) / 180 $angle = $a * $deg $turnLine[0] = tan($angle + ATan($m)) $turnLine[1] = $y - ($turnLine[0] * $x) return $turnLine EndFunc Using it to turn a line at $a degrees. Try out this: _getTurnLine(45,2,2,0) $array[0] should be 1 (successfull) and $array[1] should be 0 but $array[1] gives out a freaking number with "e-106". plz help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 13, 2011 Moderators Share Posted September 13, 2011 Jonas93, Welcome to the AutoIt forum. Could you please explain what the function does, what the 4 parameters represent, and what should be in the 2 elements of the returned array. It would make helping you much easier as we might then have a clue as to what you were doing! 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 Link to comment Share on other sites More sharing options...
taietel Posted September 13, 2011 Share Posted September 13, 2011 (edited) Func _getTurnLine($a, $x, $y, $m) Local $turnLine[2] Local $pi = 3.14159265358979 $deg = $pi / 180 $angle = $a * $deg $turnLine[0] = Round(Tan($angle + ATan($m) / $deg)) $turnLine[1] = Round($y - $turnLine[0] * $x) Return $turnLine EndFunc ;==>_getTurnLine If you want to just rotate a line, here's an example: expandcollapse popup#include <GUIConstantsEx.au3> _Test() Func _Test() Local $hGUI = GUICreate("Test", 450, 450) GUISetBkColor(0xffffff) Local $Graphic2 = GUICtrlCreateGraphic(225, 225, 200, 200) GUICtrlSetGraphic($Graphic2, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($Graphic2, $GUI_GR_COLOR, 0x996600) For $i = 0 To 170 Step 10 Local $aV = _RotateLine($i, 0, 0, 200, 0, False) ;set the initial point GUICtrlSetGraphic($Graphic2, $GUI_GR_MOVE, $aV[0], $aV[1]) ;draw the line to the final point GUICtrlSetGraphic($Graphic2, $GUI_GR_LINE, $aV[2], $aV[3]) __Debug("x=" & $aV[2] & ", y=" & $aV[3]) Next GUISetState() While 1 Sleep(10) Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd EndFunc ;==>_Test Func _RotateLine($iAngle, $iX0, $iY0, $iX, $iY, $bClockwise = True) Local $aRet[4] Local $PI = 3.14159265358979 Local $DEG2RAD = $PI / 180 $iAngle = $iAngle * $DEG2RAD $iIp = Round(Sqrt(($iX - $iX0) ^ 2 + ($iY - $iY0) ^ 2)) $aRet[0] = $iX0 $aRet[1] = $iY0 $aRet[2] = Round($iIp * Cos($iAngle)) If $bClockwise Then $aRet[3] = Round($iIp * Sin($iAngle)) Else $aRet[3] = -Round($iIp * Sin($iAngle)) EndIf Return $aRet EndFunc ;==>_RotateLine Func __Debug($s) ConsoleWrite($s & @CRLF) EndFunc ;==>__Debug Edited September 13, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text 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