Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Check if line is straight

by Anonymous Monk
on May 16, 2011 at 20:14 UTC ( [id://905143]=note: print w/replies, xml ) Need Help??


in reply to Re: Check if line is straight
in thread Check if line is straight

This is pretty neat, saves a lot of code. What is the best way to add tolerance to this? any suggestions ? Thanks

Replies are listed 'Best First'.
Re^3: Check if line is straight
by lidden (Curate) on May 16, 2011 at 23:13 UTC
    return abs(($x2-$x1)*($y-$y1)-($x-$x1)*($y2-$y1)) < $tolerance;

    Update added abs()

Re^3: Check if line is straight
by pajout (Curate) on May 17, 2011 at 11:30 UTC
    It depends if you mean tolerance necessary for dealing floats - lidden suggested it already. But if you mean real tolerance, for instance "path is correct if the angle between two vectors is less than 1 degree", you should really compute that value.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://905143]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found