google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.32k stars 308 forks source link

Why Polyline::Contains(S2Point) is not numerically well-defined? #199

Closed jievince closed 3 years ago

jievince commented 3 years ago

In math, testing if a point is on a line is easy.

jmr commented 3 years ago

S2Points have finite precision. It's not really useful or interesting to ask if a point is on a line. Use the distance to the line with a threshold if you want to do that.

jievince commented 3 years ago

Sorry @jmr, I didn't find a function in the S2 library that defines the shortest distance from a S2Point to a Polyline.

jievince commented 3 years ago

Seems S2Polyline::Project is what I want...