The OpenD Programming Language

fromPolar

Constructs a complex number given its absolute value and argument.

@safe pure nothrow @nogc
fromPolar
(
T
U
)
(
const T modulus
,
const U argument
)

Parameters

modulus T

The modulus

argument U

The argument

Return Value

Type: Complex!(CommonType!(T, U))

The complex number with the given modulus and argument.

Examples

import core.math;
import std.math.operations : isClose;
import std.math.algebraic : sqrt;
import std.math.constants : PI_4;
auto z = fromPolar(core.math.sqrt(2.0L), PI_4);
assert(isClose(z.re, 1.0L));
assert(isClose(z.im, 1.0L));

Meta