瀏覽代碼

Fix tests for point on line with infinite slope.

Sam Jaffe 6 年之前
父節點
當前提交
38d2560b55
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      math/src/common.cpp

+ 3 - 0
math/src/common.cpp

@@ -34,6 +34,9 @@ namespace math {
   }
   
   bool contains(dim2::line const & ln, dim2::point const & pt) {
+    if (ln.first[0] == ln.second[0]) {
+      return pt[0] == ln.first[0] && between(pt[1], ln.first[1], ln.second[1]);
+    }
     return approx_equal((ln.first[0] - pt[0]) * ln.slope() + pt[1],
                         ln.first[1], static_cast<float>(1E-6));
   }