Jump to content
  • Advertisement
Sign in to follow this  

A better way to solve problems than using functions..?

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

First of all a NOTE: functions as in y=ax+b not void foo(); What I am saying is, I've been working on some calculations lately (which require calculating segment intersection, line intersection, calculating coords, rotation etc.) and since I am a math person I've tried the first and most obvious way of solving them - using functions. Now the methods I've used work really great, the answers I get are pretty accurate and all, however I'm starting to dislike using functions when solving geometrical problems due to one problem... infinite slope. Since float cannot have an infinite value, every time I'm working with a function I have to check if its slope isn't infinite. This is ok for smaller stuff but when I have to calculate intersection points of 3 different lines... things get a little messy. So yeah, is there a better, commonly known alternative to solving different geometrical problems with functions? The only thing I thought of is using a really big number for infinite slope (say, 1 000 000 or so) - if you consider that your typical screen width/height is about 1000 pixels it should work just fine. But there is always that small inaccuracy... or am I worrying too much?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I just glanced at the site petewood referenced, but it looked like the vector form of lines is more complicated than need be. Using the parametric equation from two points (Line=P1+U*(P2-P1)), http://astronomy.swin.edu.au/~pbourke/geometry/ works out several equations quite nicely. It sounds like you need more complex equations than they give, but using this form might help some..?

-Extrarius

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!