Dear friends:
I am working on a C++ computational geometry code, and i want to make sure whether two points are the same by comparing their x y and z coordinates. The coordinates of the points are in the double formate.
since the pc can not represents the double number exactly in the memory, and i have a large number of points in a small region, i think it is inaccurate to do the comparison by a simple "==".
Could you please give me some advices on that?
Regards
Your Sincerely.
ztdep
ztdep
-8
Junior Poster in Training
Recommended Answers
Jump to PostYou can use range
boot equals (double n1, double n2) { if (abs((n1 - n2)) < 0.001) return true; else { return false; }}
Something like this. I wrote this in 2 minutes so you may wont to modify this a little to suit your needs better, …
Jump to PostI think that before you suggest solutions to a problem, it is important to understand exactly what problem you are trying to solve.
When you say that you "want to make sure whether two points are the same," exactly what do you mean? In other words, will you ever …
All 5 Replies
sergent
52
Posting Pro
Asen
0
Newbie Poster
template<>
37
Junior Poster
arkoenig
340
Practically a Master Poster
ztdep
-8
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.