# Complex.js

Defines the Complex class.

#### Description

The Complex class, just like the Polar class, is used by the Hypertree, ST and RGraph as a 2D point representation.

http://en.wikipedia.org/wiki/Complex_number

Summary
 Complex.js Defines the Complex class. Complex A multi-purpose Complex Class with common methods. Functions getc Returns a complex number. getp Returns a Polar representation of this number. set Sets a number. setc Sets a complex number. setp Sets a polar number. clone Returns a copy of the current object. toPolar Transforms cartesian to polar coordinates. norm Calculates a Complex number norm. squaredNorm Calculates a Complex number squared norm. add Returns the result of adding two complex numbers. prod Returns the result of multiplying two Complex numbers. conjugate Returns the conjugate of this Complex number. scale Returns the result of scaling a Complex instance. equals Comparison method. \$add Returns the result of adding two Complex numbers. \$prod Returns the result of multiplying two Complex numbers. \$conjugate Returns the conjugate for this Complex. \$scale Returns the result of scaling a Complex instance. \$div Returns the division of two Complex numbers. isZero Returns true if the number is zero.

## Complex

A multi-purpose Complex Class with common methods.

#### Description

The Complex class, just like the Polar class, is used by the Hypertree, ST and RGraph as a 2D point representation.

http://en.wikipedia.org/wiki/Complex_number

#### Parameters

 x optional A Complex number real part. y optional A Complex number imaginary part.
Summary
 Functions getc Returns a complex number. getp Returns a Polar representation of this number. set Sets a number. setc Sets a complex number. setp Sets a polar number. clone Returns a copy of the current object. toPolar Transforms cartesian to polar coordinates. norm Calculates a Complex number norm. squaredNorm Calculates a Complex number squared norm. add Returns the result of adding two complex numbers. prod Returns the result of multiplying two Complex numbers. conjugate Returns the conjugate of this Complex number. scale Returns the result of scaling a Complex instance. equals Comparison method. \$add Returns the result of adding two Complex numbers. \$prod Returns the result of multiplying two Complex numbers. \$conjugate Returns the conjugate for this Complex. \$scale Returns the result of scaling a Complex instance. \$div Returns the division of two Complex numbers. isZero Returns true if the number is zero.

### getc

 getc: function()

Returns a complex number.

#### Returns

A complex number.

### getp

 getp: function( simple )

Returns a Polar representation of this number.

#### Parameters

 simple optional If true, this method will return only an object holding theta and rho properties and not a Polar instance.  Default’s false.

#### Returns

A variable in Polar coordinates.

### set

 set: function( c )

Sets a number.

#### Parameters

 c A Complex or Polar instance.

### setc

 setc: function( x, y )

Sets a complex number.

#### Parameters

 x A Complex number Real part. y A Complex number Imaginary part.

### setp

 setp: function( theta, rho )

Sets a polar number.

#### Parameters

 theta A Polar number theta property. rho A Polar number rho property.

### clone

 clone: function()

Returns a copy of the current object.

#### Returns

A copy of the real object.

### toPolar

 toPolar: function( simple )

Transforms cartesian to polar coordinates.

#### Parameters

 simple optional If true this method will only return an object with theta and rho properties (and not the whole Polar instance).  Default’s false.

#### Returns

A new Polar instance.

### norm

 norm: function ()

Calculates a Complex number norm.

#### Returns

A real number representing the complex norm.

### squaredNorm

 squaredNorm: function ()

Calculates a Complex number squared norm.

#### Returns

A real number representing the complex squared norm.

Returns the result of adding two complex numbers.

Does not alter the original object.

#### Parameters

 pos A Complex instance.

#### Returns

The result of adding two complex numbers.

### prod

 prod: function( pos )

Returns the result of multiplying two Complex numbers.

Does not alter the original object.

#### Parameters

 pos A Complex instance.

#### Returns

The result of multiplying two complex numbers.

### conjugate

 conjugate: function()

Returns the conjugate of this Complex number.

Does not alter the original object.

#### Returns

The conjugate of this Complex number.

### scale

 scale: function( factor )

Returns the result of scaling a Complex instance.

Does not alter the original object.

#### Parameters

 factor A scale factor.

#### Returns

The result of scaling this complex to a factor.

### equals

 equals: function( c )

Comparison method.

Returns true if both real and imaginary parts are equal.

#### Parameters

 c A Complex instance.

#### Returns

A boolean instance indicating if both Complex numbers are equal.

Returns the result of adding two Complex numbers.

Alters the original object.

#### Parameters

 pos A Complex instance.

#### Returns

The result of adding two complex numbers.

### \$prod

 \$prod:function( pos )

Returns the result of multiplying two Complex numbers.

Alters the original object.

#### Parameters

 pos A Complex instance.

#### Returns

The result of multiplying two complex numbers.

### \$conjugate

 \$conjugate: function()

Returns the conjugate for this Complex.

Alters the original object.

#### Returns

The conjugate for this complex.

### \$scale

 \$scale: function( factor )

Returns the result of scaling a Complex instance.

Alters the original object.

#### Parameters

 factor A scale factor.

#### Returns

The result of scaling this complex to a factor.

### \$div

 \$div: function( pos )

Returns the division of two Complex numbers.

Alters the original object.

#### Parameters

 pos A Complex number.

#### Returns

The result of scaling this complex to a factor.

### isZero

 isZero: function ()

Returns true if the number is zero.

A multi-purpose Complex Class with common methods.
 getc: function()
Returns a complex number.
 getp: function( simple )
Returns a Polar representation of this number.
A multi purpose polar representation.
 set: function( c )
Sets a number.
 setc: function( x, y )
Sets a complex number.
 setp: function( theta, rho )
Sets a polar number.
 clone: function()
Returns a copy of the current object.
 toPolar: function( simple )
Transforms cartesian to polar coordinates.
 norm: function ()
Calculates a Complex number norm.
 squaredNorm: function ()
Calculates a Complex number squared norm.
Returns the result of adding two complex numbers.
 prod: function( pos )
Returns the result of multiplying two Complex numbers.
 conjugate: function()
Returns the conjugate of this Complex number.
 scale: function( factor )
Returns the result of scaling a Complex instance.
 equals: function( c )
Comparison method.
Returns the result of adding two Complex numbers.
 \$prod:function( pos )
Returns the result of multiplying two Complex numbers.
 \$conjugate: function()
Returns the conjugate for this Complex.
 \$scale: function( factor )
Returns the result of scaling a Complex instance.
 \$div: function( pos )
Returns the division of two Complex numbers.
 isZero: function ()
Returns true if the number is zero.
A Hyperbolic Tree/Graph visualization.
A Tree layout with advanced contraction and expansion animations.