src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php
public static function fromGmpPolar(GMPRationalType $radius, GMPRationalType $theta)
    {
        $cos = RationalTypeFactory::fromFloat(cos($theta()));
        $sin = RationalTypeFactory::fromFloat(sin($theta()));

        //real = radius * cos
        $rNum = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->numerator()->gmp(),
                    $cos->numerator()->gmp()
                )
            )
        );
        $rDen = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->denominator()->gmp(),
                    $cos->denominator()->gmp()
                )
            )
        );
        //imag = radius * sin
        $iNum = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->numerator()->gmp(),
                    $sin->numerator()->gmp()
                )
            )
        );
        $iDen = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->denominator()->gmp(),
                    $sin->denominator()->gmp()
                )
            )
        );

        return new GMPComplexType(
            RationalTypeFactory::create($rNum, $rDen),
            RationalTypeFactory::create($iNum, $iDen)
        );
    }
public static function fromGmpPolar(GMPRationalType $radius, GMPRationalType $theta)
    {
        $cos = RationalTypeFactory::fromFloat(cos($theta()));
        $sin = RationalTypeFactory::fromFloat(sin($theta()));

        //real = radius * cos
        $rNum = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->numerator()->gmp(),
                    $cos->numerator()->gmp()
                )
            )
        );
        $rDen = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->denominator()->gmp(),
                    $cos->denominator()->gmp()
                )
            )
        );
        //imag = radius * sin
        $iNum = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->numerator()->gmp(),
                    $sin->numerator()->gmp()
                )
            )
        );
        $iDen = TypeFactory::create(
            'int',
            gmp_strval(
                gmp_mul(
                    $radius->denominator()->gmp(),
                    $sin->denominator()->gmp()
                )
            )
        );

        return new GMPComplexType(
            RationalTypeFactory::create($rNum, $rDen),
            RationalTypeFactory::create($iNum, $iDen)
        );
    }
public static function fromGmpPolar ( GMPRationalType $ radius , GMPRationalType $ theta ) { $ cos = RationalTypeFactory :: fromFloat ( cos ( $ theta ( ) ) ) ; $ sin = RationalTypeFactory :: fromFloat ( sin ( $ theta ( ) ) ) ; //real = radius * cos $ rNum = TypeFactory :: create ( 'int' , gmp_strval ( gmp_mul ( $ radius -> numerator ( ) -> gmp ( ) , $ cos -> numerator ( ) -> gmp ( ) ) ) ) ; $ rDen = TypeFactory :: create ( 'int' , gmp_strval ( gmp_mul ( $ radius -> denominator ( ) -> gmp ( ) , $ cos -> denominator ( ) -> gmp ( ) ) ) ) ; //imag = radius * sin $ iNum = TypeFactory :: create ( 'int' , gmp_strval ( gmp_mul ( $ radius -> numerator ( ) -> gmp ( ) , $ sin -> numerator ( ) -> gmp ( ) ) ) ) ; $ iDen = TypeFactory :: create ( 'int' , gmp_strval ( gmp_mul ( $ radius -> denominator ( ) -> gmp ( ) , $ sin -> denominator ( ) -> gmp ( ) ) ) ) ; return new GMPComplexType ( RationalTypeFactory :: create ( $ rNum , $ rDen ) , RationalTypeFactory :: create ( $ iNum , $ iDen ) ) ; }
Create complex type from polar co-ordinates - GMP version

@param \Chippyash\Type\Number\Rational\GMPRationalType $radius
@param \Chippyash\Type\Number\Rational\GMPRationalType $theta angle expressed in radians

@return \Chippyash\Type\Number\Complex\GMPComplexType

@codeCoverageIgnore
Create complex type from polar co - ordinates - GMP version