| |
|
|
| Posesiones hier una Code gefunden [...] KompilierenMarcaSeparaciónFunction 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 el veces portieren y schauen si el se ejecuta... |
|
|
| |
|
|
|
| Ok KompilierenMarcaSeparaciónfloat intersection_ab,intersection_cd,intersection_x,intersection_y
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
| 05.12.2006 ▲ | |
|
|
|
|
| Hehe funktioniert super!
Testcode: KompilierenMarcaSeparación {$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
|
|
|
| |
|
|
|
| |
|
|