Sign in to follow this  
Koobazaur

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

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

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