English
Source / code snippets

Kreuzen lines maths

 
have here code found  [...] 
CompileMarkSeparation
Function Lines_Intersect(ax#, ay#, bx#, by#, cx#, cy#, dx#, dy#)
rn# = (ay#-cy#)*(dx#-cx#) - (ax#-cx#)*(dy#-cy#)
rd# = (bx#-ax#)*(dy#-cy#) - (by#-ay#)*(dx#-cx#)

If rd# = 0

    Return False

Else

    sn# = (ay#-cy#)*(bx#-ax#) - (ax#-cx#)*(by#-ay#)
    intersection_ab# = rn# / rd#
    intersection_cd# = sn# / rd#
    intersection_x#  = ax# + intersection_ab#*(bx#-ax#)
    intersection_y#  = ay# + intersection_ab#*(by#-ay#)
    Return True

EndIf

End Function

If intersection=0 Or intersection_ab#<0 Or intersection_ab#>1 Or intersection_cd#<0 Or intersection_cd#>1 Then

    Text 0,40,"Linien kreuzen nicht"

Else

    Text 0,40,"Linien kreuzen"

EndIf


Werd whom time portieren and look whether the runs...
 
12/05/06  
 



OK
CompileMarkSeparation
12/05/06  
 



Hehe functions super!

Testcode:
CompileMarkSeparation
 {$cleq}
const myPI=3.1415926535897932384626433832795
float cos_outpx,cos_outpy,w
float intersection_ab,intersection_cd,intersection_x,intersection_y
bool intersection
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,"+"
    line 150,50 - 150,200
    intersection:=LineIntersec(100,100,mousex,mousey,150,50,150,200)

    If (intersection==false) Or (intersection_ab<0) Or (intersection_ab>1) Or (intersection_cd<0) Or (intersection_cd>1)

        print "Linien kreuzen nicht"

    Else

        print "Linien kreuzen"

    EndIf

    sleep 50

wend

waitkey

proc LineIntersec(float ax,ay,bx,by,cx,cy,dx,dy)

    float rn:=(ay-cy)*(dx-cx) - (ax-cx)*(dy-cy)
    float rd:=(bx-ax)*(dy-cy) - (by-ay)*(dx-cx)
    case (rd==0) : return false
    float sn = (ay-cy)*(bx-ax) - (ax-cx)*(by-ay)
    intersection_ab = rn / rd
    intersection_cd = sn / rd
    intersection_x  = ax + intersection_ab*(bx-ax)
    intersection_y  = ay + intersection_ab*(by-ay)
    return true

endproc

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

 
12/05/06  
 



so The summary:
CompileMarkSeparation
12/05/06  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.675 Views

Untitledvor 0 min.
Michael W.12/23/16
Ernst05/26/14
Julian Schmidt08/30/11

Themeninformationen

this Topic has 1 subscriber:

iF (4x)


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