Funzione Arcotangente2

« Older   Newer »
  Share  
CAT_IMG Posted on 17/12/2012, 17:34     +1   -1

So implementare gli object

Group:
Admin
Posts:
1,215
Reputazione:
+150

Status:


Salve ragazzi :D
Mentre spiegavo a logix un po' di cose sui vettori e su come rappresentarli in memoria, mi sono accorto che in AutoIt manca la funzione trigonometrica atan2(y,x) :asd:
Ho cercato un'implementazione online, ho trovato questa che funziona (anche se non condivido la nomenclatura delle variabili -_- )
Spero sia utile a qualcuno:
CODICE
Func _ATAN2(Const $NY, Const $NX)
   Const $NPI = 3.14159265358979
   Local $NRESULT
   If IsNumber($NY) = 0 Then
       SetError(1)
       Return 0
   ElseIf IsNumber($NX) = 0 Then
       SetError(1)
       Return 0
   EndIf
   If $NX = 0 Then
       If $NY > 0 Then
           $NRESULT = $NPI / 2
       ElseIf $NY < 0 Then
           $NRESULT = 3 * $NPI / 2
       Else
           SetError(2)
           Return 0
       EndIf
   ElseIf $NX < 0 Then
       $NRESULT = ATan($NY / $NX) + $NPI
   Else
       $NRESULT = ATan($NY / $NX)
   EndIf
   While $NRESULT < 0
       $NRESULT += 2 * $NPI
   WEnd
   Return $NRESULT
EndFunc


<pastebin>

Fonte
 
Top
doublechar
CAT_IMG Posted on 20/1/2013, 03:11     +1   -1




i lav iu <3
 
Top
1 replies since 17/12/2012, 17:34   304 views
  Share