Blame | Last modification | View Log | RSS feed
<?php
class Vector {
public $x;
public $y;
public $include;
public function __construct($x,$y) {
$this->x = $x;
$this->y = $y;
}
public function DotProduct(Vector $v) {
$dot = ($this->x * $v->x + $this->y * $v->y);
return $dot;
}
public function Magnitude() {
return sqrt($this->x*$this->x + $this->y*$this->y);
}
public function UnitVector() {
if ($this->Magnitude() == 0) return new Vector(0,0);
return new Vector($this->x / $this->Magnitude(), $this->y / $this->Magnitude());
}
}
?>