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 4 -



Hubert
Binnewies
you have right....You konntest with my Gleichung nothing anfangem because tappt im dunkeln schlichtweg wrong was....

The korrekte Formel you see under in the Image.

Woraus itself the following Listing yields...übergangs- and sprunglos...
CompileMarkSeparation
CLS
declare T!,DX!,DY!

WHILE 1

    CLS
    PRINT WNK(400,200,%MOUSEX,%MOUSEY)
    SLEEP 50

ENDWHILE

WAITKEY

proc WNK

    PARAMETERS X&,Y&,XX&,YY&
    LINE X&,Y& - XX&,YY&

    if xx&-x&>0

        if yy&-y&>0

            T! = (90*(yy& - y&))/sqrt((xx& - x&)^2 + (yy& - y&)^2)

        endif

    endif

    if xx&-x&<0

        if yy&-y&>0

            T! = 90-((90*(yy& - y&))/sqrt(((xx& - x&)*-1)^2 + (yy& - y&)^2))+90

        endif

    endif

    if xx&-x&<0

        if yy&-y&<0

            T! = 180+((90*((yy& - y&)*-1))/sqrt(((xx& - x&)*-1)^2 + ((yy& - y&)*-1)^2))

        endif

    endif

    if xx&-x&>0

        if yy&-y&<0

            T! = 180-((90*((yy& - y&)*-1))/sqrt((xx& - x&)^2 + ((yy& - y&)*-1)^2))+180

        endif

    endif

    RETURN T!

./../Function-References/XProfan/endproc/'>endproc


can you so what begin??

Hubert

3 kB
Kurzbeschreibung: Gleichung
Hochgeladen:12/06/06
Downloadcounter100
Download
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/06  
 




Hubert
Binnewies
you have right....You konntest with my Gleichung nothing anfangem because tappt im dunkeln schlichtweg wrong was....

The korrekte Formel you see under in the Image.

Woraus itself the following Listing yields...übergangs- and sprunglos...
CompileMarkSeparation
CLS
declare T!,DX!,DY!

WHILE 1

    CLS
    PRINT WNK(400,200,%MOUSEX,%MOUSEY)
    SLEEP 50

ENDWHILE

WAITKEY

proc WNK

    PARAMETERS X&,Y&,XX&,YY&
    LINE X&,Y& - XX&,YY&

    if xx&-x&>0

        if yy&-y&=0

            T! = 0

        endif

    endif

    if xx&-x&>0

        if yy&-y&>0

            T! = (90*(yy& - y&))/sqrt((xx& - x&)^2 + (yy& - y&)^2)

        endif

    endif

    if xx&-x&=0

        if yy&-y&>0

            T! = 90

        endif

    endif

    if xx&-x&<0

        if yy&-y&>0

            T! = 90-((90*(yy& - y&))/sqrt(((xx& - x&)*-1)^2 + (yy& - y&)^2))+90

        endif

    endif

    if xx&-x&<0

        if yy&-y&=0

            T! = 180

        endif

    endif

    if xx&-x&<0

        if yy&-y&<0

            T! = 180+((90*((yy& - y&)*-1))/sqrt(((xx& - x&)*-1)^2 + ((yy& - y&)*-1)^2))

        endif

    endif

    if xx&-x&=0

        if yy&-y&<0

            T! = 270

        endif

    endif

    if xx&-x&>0

        if yy&-y&<0

            T! = 180-((90*((yy& - y&)*-1))/sqrt((xx& - x&)^2 + ((yy& - y&)*-1)^2))+180

        endif

    endif

    RETURN T!

endproc


can you so what begin??

Hubert

3 kB
Kurzbeschreibung: Gleichung
Hochgeladen:12/06/06
Downloadcounter138
Download
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/06  
 



clear super! in the principle if I now both compare - have You my ArcTang into Sqrt swapped - time so roughly said.

I mean - habs but only übersprungen - Your formula gives a incorrect worth if xx-x or yy-y same zero is. But secondary matter and through one >=0 instead of >0 To bebehen.

now must I only yet rausbekommen whether your Variante More performance in XProfan has.

