33    public function __construct(
 
   38    public function getX() : 
float{
 
   42    public function getY() : 
float{
 
   46    public function getFloorX() : 
int{
 
   47        return (
int) floor($this->x);
 
   50    public function getFloorY() : 
int{
 
   51        return (
int) floor($this->y);
 
   54    public function add(
float $x, 
float $y) : 
Vector2{
 
   55        return new Vector2($this->x + $x, $this->y + $y);
 
   59        return $this->add($vector2->x, $vector2->y);
 
   62    public function subtract(
float $x, 
float $y) : 
Vector2{
 
   63        return $this->add(-$x, -$y);
 
   67        return $this->add(-$vector2->x, -$vector2->y);
 
   70    public function ceil() : 
Vector2{
 
   71        return new Vector2((
int) ceil($this->x), (
int) ceil($this->y));
 
   74    public function floor() : 
Vector2{
 
   75        return new Vector2((
int) floor($this->x), (
int) floor($this->y));
 
   78    public function round() : 
Vector2{
 
   79        return new Vector2(round($this->x), round($this->y));
 
   82    public function abs() : 
Vector2{
 
   83        return new Vector2(abs($this->x), abs($this->y));
 
   86    public function multiply(
float $number) : 
Vector2{
 
   87        return new Vector2($this->x * $number, $this->y * $number);
 
   90    public function divide(
float $number) : 
Vector2{
 
   91        return new Vector2($this->x / $number, $this->y / $number);
 
   94    public function distance(
Vector2 $pos) : 
float{
 
   95        return sqrt($this->distanceSquared($pos));
 
   98    public function distanceSquared(
Vector2 $pos) : 
float{
 
   99        return (($this->x - $pos->x) ** 2) + (($this->y - $pos->y) ** 2);
 
  102    public function length() : 
float{
 
  103        return sqrt($this->lengthSquared());
 
  106    public function lengthSquared() : 
float{
 
  107        return $this->x * $this->x + $this->y * $this->y;
 
  110    public function normalize() : 
Vector2{
 
  111        $len = $this->lengthSquared();
 
  113            return $this->divide(sqrt($len));
 
  119    public function dot(
Vector2 $v) : 
float{
 
  120        return $this->x * $v->x + $this->y * $v->y;
 
  123    public function __toString(){
 
  124        return "Vector2(x=" . $this->x . 
",y=" . $this->y . 
")";