ghilesZ / geoml

A 2d geometry library for ocaml
GNU Lesser General Public License v2.1
35 stars 5 forks source link

Segment.contains contains an error #11

Closed richardalligier closed 3 years ago

richardalligier commented 3 years ago

Hi,

There is a mistake on Segment.contains. You should use Point.distance instead of Point.sq_distance.

Best regards, Richard

richardalligier commented 3 years ago

Furthermore, inside Circle.segment_intersection, instead of using Segment.contains, you could just check that the dot_product of the vector (a,p) and (a,b) is between 0 and (sq_distance a b) where we want to check if p is inside [a;b]. It could be more reliable because we already know that the point p is on the line defined by (a,b)

ghilesZ commented 3 years ago

Thanks for the issue. Do you by any chance have a fix? if not i will correct it this week-end

richardalligier commented 3 years ago

I made a pull request

ghilesZ commented 3 years ago

Great! Thank you again, i'm closing this issue