Пример #1
0
 /**
  * Returns a Complex given polar coordinates.
  *
  * @param float $modulus
  * @param float $argument
  *
  * @return Complex
  */
 public static function fromPolar(Real $modulus, Real $argument)
 {
     $realValue = $modulus->toNative() * \cos($argument->toNative());
     $imValue = $modulus->toNative() * \sin($argument->toNative());
     $real = new Real($realValue);
     $im = new Real($imValue);
     $complex = new self($real, $im);
     return $complex;
 }
Пример #2
0
 public function testToString()
 {
     $real = new Real(0.7);
     $this->assertEquals('.7', $real->__toString());
 }
Пример #3
0
 public function testGetArgument()
 {
     $arg = new Real(1.0010398733119);
     $this->assertTrue($arg->sameValueAs($this->complex->getArgument()));
 }
Пример #4
0
 /**
  * Returns the value of the integer number.
  *
  * @return int
  */
 public function toNative()
 {
     $value = parent::toNative();
     return \intval($value);
 }