Sign in to follow this  

equation of line , without using a slope ( determinants)

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

If you intended to correct an error in the post then please contact us.

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 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?

Share this post


Link to post
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 this post


Link to post
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!

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this