treebolic.core
Class Complex

java.lang.Object
  extended by treebolic.core.Complex
Direct Known Subclasses:
HyperRotation, HyperTranslation

public class Complex
extends java.lang.Object

Complex

Author:
Bernard Bou

Field Summary
static Complex EAST
          East orientation
 double im
          Imaginary part
static Complex NORTH
          North orientation
static Complex ONE
          One
 double re
          Real part
static Complex SOUTH
          South orientation
static Complex WEST
          West orientation
static Complex ZERO
          Zero
 
Constructor Summary
Complex()
          Default constructor which defaults to (0,0)
Complex(Complex z)
          Copy constructor
Complex(double x)
          Construct complex from real part, imaginary part defaulting to 0
Complex(double x, double y)
          Construct complex from real and imaginary parts
 
Method Summary
 double abs2()
          Squared magnitude
 Complex add(Complex z)
          Add complex z to this complex
 Complex add(Complex z1, Complex z2)
          Set this complex to z1+z2
 double arg()
          Argument
 Complex conj()
          Conjugate of this complex
 Complex conj(Complex z)
          Conjugate of z
 Complex div(Complex z)
          Division of this complex by z
 Complex div(Complex z1, Complex z2)
          Division
 Complex divide(Complex z, double d)
          Divide complex by double
 Complex divide(double d)
          Divide this complex by double
 boolean equals(Complex z)
          Complex equality
 double mag()
          Magnitude
static Complex makeFromArg(double thisArg)
          Construct complex of magnitude 1 from argument re = cos(arg) im = sin(arg)
static Complex makeFromArgAbs(double thisArg, double thisMag)
          Construct complex from argument and mag re = cos(arg) im = sin(arg)
 Complex mul(Complex z)
          Multiplication of this complex by z
 Complex mul(Complex a, Complex b)
          Multiplication
 Complex multiply(Complex z, double m)
          Multiply complex by double
 Complex multiply(double m)
          Multiply this complex by double
 Complex neg()
          Negation of this complex
 Complex neg(Complex z)
          Negation of complex z
 Complex normalize()
          Map to magnitude one complex
 Complex onediv()
          Inverse of this complex
 Complex set(Complex z)
          Set complex to value of another complex, no new complex object is created
 Complex set(double x, double y)
          Set complex to values of real and imaginary parts no new complex object is created
 Complex sub(Complex z)
          Substract complex z from this complex
 Complex sub(Complex z1, Complex z2)
          Set this complex to z1-z2
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Complex ZERO
Zero


ONE

public static final Complex ONE
One


NORTH

public static final Complex NORTH
North orientation


SOUTH

public static final Complex SOUTH
South orientation


EAST

public static final Complex EAST
East orientation


WEST

public static final Complex WEST
West orientation


re

public double re
Real part


im

public double im
Imaginary part

Constructor Detail

Complex

public Complex()
Default constructor which defaults to (0,0)


Complex

public Complex(double x,
               double y)
Construct complex from real and imaginary parts

Parameters:
x - real part
y - imaginary part

Complex

public Complex(Complex z)
Copy constructor

Parameters:
z - copied complex

Complex

public Complex(double x)
Construct complex from real part, imaginary part defaulting to 0

Parameters:
x - real part
Method Detail

makeFromArgAbs

public static Complex makeFromArgAbs(double thisArg,
                                     double thisMag)
Construct complex from argument and mag re = cos(arg) im = sin(arg)

Parameters:
thisArg - argument a
thisMag - magnitude m
Returns:
new complex of this argument a and magnitude m

makeFromArg

public static Complex makeFromArg(double thisArg)
Construct complex of magnitude 1 from argument re = cos(arg) im = sin(arg)

Parameters:
thisArg - argument a
Returns:
new complex of magnitude 1 and argument a

set

public Complex set(Complex z)
Set complex to value of another complex, no new complex object is created

Parameters:
z - complex
Returns:
original complex object, whose value has been set to z

set

public Complex set(double x,
                   double y)
Set complex to values of real and imaginary parts no new complex object is created

Parameters:
x - real part
y - imaginary part
Returns:
original complex object, whose value has been set to x,z

equals

public boolean equals(Complex z)
Complex equality

Parameters:
z - complex
Returns:
true if this complex z0 is equal to complex z

add

public Complex add(Complex z)
Add complex z to this complex

Parameters:
z - complex to be added to this complex
Returns:
this complex, whose value has been set to z0+z

add

public Complex add(Complex z1,
                   Complex z2)
Set this complex to z1+z2

Parameters:
z1 - complex
z2 - complex
Returns:
this complex, whose value has been set to z1+z2 and whose original value is not used

sub

public Complex sub(Complex z)
Substract complex z from this complex

Parameters:
z - complex
Returns:
this complex, whose value has been set to z0-z

sub

public Complex sub(Complex z1,
                   Complex z2)
Set this complex to z1-z2

Parameters:
z1 - complex
z2 - complex
Returns:
this complex whose value has been set to z1-z2 and whose original value is not used

conj

public Complex conj()
Conjugate of this complex

Returns:
this complex, whose value has been to the conjugate of this complex

conj

public Complex conj(Complex z)
Conjugate of z

Parameters:
z - complex
Returns:
this complex, whose value has been set to conjugate of z and whose original value is not used

neg

public Complex neg()
Negation of this complex

Returns:
this complex, whose value has been set to the negation of this complex

neg

public Complex neg(Complex z)
Negation of complex z

Parameters:
z - complex
Returns:
this complex, whose value has been set to the negation of z and whose original value is not used

div

public Complex div(Complex z)
Division of this complex by z

Parameters:
z - complex
Returns:
this complex, whose value has been set to the division of this complex by complex z (=z0/z)

div

public Complex div(Complex z1,
                   Complex z2)
Division

Parameters:
z1 - complex
z2 - complex
Returns:
this complex, whose value has been set to the division of z1 by z2 (=z1/z2) and whose original value is not used

onediv

public Complex onediv()
Inverse of this complex

Returns:
this complex, as the result of inverting its original value (=1/z0)

mul

public Complex mul(Complex z)
Multiplication of this complex by z

Parameters:
z -
Returns:
this complex, whose value has been multiplied by z (=z0.z)

mul

public Complex mul(Complex a,
                   Complex b)
Multiplication

Parameters:
a - complex
b - complex
Returns:
this complex as the result of a.b and whose original value not used

multiply

public Complex multiply(Complex z,
                        double m)
Multiply complex by double

Parameters:
z - complex
m - multiplicator
Returns:
this complex, as the result of multiplying z by m

multiply

public Complex multiply(double m)
Multiply this complex by double

Parameters:
m - multiplicator
Returns:
this complex, multiplied by m

divide

public Complex divide(Complex z,
                      double d)
Divide complex by double

Parameters:
z - complex
d - divisor
Returns:
this complex, as the result of dividying z by d

divide

public Complex divide(double d)
Divide this complex by double

Parameters:
d - divisor
Returns:
this complex, divided by d

arg

public double arg()
Argument

Returns:
argument of complex

mag

public double mag()
Magnitude

Returns:
magnitude

abs2

public double abs2()
Squared magnitude

Returns:
squared magnitude

normalize

public Complex normalize()
Map to magnitude one complex

Returns:
magnitude 1 complex with same argument

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object