Complex.fromPolar constructor

Complex.fromPolar(
  1. double r,
  2. double theta, {
  3. bool angleInRadians = true,
})

Creates a complex number from the given polar coordinates where r is the radius and theta is the angle.

By default the angle theta must be expressed in radians but setting angleInRadians = false allows the value to be in degrees.

Implementation

Complex.fromPolar(double r, double theta, {bool angleInRadians = true})
    : real = r * math.cos(angleInRadians ? theta : degToRad(theta)),
      imaginary = r * math.sin(angleInRadians ? theta : degToRad(theta));