Package edu.jas.root

Class Rectangle<C extends RingElem<C> & Rational>

  • Type Parameters:
    C - coefficient type.
    All Implemented Interfaces:
    java.io.Serializable

    public class Rectangle<C extends RingElem<C> & Rational>
    extends java.lang.Object
    implements java.io.Serializable
    Rectangle. For example isolating rectangle for complex roots.
    See Also:
    Serialized Form
    • Constructor Detail

      • Rectangle

        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.
          nw|0 ne|3
          sw|1 se|2
         
        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.
      • contains

        public boolean contains​(Rectangle<C> r)
        Contains a rectangle.
        Parameters:
        r - rectangle.
        Returns:
        true if r is contained in this rectangle, else false.
      • randomPoint

        public Complex<C> randomPoint()
        Random point of recatangle.
        Returns:
        a random point contained in this rectangle.
      • copy

        public Rectangle<C> copy()
        Copy this.
        Returns:
        a copy of this.
      • 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);
      • lengthReal

        public C lengthReal()
        Length real side.
        Returns:
        |re(ne)-re(sw)|;
      • lengthImag

        public C lengthImag()
        Length imaginary side.
        Returns:
        |im(ne)-im(sw)|;