Class AlgorithmCircularSectorToRectangle

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmCircularSectorToRectangle
    extends AlgorithmBase
    This software uses 2D conformal mapping in converting a circular sector defined by 4 user points at the sector corners to a rectangle of user specified size. The circular sector has an inner radius rmin, an outer radius rmax, and extends over an angle theta = alpha * PI radians, with 0 < alpha <= 1. In a conformal mapping in any small neighborhood the relative angle and shape are preserved. The points z1, z2, z3, and z4 are entered in a counterclockwise order with z1 and z2 on rmax and z3 and z4 on rmin. For the case of rmax pointing to the top of the image, z1 is the upper right point on rmax, z2 is the upper left point on rmax, z3 is the lower left point on rmin, and z4 is the lower right point on rmin. The mapping to the user specified rectangle is performed in 3 steps. First, all distances from the circular center are divided by sqrt(rmax * rmin). Second, a conformal mapping to a rectangle of width 1 and height log(rmax/rmin)/theta occurs. Then, this rectangle is linearly scaled to a rectangle of user specified xDim and yDim. Note that the linear scaling of one rectangle to another is not a conformal mapping unless the width and height are scaled by the same factor. From "Lectures on Quasiconformal Mappings" second edition by Lars V. Ahlfors: "If Q is a square and R is a rectangle, not a square, there is no conformal mapping of Q on R which maps vertices on vertices."

    Let z4z1 be on the real axis, let the straight line z2z3 be inclined at an angle alpha*PI, 0 < alpha <= 1, z3 and z4 are both on the radius rmin, and z1 and z2 are both on the radius rmax. For the conformal mapping we require that rmax > 1 and 0 < rmin < 1. So divide all the distances by sqrt(rmax * rmin). Then the radii go from sqrt(rmin/rmax) to sqrt(rmax/rmin).

    To go from a circular sector to a rectangle use the transformation w = f(z) = u + iv = log(z)/(i*alpha*PI) Let z = r*exp(i*theta) Then, w = log(r*exp(i*theta))/(i*alpha*PI) = theta/(alpha*PI) - i*log(r)/(alpha*PI) so u = theta/(alpha*PI), v = -log(r)/(alpha*PI)

    For conformal mapping we require that f(z) be analytic - the Cauchy-Riemann equations must be satisfied and f'(z) must not equal zero. The Cauchy-Riemann equations in polar form are: du/dr = (1/r)(dv/dtheta); (1/r)du/dtheta = -dv/dr The first equation gives zero on both sides and the second equation gives (alpha*PI)/r on both sides, so the Cauchy Riemann equations hold. f'(z) = 1/(i*alpha*PI*z) does not equal zero.

    In the first mapping: rmin -> sqrt(rmin/rmax) -> log(sqrt(rmin/rmax))/(i*alpha*PI) = i*log(sqrt(rmax/rmin))/(alpha*PI) rmin*exp(i*alpha*PI) -> sqrt(rmin/rmax)*exp(i*alpha*PI) -> 1 + i*log(sqrt(rmax/rmin))/(alpha*PI) rmax -> sqrt(rmax/rmin) -> log(sqrt(rmax/rmin))/(i*alpha*PI) = -i*log(sqrt(rmax/rmin))/(alpha*PI) rmax*exp(i*alpha*PI) -> sqrt(rmax/rmin)*exp(i*alpha*PI) -> 1 - i*log(sqrt(rmax/rmin))/(alpha*PI)

    Now do a simple linear transformation where both the x axis is inverted and both axes are scaled to obtain: z1" = xDim-1, 0 z2" = 0, 0 z3" = 0, yDim-1 z4" = xDim - 1, yDim-1

    x" = (1 - x')*(xDim - 1) Let var = log(sqrt(rmax/rmin))/(alpha*PI) y" = (y' + var)* (yDim - 1)/(2 * var)

    A similar transformation is performed in Conformal Mapping by Zeev Nehari Chapter VI Mapping Properties of Special Functions 2. Exponential and Trigonometric Functios pp. 273-280. Nehari states that "the transformation w = exp(z) maps the boundary of any rectangle in the z-plane whose sides are parallel to the axes onto a closed contour consisting of two circular arcs about the origin and two linear segments pointing at the origin."

    References: 1.) Advanced Calculus For Applications Second Edition by F. B. Hildebrand, Section 10.4 Analytic Functions of a Complex Variable pages 550-554 and Section 11.4 Conformal Mapping pages 628-632, Prentice-Hall, Inc., 1976. 2.) "A Domain Decomposition Method for Conformal Mapping onto a Rectangle", N. Papamichael and N. S. Stylianopoulos, Constructive Approximation, Vol. 7, 1991, pp. 349-379. Relevant result is given in Remark 4.7 on pages 374-375.

    3.) Conformal Mapping by Zeev Nehari Chapter VI Mapping Properties of Special Functions 2. Exponential and Trigonometric Functions pp. 273-280.
    • Constructor Detail

      • AlgorithmCircularSectorToRectangle

        public AlgorithmCircularSectorToRectangle()
        AlgorithmCircularSectorToRectangle - default constructor.
      • AlgorithmCircularSectorToRectangle

        public AlgorithmCircularSectorToRectangle​(ModelImage destImg,
                                                  ModelImage srcImg,
                                                  double[] x,
                                                  double[] y)
        AlgorithmCircularSectorToRectangle.
        Parameters:
        destImg - DOCUMENT ME!
        srcImg - DOCUMENT ME!
        x - array with x coordinates of 4 sector boundary points
        y - array with y coordinates of 4 sector boundary points
    • Method Detail

      • selfTest

        private void selfTest()
      • selfTest2

        private void selfTest2()
      • selfTest3

        private void selfTest3()