English
Forum

maths: Angle calculation

 
- Page 1 -


Hey could me Please of/ one the explicit More mathematically formed XProfan on The Sprünge help ? I see whom woods to Bäumen not any more

everything I wants is a speedy function from the way xy,xxyy me whom winkel (360°!) returns.

my code functions already - naja almost.
CompileMarkSeparation
CLS

WHILE 1

    CLS
    PRINT WNK(100,100,%MOUSEX,%MOUSEY)
    SLEEP 100

ENDWHILE

WAITKEY

proc WNK

    PARAMETERS X&,Y&,XX&,YY&
    var T!=0

    IF XX&<X&

        RETURN WNK(XX&,Y&,X&,YY&)

    ENDIF

    IF YY&<Y&

        RETURN WNK(X&,YY&,XX&,Y&)

    ENDIF

    LINE X&,Y& - XX&,YY&
    var DX!=XX&-X&
    var DY!=YY&-Y&
    T!=(SQRT(DX!*DX!+DY!*DY!))

    IF YY&<XX&

        T!=RAD2DEG(SINH(DY!/T!))

    ELSE

        T!=45+(45-RAD2DEG(SINH(DX!/T!)))

    ENDIF

    RETURN T!

endproc

proc RAD2DEG

    PARAMETERS ANGLE!
    RETURN (180 / @PI()) * ANGLE!

endproc

proc SINH

    PARAMETERS ANGLE!
    RETURN (@EXP(ANGLE!) - @EXP(-ANGLE!)) / 2

./../function-references/XProfan/endproc/'>endproc

 
12/05/06  
 



 
- Page 2 -


ok *180/pi could one still in *57.295779513082320876798154814105 supplant...
 
12/05/06  
 




Jac
de
Lad
How you mean...
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
12/05/06  
 



clear gladly mach I... I building time NEN PerformanceCheck drunter but Deins is rather see I now already mom...
 
12/05/06  
 




Jac
de
Lad
180/Pi is about 57.295779513082320876798154814105170332405472466564321549160243861202847148321552632440968995851110944186223381632864893281448264601248315036068267863411942122526388097467267926307988702893110767938261442638263158209610460487020506444259656841120171912057738566280431284962624203376187937297623870790340315980719624089522045186205459923396314841906966220115126609691801514787637366923164107126774038514690165499594192515711986479435210661624389035202306756177796757113315683506205731313360156501348898018788709918

 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
12/05/06  
 



Hm ne Deins gives I do not whom Winkel in strain look time to that comparison both Procs:
CompileMarkSeparation
 {$cleq}
const myPi=3.1415926535897932384626433832795
cls

while 1

    cls
    print int(wnk(100,100,mousex,mousey,false)),"°  "
    print winkel(100,100,mousex,mousey),"°"
    sleep 50

wend

waitkey

proc wnk(float x1,y1,x2,y2,int mode)

    float x= sub ( x2! , x1! )
    float y= sub ( y2! , y1! )
    line x1,y1 - x2,y2
    case (x<0) and (y<0) : return wnk(x2,y2,x1,y1,3)
    case x<0 : return wnk(x2,y1,x1,y2,1)
    case y<0 : return wnk(x1,y2,x2,y1,2)
    casenot x : x=0.0000001
    casenot y : y=0.0000001
    float w=arctan(y/x)*57.295779513082320876798154814105

    if (mode==1)

        w:=90+(90-w)

    elseif (mode==2)

        w:=360-w

    elseif (mode==3)

        w:=180+w

    endif

    return w

endproc

proc Winkel

    Parameters x1!,y1!,x2!,y2!
    declare dx!,dy!
    dx!=x2!-x1!
    dy!=y1!-y2!

    if Abs(dx!)<Abs(dy!)

        Return Pi()/2-ArcTan(dx!/dy!)+If((dx!<0) | (dy!<0),Pi(),0)

    else

        Return ArcTan(dy!/dx!)+If((dx!<0) | (dy!<0),Pi(),0)

    endif

/../../function-references/XProfan/endproc/'>endproc

 
12/05/06  
 




Jac
de
Lad
I Have one year preparatory work through Parcival, there expect I, that my Formel rather is!
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
12/05/06  
 



clear but tappt im dunkeln is not.
 
12/05/06  
 




Jac
de
Lad
Have The Umrechnung in Dezimalgrad forget:
CompileMarkSeparation
proc Winkel

    Parameters x1!,y1!,x2!,y2!
    declare dx!,dy!
    dx!=x2!-x1!
    dy!=y2!-y1!

    if Abs(dx!)<Abs(dy!)

        Return (Pi()/2-ArcTan(dx!/dy!)+If((dx!<0) | (dy!<0),Pi(),0))/Pi()*180

    else

        Return (ArcTan(dy!/dx!)+If((dx!<0) | (dy!<0),Pi(),0))/Pi()*180

    endif

Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
12/05/06  
 



everything clear I look...
 
12/05/06  
 



Jain: look self:
CompileMarkSeparation
 {$cleq}
const myPi=3.1415926535897932384626433832795
cls

while 1

    cls
    print int(wnk(100,100,mousex,mousey,false)),"°  "
    print winkel(100,100,mousex,mousey),"°"
    sleep 50

wend

waitkey

proc wnk(float x1,y1,x2,y2,int mode)

    float x= sub ( x2! , x1! )
    float y= sub ( y2! , y1! )
    line x1,y1 - x2,y2
    case (x<0) and (y<0) : return wnk(x2,y2,x1,y1,3)
    case x<0 : return wnk(x2,y1,x1,y2,1)
    case y<0 : return wnk(x1,y2,x2,y1,2)
    casenot x : x=0.0000001
    casenot y : y=0.0000001
    float w=arctan(y/x)*57.295779513082320876798154814105

    if (mode==1)

        w:=90+(90-w)

    elseif (mode==2)

        w:=360-w

    elseif (mode==3)

        w:=180+w

    endif

    return w

endproc

proc Winkel

    Parameters x1!,y1!,x2!,y2!
    declare dx!,dy!
    dx!=x2!-x1!
    dy!=y2!-y1!

    if Abs(dx!)<Abs(dy!)

        Return (Pi()/2-ArcTan(dx!/dy!)+If((dx!<0) | (dy!<0),Pi(),0))/Pi()*180

    else

        Return (ArcTan(dy!/dx!)+If((dx!<0) | (dy!<0),Pi(),0))/Pi()*180

    endif

/../../function-references/XProfan/endproc/'>endproc


If xx<x and y<yy scheiterts.
 
12/05/06  
 



means ähäm the isses Yes strain I must The mouse KreisRum wander can and always the right Value receive. your function is sure Real rather as they yet the same result How my ausspuckt.
 
12/05/06  
 




Jac
de
Lad
Why must unbeding 270° supra his? under wärs plenty plainer!
 
Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE)
Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP
12/05/06  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

5.020 Views

Untitledvor 0 min.
Michael W.12/23/16
Julian Schmidt11/25/13
holmol9305/10/13
Andreas Koch11/07/12
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie