Jump to content
  • Advertisement
Sign in to follow this  
fguihen

repesenting inifnity

This topic is 4906 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

im writing an algorithm to test if two lines intersect. its fine , except when a line is vertical ,and its m( slope) = infinity. this means that i have to scrap my algorithm. is there any way i can approximate infinity, so that i can keep my algorithm? i know infinity is..well infinity, nut worth asking

Share this post


Link to post
Share on other sites
Advertisement
What kind of precision are you using? Does your language have an "inf" built in? Is this in 2D or 3D? I guess for them to be parallel their slopes must be equal right? So assuming 2D couldnt you just have it be like
(assumign there exists Line.m = slope

bool 2dLineIntersect(Line L1,Line L2){
if(!(L1.m==L2.m))
{
REST OF ROUTINE
}

}

Share this post


Link to post
Share on other sites
Quote:
Original post by healeyx76
... I guess for them to be parallel their slopes must be equal right? ...

Parallel lines aren't the problem - it is vertical lines which are the problem, since they have an 'm' (slope) value of infinity.

Anyway, I'd agree with alvaro - represent the line with a point and a direction vector.

(and, have a look at Magic-Software.com, to see how they've done it - although, don't forget to read the license if you want to use that code itself, rather than using it to learn the relevant algorithms)

John B

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!