Opus5
Class Complex

java.lang.Object
  |
  +--Opus5.Complex

public class Complex
extends java.lang.Object

A complex number.

Version:
$Id: Complex.java,v 3.2 1998/07/28 01:56:23 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Constructor Summary
Complex()
          Constructs a Complex with the the value zero.
Complex(double x)
          Constructs a Complex with the specified real part.
Complex(double x, double y)
          Constructs a Complex with the specified real and imaginary parts.
 
Method Summary
 void assign(Complex c)
          Assigns the value of the specified complex number to this complex number.
 double getImag()
          Returns the imaginary part of this complex number.
 double getR()
          Returns the magnitude of this complex number.
 double getReal()
          Returns the real part of this complex number.
 double getTheta()
          Returns the angle of this complex number.
 void setImag(double y)
          Sets the imaginary part of this complex number to the specified value.
 void setR(double r)
          Sets the magnitude of this complex number to the specified value.
 void setReal(double x)
          Sets the real part of this complex number to the specified value.
 void setTheta(double theta)
          Sets the angle of this complex number to the specified value.
 java.lang.String toString()
          Returns a string representation of this complex number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex(double x,
               double y)
Constructs a Complex with the specified real and imaginary parts.
Parameters:
x - The desired real value.
y - The desired imaginary value.

Complex

public Complex()
Constructs a Complex with the the value zero.

Complex

public Complex(double x)
Constructs a Complex with the specified real part.
Parameters:
x - The desired real value.
Method Detail

setReal

public void setReal(double x)
Sets the real part of this complex number to the specified value.
Parameters:
x - The desired real value.

setImag

public void setImag(double y)
Sets the imaginary part of this complex number to the specified value.
Parameters:
y - The desired imaginary value.

getReal

public double getReal()
Returns the real part of this complex number.
Returns:
The real part of this complex number.

getImag

public double getImag()
Returns the imaginary part of this complex number.
Returns:
The imaginary part of this complex number.

getR

public double getR()
Returns the magnitude of this complex number.
Returns:
The magnitude of this complex number.

getTheta

public double getTheta()
Returns the angle of this complex number.
Returns:
the angle of this complex number.

toString

public java.lang.String toString()
Returns a string representation of this complex number.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this complex number.

setR

public void setR(double r)
Sets the magnitude of this complex number to the specified value.
Parameters:
r - The desired magnitude.

setTheta

public void setTheta(double theta)
Sets the angle of this complex number to the specified value.
Parameters:
theta - The desired angle.

assign

public void assign(Complex c)
Assigns the value of the specified complex number to this complex number.
Parameters:
c - The desired complex value.