16 lines
316 B
Go
16 lines
316 B
Go
package shape
|
|
|
|
import "zworld/plugin/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
|
|
}
|