Class Complex
- java.lang.Object
-
- talonsoalbi_at_gmail_dot_com.ssoxmatch.ephem.moons.Complex
-
- All Implemented Interfaces:
java.io.Serializable
public class Complex extends java.lang.Object implements java.io.Serializable
A support class for complex numbers.- Author:
- talonso
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Complex(double r, double i)
Explicit constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Complex
add(Complex a)
Add operation.Complex
exponential()
Returns the exponential function of certain Complex.double
getImaginary()
Imaginary partdouble
getReal()
Real partComplex
multiply(double x)
Multiplies a complex by a scalar.java.lang.String
toString()
Converts a Complex into a String of the form ( a + bi).
-
-
-
Method Detail
-
getReal
public double getReal()
Real part- Returns:
- the real
-
getImaginary
public double getImaginary()
Imaginary part- Returns:
- the imaginary
-
add
public Complex add(Complex a)
Add operation.- Parameters:
a
- A complex number.- Returns:
- The sum of both.
-
multiply
public Complex multiply(double x)
Multiplies a complex by a scalar.- Parameters:
x
- A number.- Returns:
- this*x.
-
exponential
public Complex exponential()
Returns the exponential function of certain Complex.- Returns:
- Exp(this) as a new Complex.
-
toString
public java.lang.String toString()
Converts a Complex into a String of the form ( a + bi).
This enables the Complex to be easily printed. For example, if z was 2 - 5i, thenSystem.out.println("z = " + z);
would printz = (2 - 5i)
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String containing the cartesian coordinate representation
-
-