From c9a0f3495f4334ce34493fa3149f08b2b6d6d73b Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 28 Feb 2018 19:39:34 +0100 Subject: [PATCH] simplify nonzero check --- src/LineSegment.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LineSegment.jl b/src/LineSegment.jl index e0ee0b1997..ddb8065871 100644 --- a/src/LineSegment.jl +++ b/src/LineSegment.jl @@ -136,8 +136,8 @@ The algorithm is inspired from [here](https://stackoverflow.com/a/328110). function ∈(x::AbstractVector{N}, L::LineSegment{N})::Bool where {N<:Real} @assert length(x) == dim(L) # check if the point is on the line through the line segment - if abs((x[2] - L.p[2]) * (L.q[1] - L.p[1]) - - (x[1] - L.p[1]) * (L.q[2] - L.p[2])) > 0 + if (x[2] - L.p[2]) * (L.q[1] - L.p[1]) - + (x[1] - L.p[1]) * (L.q[2] - L.p[2]) != 0 return false end # check if the point is inside the box approximation of the line segment