Ah you've seen grad again revised the formula - I look time...
 
12/06/06  
 




Hubert
Binnewies
[quote:93643e9b90=iF]Your formula gives a incorrect worth if xx-x or yy-y same zero is. But secondary matter and through one >=0 instead of >0 To bebehen.

[/quote:93643e9b90]
would I do not do....because if yy-y=0 and is You 0*90 make remaining it 0...
and if You then attempt The 0 To share erhälst You a ungültigen Funktionswert..

look into second listing...the first is unfortunately one accident at reinsetzen in that Forum...
there have I the trouble resolved...

Hubert
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/06  
 



Yeha! your formal needed 9% wniger Time by me

here the SpeedTestCode:
CompileMarkSeparation
DECLARE T!,DX!,DY!
RANDOMIZE
CLS
var TME&=&GETTICKCOUNT

WHILELOOP 10000

    WNK(100,100,RND(200),RND(200))

ENDWHILE

TME&=&GETTICKCOUNT-TME&
var TME2&=&GETTICKCOUNT

WHILELOOP 10000

    WNK2(100,100,RND(200),RND(200))

ENDWHILE

TME2&=&GETTICKCOUNT-TME2&
PRINT TME&
PRINT TME2&
WAITKEY

proc WNK

    PARAMETERS X1!,Y1!,X2!,Y2!,MODE%
    var DX!=X2!-X1!
    var DY!=Y2!-Y1!

    IF (DX!<0) AND (DY!<0)

        RETURN WNK(X2!,Y2!,X1!,Y1!,3)

    ENDIF

    IF DX!<0

        RETURN WNK(X2!,Y1!,X1!,Y2!,1)

    ENDIF

    IF DY!<0

        RETURN WNK(X1!,Y2!,X2!,Y1!,2)

    ENDIF

    IFNOT DX!

        DX!=0.0000001

    ENDIF

    IFNOT DY!

        DY!=0.0000001

    ENDIF

    var W!=ARCTAN(DY!/DX!)*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 WNK2

    PARAMETERS X&,Y&,XX&,YY&

    IF XX&-X&>0

        IF YY&-Y&=0

            T!=0

        ENDIF

    ENDIF

    IF XX&-X&>0

        IF YY&-Y&>0

            T!=(90*(YY& - Y&))/SQRT((XX& - X&)^2 + (YY& - Y&)^2)

        ENDIF

    ENDIF

    IF XX&-X&=0

        IF YY&-Y&>0

            T!=90

        ENDIF

    ENDIF

    IF XX&-X&<0

        IF YY&-Y&>0

            T!=90-((90*(YY& - Y&))/SQRT(((XX& - X&)*-1)^2 + (YY& - Y&)^2))+90

        ENDIF

    ENDIF

    IF XX&-X&<0

        IF YY&-Y&=0

            T!=180

        ENDIF

    ENDIF

    IF XX&-X&<0

        IF YY&-Y&<0

            T!=180+((90*((YY& - Y&)*-1))/SQRT(((XX& - X&)*-1)^2 + ((YY& - Y&)*-1)^2))

        ENDIF

    ENDIF

    IF XX&-X&=0

        IF YY&-Y&<0

            T!=270

        ENDIF

    ENDIF

    IF XX&-X&>0

        IF YY&-Y&<0

            T!=180-((90*((YY& - Y&)*-1))/SQRT((XX& - X&)^2 + ((YY& - Y&)*-1)^2))+180

        ENDIF

    E
a> RETURN T! endproc
 
12/06/06  
 



so now try I Your formula again bisl programmablauftechnisch To optimize...
 
12/06/06  
 




Hubert
Binnewies
[quote:ed547f9469=iF]so now try I Your formula again bisl programmablauftechnisch To optimize...[/quote:ed547f9469]
Have I already...lose therefore of course something on übersichtlichkeit, but it vanish some zeitaufwendige IF inquire...
CompileMarkSeparation
CLS
declare T!,DX!,DY!

WHILE 1

    CLS
    PRINT WNK(400,200,%MOUSEX,%MOUSEY)
    SLEEP 50

