Esempio n. 1
0
 /**
  * Adds another cartesian vector to this instance
  *
  * @param static $b
  */
 public function add(Cartesian $b)
 {
     $this->x->add($b->x);
     $this->y->add($b->y);
     $this->z->add($b->z);
     if ($this->vx) {
         $this->vx->add($b->vx);
         $this->vy->add($b->vy);
         $this->vz->add($b->vz);
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Adds another velocity to this instance and returns a new instance with
  * the sum.
  *
  * @param Velocity $b Velocity to add
  *
  * @return static Sum of the two velocity instances
  */
 public function add(Velocity $b)
 {
     $dist = $this->dist->add($b->dist);
     $velocity = new Velocity($dist, $this->time);
     $velocity->format = $this->format;
     return $velocity;
 }