| Author |
Intersection of two lines
|
|
| Mark Mendez 2005-11-17, 3:59 am |
| I am trying to write a code that solves for the intersection of two
lines as their slopes and y-intercepts change indepently of each
other. i was wondering if anyone knew of a easy way to do this. Right
now i have everything in a table and i want it to calculate all the
possible solutions into a mesh that i can plot in 3D based on the x
and y value of the intersection.
| |
| nma@12000.org 2005-11-17, 3:59 am |
| Mark Mendez wrote:
> I am trying to write a code that solves for the intersection of two
> lines as their slopes and y-intercepts change indepently of each
> other. i was wondering if anyone knew of a easy way to do this. Right
> now i have everything in a table and i want it to calculate all the
> possible solutions into a mesh that i can plot in 3D based on the x
> and y value of the intersection.
intersection point is the solution to the 2 lines equations. The
solution is (x,y).
So, set up Ax=c and solve for 'x', where 'x' here is the (x,y) point,
using Matlab \ operator.
example:
%y=m1 x + c1
%y=m2 x + c2
m1=.5;
m2=.3;
c1=0;
c2=1;
c=[c1;c2];
A=[1 -m1;1 -m2]
intersectionPoint = A\c
Nasser
| |
|
| nma wrote:
>
>
> Mark Mendez wrote:
> two
each[color=darkred]
> Right
> the
the[color=darkred]
> x
>
> intersection point is the solution to the 2 lines equations. The
> solution is (x,y).
> So, set up Ax=c and solve for 'x', where 'x' here is the (x,y)
> point,
> using Matlab \ operator.
>
> example:
>
> %y=m1 x + c1
> %y=m2 x + c2
>
> m1=.5;
> m2=.3;
> c1=0;
> c2=1;
>
> c=[c1;c2];
>
> A=[1 -m1;1 -m2]
>
> intersectionPoint = A\c
>
> Nasser
>
>
Why does A = [1 -m1;1 -m2]. I do not understand why it is a 2x2
matrix and why a value of 1?
| |
| minikitty 2005-11-17, 7:06 pm |
| Maybe this is easier for you?
y - m1 x = c1
y - m2 x = c2
A [y;x] = [c1; c2] ===> [y;x] = A\[c1;c2]
| |
| N.P.Nagendra Rao 2005-11-28, 3:58 am |
| minikitty wrote:
>
>
> Maybe this is easier for you?
> y - m1 x = c1
> y - m2 x = c2
>
> A [y;x] = [c1; c2] ===> [y;x] = A\[c1;c2]
>
>
my answer is :
l1=[a1 b1 c1] l2=[a2 b2 c2]
matlab programme is :
P=intersection(l1,l2):
a=A(1);b=A(2);c=A(3);
p=B(1);q=B(2);z=B(3);
d=p*b-a*q;
x= (q*c-b*z)/d;
y= (a*z-p*c)/d;
P(1)=x;
P(2)=y;
|
|
|
|