NUMBERS-28: Added cis() method to Complex
diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index 4e9022e..c7c7b0b 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -95,6 +95,17 @@
}
/**
+ * For a real constructor argument x, returns a new Complex object c
+ * where {@code c = cos(x) + i sin (x)}
+ *
+ * @param x {@code double} to build the cis number
+ * @return {@code Complex}
+ */
+ public Complex cis(double x) {
+ return new Complex(Math.cos(x), Math.sin(x));
+ }
+
+ /**
* Return the absolute value of this complex number.
* Returns {@code NaN} if either real or imaginary part is {@code NaN}
* and {@code Double.POSITIVE_INFINITY} if neither part is {@code NaN},