|
![](/i/fill.gif) |
Straight lines will cross at one point if their slopes differ.
In an equation of the form y=m*x+b, m is the slope and b the y-intercept.
Where you have two lines y=m1*x+b1, and y=m2*x+b2, you can solve
x=(b1-b2)/(m2-m1) and then subtitute to find y.
A) x=2*y+1 (y=0.5*x-0.5)
B) y=x-1
x = ((-0.5)-(-1))/(1 -0.5) = 0.5/0.5 = 1
y=0.5-0.5=0
In general curved lines are not required to intersect, and if they do
intersect there can be an infinite number of intersections. However, any
two curved lines with a known equations can be tested for intersections
in some interval.
#macro line_intersect_2d(m1 b1 m2 b2)
#if (m1=m2)
#error "There is no intersection!\n"
#else
#local result = <((b1-b2)/(m2-m1)),m1*((b1-b2)/(m2-m1))+b1>;
#end
result
#end
#declare I = line_intersect_2d(0.5, -0.5, 1, -1);
Post a reply to this message
|
![](/i/fill.gif) |