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

        list($realNumerator, $realDenominator) = self::getRealPartsFromRadiusAndCos($radius, $cos);
        list($imaginaryNumerator, $imaginaryDenominator) = self::getImaginaryPartsFromRadiusAndSin($radius, $sin);

        $realPart = RationalTypeFactory::create($realNumerator, $realDenominator);
        $imaginaryPart = RationalTypeFactory::create($imaginaryNumerator, $imaginaryDenominator);
        
        return new ComplexType($realPart, $imaginaryPart);
    }
public static function fromNativePolar(RationalType $radius, RationalType $theta)
    {
        $cos = RationalTypeFactory::fromFloat(cos($theta()));
        $sin = RationalTypeFactory::fromFloat(sin($theta()));

        list($realNumerator, $realDenominator) = self::getRealPartsFromRadiusAndCos($radius, $cos);
        list($imaginaryNumerator, $imaginaryDenominator) = self::getImaginaryPartsFromRadiusAndSin($radius, $sin);

        $realPart = RationalTypeFactory::create($realNumerator, $realDenominator);
        $imaginaryPart = RationalTypeFactory::create($imaginaryNumerator, $imaginaryDenominator);
        
        return new ComplexType($realPart, $imaginaryPart);
    }
public static function fromNativePolar ( RationalType $ radius , RationalType $ theta ) { $ cos = RationalTypeFactory :: fromFloat ( cos ( $ theta ( ) ) ) ; $ sin = RationalTypeFactory :: fromFloat ( sin ( $ theta ( ) ) ) ; list ( $ realNumerator , $ realDenominator ) = self :: getRealPartsFromRadiusAndCos ( $ radius , $ cos ) ; list ( $ imaginaryNumerator , $ imaginaryDenominator ) = self :: getImaginaryPartsFromRadiusAndSin ( $ radius , $ sin ) ; $ realPart = RationalTypeFactory :: create ( $ realNumerator , $ realDenominator ) ; $ imaginaryPart = RationalTypeFactory :: create ( $ imaginaryNumerator , $ imaginaryDenominator ) ; return new ComplexType ( $ realPart , $ imaginaryPart ) ; }
Create complex type from polar co-ordinates - Native version

z = radius x (cos(theta) + i.sin(theta))
real = radius x cos(theta)
imag = radius x sin(theta)

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

@return \Chippyash\Type\Number\Complex\ComplexType
Create complex type from polar co - ordinates - Native version