Efficient way of finding distance between two 3D points

后端 未结 11 1160
借酒劲吻你
借酒劲吻你 2021-02-01 06:42

I am writing a code in C++ and want to compute distance between two points. Question 1:

I have two points P(x1, y1, z1) and Q(x2, y2, z2) , where x,

11条回答
  •  渐次进展
    2021-02-01 07:35

    Is there a better way if I just want to determine if P and Q are in fact the same points?

    Then just compare the coordinates directly!

    bool areEqual(const Point& p1, const Point& p2) {
         return fabs(p1.x - p2.x) < EPSILON &&
                fabs(p1.y - p2.y) < EPSILON &&
                fabs(p1.z - p2.z) < EPSILON;
    }
    

提交回复
热议问题