public function distanceSquared($x, $y = 0) { if ($x instanceof Vector2) { return $this->distanceSquared($x->x, $x->y); } else { return pow($this->x - $x, 2) + pow($this->y - $y, 2); } }