imagine-node
Advanced tools
Comparing version 1.0.6 to 1.0.7
26
index.js
@@ -56,15 +56,19 @@ const { PI } = Math; | ||
} | ||
static getPolar(real, imaginary) { | ||
return new Complex(real, imaginary).getPolar(); | ||
static theta(real, imaginary) { | ||
return new Complex(real, imaginary).theta(); | ||
} | ||
getPolar() { | ||
theta() { | ||
const { real, imaginary } = this; | ||
const norm = Math.hypot(real, imaginary); | ||
const theta = Math.atan2(imaginary, real); | ||
return Math.atan2(imaginary, real); | ||
} | ||
return { theta, norm }; | ||
static polar(real, imaginary) { | ||
return new Complex(real, imaginary).polar(); | ||
} | ||
polar() { | ||
return { theta: this.theta(), norm: this.norm() }; | ||
} | ||
sub(other = 0, defaultImaginary) { | ||
@@ -217,3 +221,3 @@ const { | ||
const { r = 0, i = 0, real = r, imaginary = i } = this; | ||
let { norm, theta } = Complex.getPolar(real, imaginary); | ||
let { norm, theta } = Complex.polar(real, imaginary); | ||
theta = theta / n; | ||
@@ -232,3 +236,3 @@ if (!norm) return this; | ||
const { r = 0, i = 0, real = r, imaginary = i } = complex; | ||
let { norm, theta } = Complex.getPolar(real, imaginary); | ||
let { norm, theta } = Complex.polar(real, imaginary); | ||
theta = theta / n; | ||
@@ -373,3 +377,3 @@ if (!norm) return this; | ||
const { r = 0, i = 0, real = r, imaginary = i } = this; | ||
const { norm, theta } = Complex.getPolar(real, imaginary); | ||
const { norm, theta } = Complex.polar(real, imaginary); | ||
return new Complex( | ||
@@ -383,3 +387,3 @@ Math.log(norm), | ||
const { r = 0, i = 0, real = r, imaginary = i } = complex; | ||
const { norm, theta } = Complex.getPolar(real, imaginary); | ||
const { norm, theta } = Complex.polar(real, imaginary); | ||
return new Complex( | ||
@@ -386,0 +390,0 @@ Math.log(norm), |
{ | ||
"name": "imagine-node", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "node module to work with complex numbers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -97,3 +97,7 @@ # imagine-node | ||
## atang({real, imaginary}) -> imagineInstance | ||
## norm({real, imaginary}) -> number | ||
## polar({real, imaginary}) -> {norm, theta} | ||
## theta({real, imaginary}) -> number | ||
## sin({real, imaginary}) -> imagineInstance | ||
@@ -105,3 +109,3 @@ ## pow({real, imaginary}, {real, imaginary}) -> imagineInstance | ||
return a complex number with only imaginary part equal to number given | ||
## toString(number) -> string | ||
## toString({real, imaginary}) -> string | ||
@@ -121,2 +125,5 @@ ## re(number) -> imagineInstance | ||
## sin() -> imagineInstance | ||
## norm() -> number | ||
## polar() -> {norm, theta} | ||
## theta() -> number | ||
@@ -123,0 +130,0 @@ ## asin() -> imagineInstance |
17191
361
142