Skip to content

Version v2.2.10 - Fix "point is on segment"

Compare
Choose a tag to compare
@LdDl LdDl released this 27 Aug 19:24
· 4 commits to master since this release

What's new

There is obvious mistake (which leads to wrong calculations with oblique lines) in code below

func isOnSegment(Px, Py, Qx, Qy, Rx, Ry int) bool {
	if Qx <= maxInt(Px, Rx) && Qx >= maxInt(Px, Rx) && Qy <= maxInt(Py, Ry) && Qy >= maxInt(Py, Ry) {
		return true
	}
	return false
}

Qx >= maxInt(Px, Rx) should be Qx >= minInt(Px, Rx)
Qy >= maxInt(Py, Ry) should be Qy >= minInt(Py, Ry)

Now this is fixed