|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.monkeycoder.monkeyfractal.base.ComplexNumber
public class ComplexNumber
This class represents a Complex Number (a + bi) and provides basic math functions
for using them.
Originally part of the MonkeyFractal project.
| Field Summary | |
|---|---|
double |
i
The imaginary number part of this complex number. |
double |
r
The real number part of this complex number. |
| Constructor Summary | |
|---|---|
ComplexNumber()
Creates a new ComplexNumber initialized to (0 + 0i). |
|
ComplexNumber(double inR,
double inI)
Creates a new ComplexNumber initialized to (inR + inIi). |
|
| Method Summary | |
|---|---|
double |
actualDistFromOrigin()
Returns the actual distance from the origin of the Complex Plane. |
static double |
actualDistFromOrigin(ComplexNumber inComplex)
Returns the actual distance from the origin of the Complex Plane. |
void |
add(ComplexNumber inComplex)
Calculates the sum of this ComplexNumber and the supplied ComplexNumber. |
static ComplexNumber |
add(ComplexNumber inComplex1,
ComplexNumber inComplex2)
Calculates the sum of two ComplexNumbers. |
double |
distFromOrigin()
Returns the distance from the origin of the Complex Plane. |
static double |
distFromOrigin(ComplexNumber inComplex)
Returns the distance from the origin of the Complex Plane. |
void |
divide(ComplexNumber inComplex)
Divides this ComplexNumber by the supplied ComplexNumber. |
static ComplexNumber |
divide(ComplexNumber inComplex1,
ComplexNumber inComplex2)
Calculates the quotient of two ComplexNumbers. |
double |
getImaginary()
Returns the Imaginary part of this ComplexNumber. |
double |
getReal()
Returns the Real part of this ComplexNumber. |
boolean |
isZero()
Determines whether or not both the real and imaginary parts of this complex number are zero. |
void |
multiply(ComplexNumber inComplex)
Multiplies this ComplexNumber by the supplied ComplexNumber. |
static ComplexNumber |
multiply(ComplexNumber inComplex1,
ComplexNumber inComplex2)
Calculates the product of two ComplexNumbers. |
void |
set(ComplexNumber inComplex)
Sets the Real and Imaginary parts of this ComplexNumber to the real and imaginary parts of the passed in ComplexNumber. |
void |
set(double inR,
double inI)
Sets the Real and Imaginary parts of this ComplexNumber to (inR + inIi). |
void |
setImaginary(double inI)
Sets the Imaginary part of this ComplexNumber to the Imaginary part passed in. |
void |
setReal(double inR)
Sets the Real part of this ComplexNumber to the Real part passed in. |
void |
square()
Squares this ComplexNumber. |
static ComplexNumber |
square(ComplexNumber inComplex1)
Calculates the square of the ComplexNumber passed in. |
void |
subtract(ComplexNumber inComplex)
Subtracts the supplied ComplexNumber from this ComplexNumber. |
static ComplexNumber |
subtract(ComplexNumber inComplex1,
ComplexNumber inComplex2)
Calculates the difference of two ComplexNumbers. |
java.lang.String |
toString()
Returns this ComplexNumber as a String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public double r
public double i
| Constructor Detail |
|---|
public ComplexNumber()
public ComplexNumber(double inR,
double inI)
inR - The real number part this to which this ComplexNumber will be initialized.inI - The imaginary number part this to which this ComplexNumber will be initialized.| Method Detail |
|---|
public void set(double inR,
double inI)
inR - The real number part this to which this ComplexNumber will be set.inI - The imaginary number part this to which this ComplexNumber will be set.public void set(ComplexNumber inComplex)
inComplex - The ComplexNumber that will be used for values to set this ComplexNumber.public void setReal(double inR)
inR - The real number part this to which this ComplexNumber will be set.public void setImaginary(double inI)
inI - The imaginary number part this to which this ComplexNumber will be set.public double getReal()
public double getImaginary()
public double distFromOrigin()
public double actualDistFromOrigin()
public static double distFromOrigin(ComplexNumber inComplex)
inComplex - The ComplexNumber for which the distance from the origin will be calculated.
public static double actualDistFromOrigin(ComplexNumber inComplex)
inComplex - The ComplexNumber for which the distance from the origin will be calculated.
public boolean isZero()
public java.lang.String toString()
toString in class java.lang.Objectpublic void add(ComplexNumber inComplex)
inComplex - The ComplexNumber to be added to this one.public void subtract(ComplexNumber inComplex)
inComplex - The ComplexNumber to be subtracted from this one.public void multiply(ComplexNumber inComplex)
inComplex - The ComplexNumber to be multiplied by this one.public void divide(ComplexNumber inComplex)
inComplex - The ComplexNumber that will divide this one.public void square()
public static ComplexNumber add(ComplexNumber inComplex1,
ComplexNumber inComplex2)
inComplex1 - The first ComplexNumber to be added.inComplex2 - The second ComplexNumber to be added.
public static ComplexNumber subtract(ComplexNumber inComplex1,
ComplexNumber inComplex2)
inComplex1 - The ComplexNumber from which the second ComplexNumber will be subtracted.inComplex2 - The ComplexNumber that will be subtracted from the first ComplexNumber.
public static ComplexNumber multiply(ComplexNumber inComplex1,
ComplexNumber inComplex2)
inComplex1 - The first ComplexNumber to be multiplied.inComplex2 - The second ComplexNumber to be multiplied.
public static ComplexNumber divide(ComplexNumber inComplex1,
ComplexNumber inComplex2)
inComplex1 - The ComplexNumber that will be divided by the second ComplexNumber.inComplex2 - The ComplexNumber that will be divide the first ComplexNumber.
public static ComplexNumber square(ComplexNumber inComplex1)
inComplex1 - The ComplexNumber to square.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||