edu.jas.root
Class Rectangle<C extends RingElem<C> & Rational>

java.lang.Object
  extended by edu.jas.root.Rectangle<C>
Type Parameters:
C - coefficient type.

public class Rectangle<C extends RingElem<C> & Rational>
extends java.lang.Object

Rectangle. For example isolating rectangle for complex roots.

Author:
Heinz Kredel

Field Summary
 Complex<C>[] corners
          rectangle corners.
 
Constructor Summary
Rectangle(Complex<C> mid)
          Constructor.
Rectangle(Complex<C>[] c)
          Constructor.
Rectangle(Complex<C> sw, Complex<C> ne)
          Constructor.
Rectangle(Complex<C> nw, Complex<C> sw, Complex<C> se, Complex<C> ne)
          Constructor.
 
Method Summary
 java.lang.String centerApprox()
          Approximation of center.
 Rectangle<C> clone()
          Clone this.
 boolean contains(Complex<C> c)
          Contains a point.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 Rectangle<C> exchangeNE(Complex<C> c)
          Exchange NE corner.
 Rectangle<C> exchangeNW(Complex<C> c)
          Exchange NW corner.
 Rectangle<C> exchangeSE(Complex<C> c)
          Exchange SE corner.
 Rectangle<C> exchangeSW(Complex<C> c)
          Exchange SW corner.
 Complex<C> getCenter()
          Complex center.
 Complex<BigDecimal> getDecimalCenter()
          Complex of BigDecimal approximation of center.
 Complex<C> getNE()
          Get north east corner.
 Complex<C> getNW()
          Get north west corner.
 Complex<BigRational> getRationalCenter()
          Complex of BigRational approximation of center.
 Complex<C> getSE()
          Get south east corner.
 Complex<C> getSW()
          Get south west corner.
 int hashCode()
          Hash code for this Rectangle.
 C length()
          Length.
 Complex<C> randomPoint()
          Random point of recatangle.
 BigRational rationalLength()
          Rational Length.
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toString()
          String representation of Rectangle.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

corners

public final Complex<C extends RingElem<C> & Rational>[] corners
rectangle corners.

Constructor Detail

Rectangle

public Rectangle(Complex<C>[] c)
Constructor.

Parameters:
c - array of corners.

Rectangle

public Rectangle(Complex<C> mid)
Constructor.

Parameters:
mid - corner.

Rectangle

public Rectangle(Complex<C> sw,
                 Complex<C> ne)
Constructor.

Parameters:
sw - corner.
ne - corner.

Rectangle

public Rectangle(Complex<C> nw,
                 Complex<C> sw,
                 Complex<C> se,
                 Complex<C> ne)
Constructor.

Parameters:
nw - corner.
sw - corner.
se - corner.
ne - corner.
Method Detail

toString

public java.lang.String toString()
String representation of Rectangle.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

toScript

public java.lang.String toScript()
Get a scripting compatible string representation.

Returns:
script compatible representation for this Rectangle.

getNW

public Complex<C> getNW()
Get north west corner.

Returns:
north west corner of this rectangle.

getSW

public Complex<C> getSW()
Get south west corner.

Returns:
south west corner of this rectangle.

getSE

public Complex<C> getSE()
Get south east corner.

Returns:
south east corner of this rectangle.

getNE

public Complex<C> getNE()
Get north east corner.

Returns:
north east corner of this rectangle.

exchangeNW

public Rectangle<C> exchangeNW(Complex<C> c)
Exchange NW corner.

Parameters:
c - new NW corner.
Returns:
rectangle with north west corner c of this rectangle.

exchangeSW

public Rectangle<C> exchangeSW(Complex<C> c)
Exchange SW corner.

Parameters:
c - new SW corner.
Returns:
rectangle with south west corner c of this rectangle.

exchangeSE

public Rectangle<C> exchangeSE(Complex<C> c)
Exchange SE corner.

Parameters:
c - new SE corner.
Returns:
rectangle with south east corner c of this rectangle.

exchangeNE

public Rectangle<C> exchangeNE(Complex<C> c)
Exchange NE corner.

Parameters:
c - new NE corner.
Returns:
rectangle with north east corner c of this rectangle.

contains

public boolean contains(Complex<C> c)
Contains a point.

Parameters:
c - point.
Returns:
true if c is contained in this rectangle, else false.

randomPoint

public Complex<C> randomPoint()
Random point of recatangle.

Returns:
a random point contained in this rectangle.

clone

public Rectangle<C> clone()
Clone this.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

equals

public boolean equals(java.lang.Object b)
Comparison with any other object.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash code for this Rectangle.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

getCenter

public Complex<C> getCenter()
Complex center.

Returns:
r + i m of the center.

getRationalCenter

public Complex<BigRational> getRationalCenter()
Complex of BigRational approximation of center.

Returns:
r + i m as rational approximation of the center.

getDecimalCenter

public Complex<BigDecimal> getDecimalCenter()
Complex of BigDecimal approximation of center.

Returns:
r + i m as decimal approximation of the center.

centerApprox

public java.lang.String centerApprox()
Approximation of center.

Returns:
r + i m as string of decimal approximation of the center.

length

public C length()
Length.

Returns:
|ne-sw|**2;

rationalLength

public BigRational rationalLength()
Rational Length.

Returns:
rational(|ne-sw|**2);