ad = p1.Yval - p2.Yval;
bc = p2.Xval - p1.Xval;
c = ad* p1.Xval + bc*p1.Yval;
//line2
double ad2,bc2;
double c2;
ad2 = p3.Yval - p4.Yval;
bc2 = p4.Xval - p3.Xval;
c2 = ad* p3.Xval + bc*p3.Yval;
my algorithm is not working at all and the only place i can see that it might not be funcitioning is in getting the line equations. does this look ok, or do you have any suggestions?
equation of line , without using a slope ( determinants)
i , in a previous post have shown my method for using determinants to check for intersection of two lines. this is how i am getting the two line equations
Looks right to me. As a sanity check you can always put your equation into the more intuitive (at least for me) slope-intercept form and you'd get:
Which is essentially:
Which is correct as far as I know.
p1.Yval = (-ad/bc)p1.Xval + (c/bc)
Which is essentially:
y = (p2.Yval - p1.Yval)x/(p2.Xval - p1.Xval) + c/(p2.Xval - p1.Xval)
Which is correct as far as I know.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement