(geometry) Определение точки пересечения 2-х отрезков
eps=0.00001
unID = 1000
call "Resize_A_B_ZZYZX" parameters all
pen colorAxes
if showAxes then call`(m)CoordinateAxes` parameters all
pen colorLines
hotspot2 0, y1, unID, x1, 1+128 : unID=unID+1
hotspot2 x1, y1, unID, x1, 2 : unID=unID+1
hotspot2 -1, y1, unID, x1, 3 : unID=unID+1
hotspot2 x1, 0, unID, y1, 1+128 : unID=unID+1
hotspot2 x1, y1, unID, y1, 2 : unID=unID+1
hotspot2 x1, -1, unID, y1, 3 : unID=unID+1
hotspot2 0, y2, unID, x2, 1+128 : unID=unID+1
hotspot2 x2, y2, unID, x2, 2 : unID=unID+1
hotspot2 -1, y2, unID, x2, 3 : unID=unID+1
hotspot2 x2, 0, unID, y2, 1+128 : unID=unID+1
hotspot2 x2, y2, unID, y2, 2 : unID=unID+1
hotspot2 x2, -1, unID, y2, 3 : unID=unID+1
hotspot2 0, y3, unID, x3, 1+128 : unID=unID+1
hotspot2 x3, y3, unID, x3, 2 : unID=unID+1
hotspot2 -1, y3, unID, x3, 3 : unID=unID+1
hotspot2 x3, 0, unID, y3, 1+128 : unID=unID+1
hotspot2 x3, y3, unID, y3, 2 : unID=unID+1
hotspot2 x3, -1, unID, y3, 3 : unID=unID+1
hotspot2 0, y4, unID, x4, 1+128 : unID=unID+1
hotspot2 x4, y4, unID, x4, 2 : unID=unID+1
hotspot2 -1, y4, unID, x4, 3 : unID=unID+1
hotspot2 x4, 0, unID, y4, 1+128 : unID=unID+1
hotspot2 x4, y4, unID, y4, 2 : unID=unID+1
hotspot2 x4, -1, unID, y4, 3 : unID=unID+1
!!!!!!!!!!!!!!{Определение уравнения прямой по координатам двух точек}
a1= y2-y1
b1= x1-x2
c1= -x1*(y2-y1)+y1*(x2-x1)
line2 x1,y1,x2,y2
a2= y4-y3
b2= x3-x4
c2= -x3*(y4-y3)+y3*(x4-x3)
line2 x3,y3,x4,y4
define style graph font_style,10/GLOB_SCALE*FontSize,1,1
style graph
pen 1
text2 x1,y1,"Уравнение прямой:"+str(a1,8,2)+"x +"+str(b1,8,2)+"y +"+str(c1,8,2)+"=0"
text2 x3,y3,"Уравнение прямой:"+str(a2,8,2)+"x +"+str(b2,8,2)+"y +"+str(c2,8,2)+"=0"
!!!!!!!!!!!!!!{
if a1*b2-a2*b1=0 then
text2 0,0,"Прямые параллельны"
else
x=(c2*b1-c1*b2)/(a1*b2-a2*b1)
y=(a2*c1-a1*c2)/(a1*b2-a2*b1)
hotspot2 x,y
gosub 10
endif
end
10:
if x>=min(x1,x2) and x<max(x1,x2) and y>=min(y1,y2) and y<max(y1,y2) and x>=min(x3,x4) and x<max(x3,x4) and y>=min(y3,y4) and y<max(y3,y4)then
circle2 x,y,0.01
else
text2 0,0,"Отрезки не пересекаются"
endif
return
ссылки по теме:
http://archicad-talk.graphisoft.com/viewtopic.php?t=41635
http://paulbourke.net/geometry/pointlineplane/