zworld/plugins/math/shape/sphere.go

16 lines
317 B
Go
Raw Permalink Normal View History

2024-01-14 22:56:06 +08:00
package shape
import "zworld/plugins/math/vec3"
type Sphere struct {
Center vec3.T
Radius float32
}
func (s *Sphere) IntersectsSphere(other *Sphere) bool {
sepAxis := s.Center.Sub(other.Center)
radiiSum := s.Radius + other.Radius
intersects := sepAxis.LengthSqr() < (radiiSum * radiiSum)
return intersects
}