added bounds function and segline to intersect function
This commit is contained in:
11
internal/geom/intersect.go
Normal file
11
internal/geom/intersect.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package geom
|
||||
|
||||
func SegLineIntersect(A, B, O, D Vec) (bool, float64) {
|
||||
r := Sub(B, A)
|
||||
den := Cross(r, D)
|
||||
if NearlyZero(den) {
|
||||
return false, 0
|
||||
}
|
||||
t := Cross(Sub(O, A), D) / den
|
||||
return t > EPS && t < 1-EPS, t
|
||||
}
|
||||
Reference in New Issue
Block a user