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


WO 270 is is sausage! can You gladly make as rather would!
 
12/05/06  
 



only times by the way the matching counterpart is on me to grad been successful ^^
CompileMarkSeparation
const myPI:=3.1415926535897932384626433832795
float cos_outpx,cos_outpy

proc getcircp(float xp,yp,r,w)

    cos_outpx:=((((r*sin(((-1*(((-1+w)*myPI)+myPI))/180))))*-1)+xp)
    cos_outpy:=((((r*cos(((-1*(((-1+w)*myPI)+myPI))/180))))*-1)+yp)

end
a>

CompileMarkSeparation
var COS_OUTPX!=0
var COS_OUTPY!=0

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!)

endproc

Okok over The clinging talk we not! *g*
 
12/05/06  
 



Jupp lol need something like The world *gg*
CompileMarkSeparation
 {$cleq}
const myPI=3.1415926535897932384626433832795
float cos_outpx,cos_outpy,w
cls

while 1

    cls
    w:=wnk(100,100,mousex,mousey,false)
    print int(w),"°  "
    getcircp 100,100,50,w+90
    drawtext cos_outpx,cos_outpy,"+"
    sleep 50

wend

waitkey

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

    float dx=x2!-x1!
    float dy=y2!-y1!
    line x1,y1 - x2,y2
    case (dx<0) and (dy<0) : return wnk(x2,y2,x1,y1,3)
    case dx<0 : return wnk(x2,y1,x1,y2,1)
    case dy<0 : return wnk(x1,y2,x2,y1,2)
    casenot dx : dx=0.0000001
    casenot dy : dy=0.0000001
    float 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 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

endproc

proc getcircp(float xp,yp,r,w)

    cos_outpx:=((((r*sin(((-1*(((-1+w)*myPI)+myPI))/180))))*-1)+xp)
    cos_outpy:=((((r*cos(((-1*(((-1+w)*myPI)+myPI))/180))))*-1)+yp)

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

 
12/05/06  
 




Hubert
Binnewies
means, i'm the opinion, The meiste Prozessorzeit goes with complicated Berechnungen How Sinus & Co on it.
therefore stops I it as it my verstorbener father (he was Berufskraftfahrer) always said has: The kürzeste lane isn't always the fastest !.

I thought me: with X,Y XX,y YY,X sustain one always one rechtwinkliges Dreieck.
If I look at your first proggie is more accurate because XX always greater as X and YY always greater as Y.
accordingly need one except for ne root whom Proz only with basic arithmetic To beauftragen, The it integrally quick to charge can.
first whom einfachen Pythagoras around the Hypothenuse To to charge and then one pages-Winkelverhältnis.

and ought to X still time greater go as XX then nimm simply X-XX time -1 and the Winkel plus 90 .
and ought to Y still time greater his as YY then nimm simply Y-YY time -1 and accused the Ergebniss of 360 strain ex... and already it fits...

The whole will then adjust the formula in the picture.

in the Programmtechnischen Umsetzen are You rather How I...

Hubert

3 kB
Kurzbeschreibung: Gleichung
Hochgeladen:12/06/06
Downloadcounter172
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  
 



I mean the isses I umgesetzt have what about me find your Pa having so sure often right.
 
12/06/06  
 




Hubert
Binnewies
[quote:1a7341c7f9=iF]I mean the isses I umgesetzt have[/quote:1a7341c7f9]
well even not.....
You uses The functions to that converting in that Bogenmaß circa Sinus and Cosinus To benefit....

drop it still everything lane....
do you need still not at all...
Setz simply my Formel circa.. only with the numbers, then comes directly as response The Gradzahl out..
goes still plenty fixer....
and the too yet so far How You @Set(Decimals,n) setting.....

I meant so: You uses whom direct Berechnungsweg, need for but the Umrechnung in that Bogenmaß and the Sinus.

In of my Formel becomes everything in 2 stepped accounts (Pythagoras and Verhältniss), but for without Beachtung the units, with which The rechenintensiven Operationen How @Deg2wheel(n) or @Sin(n) wegfallen...

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  
 



sqrt( ( (xx-x)² + (yy-y)² ) / (xx-x) )*90 ? Something like?
 
12/06/06  
 




Hubert
Binnewies
Bingo.....
 
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  
 




RGH
and in XProfan becomes from the formal then these row:
CompileMarkSeparation
!a! = (90 * sqrt((xx% - x%)^2 + (yy% - y%)^2)) / (xx% - x%)
>

a Tick faster Perhaps with the Sqr()-function:
CompileMarkSeparation
!a! = (90 * sqrt(sqr(xx% - x%) + sqr(yy% - y%))) / (xx% - x%)
>

Greeting
Roland
 
Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4
12/06/06  
 




Hubert
Binnewies
and everything without strain umrechnung....
GEHTS yet faster???
 
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 - now erfüllt Your Formel but unfortunately still not whom object the Threads here - what these but does:
CompileMarkSeparation
proc WNK

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

    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


means How should it because now lauten?
 
12/06/06  
 



means Perhaps once more to Task - I as MatheUnProfi have o.G. function prepares which I The Coordinates for a line commit and the Winkel sustain. without If and but must The values 0°-360° zurückgeliefert go - Umsprung-and-Übergangsfliessend.

so How I the see need I for only whom Arcustangens - a Multipli and Division. can one MatheProfi the improve?
 
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.012 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