package types

type Edge struct {
	From Coords
	To   Coords
}

func (e *Edge) Midpoint() Coords {
	var dx, dy, minX, minY int
	if e.From.X > e.To.X {
		minX = e.To.X
		dx = e.From.X - e.To.X
	} else {
		minX = e.From.X
		dx = e.To.X - e.From.X
	}

	if e.From.Y > e.To.Y {
		minY = e.To.Y
		dy = e.From.Y - e.To.Y
	} else {
		minY = e.From.Y
		dy = e.To.Y - e.From.Y
	}
	return Coords{minX + dx / 2, minY + dy / 2}
}