Working with mathematical errors
Working with mathematical errors
- Subject: Working with mathematical errors
- From: Ashley Perrien <email@hidden>
- Date: Sun, 27 Jul 2008 20:41:02 -0500
What is the most common/accepted way of dealing with the inaccuracies
of floating point math? I'm trying to find out 1) Do 2 NSBezierPath
lines intersect and then 2) What is the point of the intersection?
Given a couple points on a line I can find the intersection point but
since 2 line segments may not intersect, I then check:
if([lineOne containsPoint: intersectionPoint])
That will nearly always fail unless the math works out to very nice,
neat, round numbers. I've seen one possible workaround of multiplying
everything by 100 and then doing integer math but considering I've got
some division involved, not sure exactly if that would work. I guess I
could just check the values myself (if point1 is +- .001 of point2)
but that seems kinda hackish.
What's the most common way of dealing with these types of problems?
Ashley Perrien
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden