# equation of line , without using a slope ( determinants)

This topic is 4907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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
ad = p1.Yval - p2.Yval;
bc = p2.Xval - p1.Xval;

c = ad* p1.Xval + bc*p1.Yval;

//line2
double c2;

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?

##### Share on other sites
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:
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.

##### Share on other sites
You can make use of parametric equation for the lines.
Search for LINES_SEG_INT_2D in the source "geometry.f90" you find in this page (it's in cobol, but it easy to read and well commented).

Hope this helps!

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631790
• Total Posts
3002365
×