protected function thrust(Force $thrust, Time $time) { /** @var Acceleration $acceleration */ $acceleration = PhysicsProvider::forceMassAccelCalcs($thrust, $this->getMass()); $additionalVelocity = $acceleration->multiplyBy($time); $this->getVelocity()->add($additionalVelocity); /** @var Momentum $momentum */ $momentum = $this->getMass()->multiplyBy($this->getVelocity()); $this->setMomentum($momentum); return $this; }
public function testMomentum() { $unit = new UnitComposition(); $momentum = $unit->getUnitClass(UnitComposition::MOMENTUM); $mass = $unit->getUnitClass(UnitComposition::MASS); $velocity = $unit->getUnitClass(UnitComposition::VELOCITY); $momentum->preConvertedAdd(1); $mass->preConvertedAdd(1); $velocity->preConvertedAdd(1); $this->assertInstanceOf('Samsara\\Newton\\Units\\Mass', PhysicsProvider::momentumCalcs($momentum, $velocity)); $this->assertInstanceOf('Samsara\\Newton\\Units\\Momentum', PhysicsProvider::momentumCalcs($mass, $velocity)); $this->assertInstanceOf('Samsara\\Newton\\Units\\Velocity', PhysicsProvider::momentumCalcs($momentum, $mass)); }