Difference between revisions of "Transform: Conformal Mapping Algorithms"
m (→Circular Sector to Rectangle) |
m (→Circular Sector to Rectangle) |
||
Line 10: | Line 10: | ||
Let, <math>z_1</math> and <math>z_2</math> belong to <math>r_{max}</math>, and <math>z_3</math> and <math>z_4</math> belong to <math>r_{min}</math>. The mapping to the user specified rectangle is performed in the following steps (1-6): | Let, <math>z_1</math> and <math>z_2</math> belong to <math>r_{max}</math>, and <math>z_3</math> and <math>z_4</math> belong to <math>r_{min}</math>. The mapping to the user specified rectangle is performed in the following steps (1-6): | ||
− | The maximum radius can be facing to the top, bottom, right, or left. So the algorithm, first, determines which of 4 orientations is present. | + | 1. The maximum radius can be facing to the top, bottom, right, or left. So the algorithm, first, determines which of 4 orientations is present. |
− | + | ||
+ | 2. Calculating the center of the circular segment. The center is calculated as a point <math>(x_c, y_c)</math> where two lines <math>(z_3, z_2)</math> and <math>(z_4, z_1)</math> cross. Therefore, | ||
====== Equation 1====== | ====== Equation 1====== | ||
Line 18: | Line 18: | ||
x_c=\frac {x_3 * y_2) - (x_2 * y_3)} {(x-3 -x_2)} - \frac {(x_4 * y_1) - (x_1 * y_4)} {x_4 - x_1)} | x_c=\frac {x_3 * y_2) - (x_2 * y_3)} {(x-3 -x_2)} - \frac {(x_4 * y_1) - (x_1 * y_4)} {x_4 - x_1)} | ||
+ | <br /> | ||
y_c = x_c \frac {y_4 -y_1} {x_4 -x_1} + \frac {(x_4 * y_1) - (x_1 * y_4)}{(x-4 - x_1)} | y_c = x_c \frac {y_4 -y_1} {x_4 -x_1} + \frac {(x_4 * y_1) - (x_1 * y_4)}{(x-4 - x_1)} | ||
</math> | </math> | ||
− | Calculating the angle of the sector in radians, see Figure 8. | + | 3. Calculating the angle of the sector in radians, see Figure 8. |
+ | |||
The angle is calculated as follows theta = theta2 - theta1. | The angle is calculated as follows theta = theta2 - theta1. | ||
For the maximum radius facing to the left, we must take into account the discontinuity of the angle at the negative x axis. The angle changes from <math>-\pi to \pi</math>, so the equation for <math>\theta</math> is now: | For the maximum radius facing to the left, we must take into account the discontinuity of the angle at the negative x axis. The angle changes from <math>-\pi to \pi</math>, so the equation for <math>\theta</math> is now: | ||
− | theta = abs(theta1) + abs(theta2) - 2.0 * | + | <math> \theta = abs(\theta1) + abs(\theta2) - 2.0 * \pi </math> |
− | The angle theta1 is along the line from center to | + | The angle <math>\theta1</math> is along the line from center to <math>z_4 to z_1</math> in <math> -\pi to \pi </math> radians: |
− | tan( | + | <math> \tan(\theta_1) = \frac{((y_1 - y_4)}{(x_1 - x4_)} => \theta_1 = \arctan{(y_1 - y_4)}{(x_1 - x_4)}</math> |
− | the angle | + | the angle <math>theta_2</math> is along the line from center to <math>z_3 to z_2</math> in <math> -\pi to \pi </math> radians: |
− | tan( | + | <math>\tan(\theta_2)= \frac{(y_2 - y_3)}{(x_2 - x_3)} => \theta_2 = \arctan\frac{(y_2 - y3_)}{(x_2 - x_3)} |
=== Transformation: Circle to Rectangle === | === Transformation: Circle to Rectangle === |
Revision as of 15:38, 17 August 2012
The methods described in this document use conformal mapping to transform points in a circular sector, circle, ellipse, or nearly circular region to points in a circle or rectangle.
Background
A conformal mapping, is a transformation w=f(z) that preserves local angles. An analytic function is conformal at any point where it has a nonzero first derivative. A complex function is analytic on a region R if it is complex differentiable at every point in R. In a conformal mapping, in any small neighborhood the relative angle and shape are preserved.
Circular Sector to Rectangle
The algorithm uses a 2D conformal mapping to convert a circular sector, defined by four user points at the sector corners, to a rectangle of the user specified size. The circular sector has an inner radius <math>r_{min}</math>, an outer radius <math>r_{max}</math>, and extends over an angle <math>theta = \alpha* \pi</math> radians, with <math>0 \le \alpha \le 1</math>.
Let, <math>z_1</math> and <math>z_2</math> belong to <math>r_{max}</math>, and <math>z_3</math> and <math>z_4</math> belong to <math>r_{min}</math>. The mapping to the user specified rectangle is performed in the following steps (1-6):
1. The maximum radius can be facing to the top, bottom, right, or left. So the algorithm, first, determines which of 4 orientations is present.
2. Calculating the center of the circular segment. The center is calculated as a point <math>(x_c, y_c)</math> where two lines <math>(z_3, z_2)</math> and <math>(z_4, z_1)</math> cross. Therefore,
Equation 1
<math> x_c=\frac {x_3 * y_2) - (x_2 * y_3)} {(x-3 -x_2)} - \frac {(x_4 * y_1) - (x_1 * y_4)} {x_4 - x_1)}
y_c = x_c \frac {y_4 -y_1} {x_4 -x_1} + \frac {(x_4 * y_1) - (x_1 * y_4)}{(x-4 - x_1)}
</math>
3. Calculating the angle of the sector in radians, see Figure 8.
The angle is calculated as follows theta = theta2 - theta1.
For the maximum radius facing to the left, we must take into account the discontinuity of the angle at the negative x axis. The angle changes from <math>-\pi to \pi</math>, so the equation for <math>\theta</math> is now:
<math> \theta = abs(\theta1) + abs(\theta2) - 2.0 * \pi </math>
The angle <math>\theta1</math> is along the line from center to <math>z_4 to z_1</math> in <math> -\pi to \pi </math> radians:
<math> \tan(\theta_1) = \frac{((y_1 - y_4)}{(x_1 - x4_)} => \theta_1 = \arctan{(y_1 - y_4)}{(x_1 - x_4)}</math>
the angle <math>theta_2</math> is along the line from center to <math>z_3 to z_2</math> in <math> -\pi to \pi </math> radians:
<math>\tan(\theta_2)= \frac{(y_2 - y_3)}{(x_2 - x_3)} => \theta_2 = \arctan\frac{(y_2 - y3_)}{(x_2 - x_3)}
Transformation: Circle to Rectangle
Transformation: Ellipse to Circle
Transformation: Nearly Circular Region to Circle
Applying the algorithms
Circular Sector to Rectangle
Circle to Rectangle
Ellipse to Circle
Nearly Circle to Circle
References
See also:
For the time being, please refer to the MIPAV HTML help Algorithms/TransformConformalMapping.html