"""
The PolarPoint Class

>>> print("I am Polar!")
I am Polar!
"""
from math import sin, cos

class PolarPoint:
    """
    This class represents a 2D point in polar coordinates defined
    by its distance from the center of the reference system and
    an angle (in radians) from the positive x-axis.

    >>> print('Testing PolarPoint')
    Testing PolarPoint

    """
    def __init__(self, rho=0.0, theta=0.0):
        """
        specifies a polar point by a `rho` (`magnitude`), its
        distance from the origin, and `theta` (`argument`) its
        polar angle (in radians)

        >>> aPolarPoint = PolarPoint(1, 0)
        """
        self.rho = rho
        self.theta = theta

    def rect(self):
        """
        returns rectangular (Cartesian) coords of the PolarPoint
        as an (x, y) tuple
        """
        return (self.rho*cos(self.theta), self.rho*sin(self.theta))

    def asComplex(self):
        """
        returns the polar point as a complex number

        >>> PolarPoint(2, 0).asComplex()
        (2+0j)

        """
        (real, imag) = self.rect()
        return complex(real, imag)
