API Docs for: 1.0.0
Show:

ComplexNumber Class

Class for representing a complex number.

Constructor

ComplexNumber

(
  • real=0
  • imag=0
)

Parameters:

  • real=0 Number

    the real component

  • imag=0 Number

    the imaginary component

Methods

add

(
  • v
)
chainable

Equivalent of += operator.

Parameters:

conjugate

() chainable

Negates the imaginary part.

divide

(
  • v
)
chainable

Equivalent of /= operator.

Parameters:

fromPolar

(
  • magnitude
  • phase
)
static

Construct a ComplexNumber from polar coordinates.

Parameters:

Returns:

ComplexNumber

imag

() Number

Returns:

Number:

imaginary component

magnitude

() Number

Returns:

Number:

length of the vector in the complex plane

multiply

(
  • v
)
chainable

Equivalent of *= operator.

Parameters:

negate

() chainable

Equivalent of unary minus operator.

phase

() Number

Returns:

Number:

angle of the vector (in radians) in the complex plane relative to the positive real axis

real

() Number

Returns:

Number:

real component

rotate

(
  • angle
)
chainable

Rotates the number around the origin by the specified angle in radians.

Parameters:

roundTo

(
  • p
)
chainable

Parameters:

subtract

(
  • v
)
chainable

Equivalent of -= operator.

Parameters: