complex: utilities for handling complex numbers
Code author: Peter Kraus
Provides convenience functions for converting complex numbers between rectangular and polar forms.
Functions
|
Convert the provided complex number in polar form \((r, θ)\) to rectangular (or Cartesian) form \((x, y)\). |
|
Convert the provided complex number in rectangular form \((x, y)\) to polar form \((r, θ)\). |
- dgpost.transform.complex.to_rectangular(mag: Quantity, arg: Quantity, output: str = None) Quantity
Convert the provided complex number in polar form \((r, θ)\) to rectangular (or Cartesian) form \((x, y)\).
- Parameters:
mag – The magnitude \(r\).
arg – The argument (or angle) \(θ\). By default in radians.
output – Name of the output namespace. Defaults to
None
, which meansx
andy
will be returned.
- Returns:
dict(output, x) (dict[str, pint.Quantity]) – Returns the Cartesian x-coordinate.
dict(output, y) (dict[str, pint.Quantity]) – Returns the Cartesian y-coordinate.
- dgpost.transform.complex.to_polar(x: Quantity, y: Quantity, output: str = None) Quantity
Convert the provided complex number in rectangular form \((x, y)\) to polar form \((r, θ)\).
Returns
- Parameters:
x – The Cartesian x-coordinate of the complex number.
y – The Cartesian y-coordinate of the complex number.
output – Name of the output namespace. Defaults to
None
, which meansmag
andarg
will be returned.
- Returns:
dict(output, mag) (dict[str, pint.Quantity]) – Returns the magnitude (r) of the complex number.
dict(output, arg) (dict[str, pint.Quantity]) – Returns the argument (θ) of the complex number, in radians.