def chord.near
gralha-svg-render@0.1.0.1 · svg.bend:169
import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
169
170
171def chord.near(+p: Point, +q: Point, +x: Point, +tol: F32) -> Bool:
172 +d = point.sub(q, p)
173 +len = F32.sqrt(point.dot(d, d))
174 +off = point.sub(x, p)
175 U.branch(Bool, F32.is_lt(len, 0.000001), _ => F32.is_le(point.distance(p, x), tol),
176 _ => F32.is_le(F32.abs(chord.cross(d, off)), (tol * len : F32))
177 && F32.is_ge(point.dot(d, off), (F32.neg(tol) * len : F32))
178 && F32.is_le(point.dot(d, off), ((len + tol) * len : F32)))