Jump to content
  • Advertisement
Sign in to follow this  
fguihen

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.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!