ENDWHILE

WAITKEY

proc WNK

    PARAMETERS X&,Y&,XX&,YY&
    LINE X&,Y& - XX&,YY&

    if xx&-x&>0

        if yy&-y&=0

            T! = 0 <---können auch 360 Grad sein

        elseif yy&-y&>0

            T! = (90*(yy& - y&))/sqrt((xx& - x&)^2 + (yy& - y&)^2)

        elseif yy&-y&<0

            T! = 180-((90*((yy& - y&)*-1))/sqrt((xx& - x&)^2 + ((yy& - y&)*-1)^2))+180

        endif

    endif

    if xx&-x&=0

        if yy&-y&>0

            T! = 90

        elseif yy&-y&<0

            T! = 270

        endif

    endif

    if xx&-x&<0

        if yy&-y&>0

            T! = 90-((90*(yy& - y&))/sqrt(((xx& - x&)*-1)^2 + (yy& - y&)^2))+90

        elseif yy&-y&=0

            T! = 180

        elseif yy&-y&<0

            T! = 180+((90*((yy& - y&)*-1))/sqrt(((xx& - x&)*-1)^2 + ((yy& - y&)*-1)^2))

        endif

    endif

    RETURN T!

 href='./../../Function-References/XProfan/endproc/'>endproc


rather??
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/06  
 



so to of my optimization is your Variante twice so quick How my Variante! here the Endergebnis:
CompileMarkSeparation
proc WNK2

    PARAMETERS X!,Y!,XX!,YY!
    var DX!=XX!-X!
    var DY!=YY!-Y!

    IF DX!>0

        IF DY!>0

            RETURN (90*(DY!))/SQRT((DX!)^2 + (DY!)^2)

        ELSEIF DY!<0

            RETURN 180-((90*((DY!)*-1))/SQRT((DX!)^2 + ((DY!)*-1)^2))+180

        ELSE

            RETURN 0

        ENDIF

    ELSEIF DX!<0

        IF DY!>0

            RETURN 90-((90*(DY!))/SQRT(((DX!)*-1)^2 + (DY!)^2))+90

        ELSEIF DY!<0

            RETURN 180+((90*((DY!)*-1))/SQRT(((DX!)*-1)^2 + ((DY!)*-1)^2))

        ELSE

            RETURN 180

        ENDIF

    ELSE

        IF DY!>0

            RETURN 90

        ELSEIF DY!<0

            RETURN 270

        ELSE

            RETURN 0

        ENDIF

    ENDIF

    RETURN T!

/../Function-References/XProfan/endproc/'>endproc

 
12/06/06  
 



Erstklassige work can there only say!

thanks!
 
12/06/06  
 




Hubert
Binnewies
jep....you have Yes nochn bunch subtraktionen and variables benennungen rausgenommen....

are you because so pleased? or must it even faster??

(I had Yes promised that I me what consider)....

Hubert
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/06  
 



means twice so quick How my Result is about the I me vorstellte

goes these function similar umzustellen?
CompileMarkSeparation
proc GETCIRCP

    PARAMETERS XP!,YP!,R!,W!
    COS_OUTPX!=((((R!*SIN(((-1*(((-1+W!)*3.1415926535897932384626433832795)+3.1415926535897932384626433832795))/180))))*-1)+XP!)
    COS_OUTPY!=((((R!*COS(((-1*(((-1+W!)*3.1415926535897932384626433832795)+3.1415926535897932384626433832795))/180))))*-1)+YP!)

endp
>
 
12/06/06  
 




Hubert
Binnewies
[quote:0fce4dc459=iF]Erstklassige work can there only say!

thanks! [/quote:0fce4dc459]
Please Please....
gladly made...

[offtopic] then kannste you Yes think what hierdrin abgeht--->  [...]  [/offtopic]
 
WinXP Prof, XProfan 9.1 Newbie

Ein kluger Kopf sagte mal:
"Nach dem derzeitigen Stand der Technik ist es unmöglich Programme zu schreiben, die fehlerfrei laufen!"
12/06/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.017 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