package main

// Sphere
type Sphere struct {
	radius   float64
	material Material
}

func (s Sphere) Distance(p Vector3) float64 {
	return p.Length() - s.radius
}

func (s Sphere) GetMaterial(p Vector3) Material {
	return s.material
}

// Box
type Box struct {
	dimensions Vector3
	material   Material
}

func (s Box) Distance(p Vector3) float64 {
	q := p.Abs().Sub(s.dimensions)
	return q.Max(0.0).Length() + min(max(q.X, max(q.Y, q.Z)), 0.0)
}

func (s Box) GetMaterial(p Vector3) Material {
	return s.material
}

// Plane
type Plane struct {
	normal   Vector3
	material Material
}

func (s Plane) Distance(p Vector3) float64 {
	return p.Dot(s.normal)
}

func (s Plane) GetMaterial(p Vector3) Material {
	return s.material
}
