MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / on_segment

Function on_segment

nodedb-spatial/src/predicates/edge.rs:33–38  ·  view source on GitHub ↗

Whether point q lies on segment p-r (given that p, q, r are collinear).

(p: [f64; 2], q: [f64; 2], r: [f64; 2])

Source from the content-addressed store, hash-verified

31
32/// Whether point q lies on segment p-r (given that p, q, r are collinear).
33pub fn on_segment(p: [f64; 2], q: [f64; 2], r: [f64; 2]) -> bool {
34 q[0] <= p[0].max(r[0])
35 && q[0] >= p[0].min(r[0])
36 && q[1] <= p[1].max(r[1])
37 && q[1] >= p[1].min(r[1])
38}
39
40/// Whether two segments (p1-q1) and (p2-q2) intersect.
41///

Callers 1

segments_intersectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected