Fractals/Computer graphic techniques/2D/transformation
Plane transformations
Names
[edit | edit source]- transformations
- Geometric Image Transformations
- Geometrical transformations
- coordinate transformations
- projections
- mappings
Theory
[edit | edit source]Mapping in 2D raster graphic is a complex function that maps from complex plane to complex plane:
It is implemented as point transformations.
It is usually denoted as
where
- is a point of complex plane ( input)
- is a point of image complex plane ( output = result)
Example code
[edit | edit source]For instance, Mercator:[3]
function Spherical_mercator(x, y) {
return [x, Math.log(Math.tan(Math.PI / 4 + y / 2))];
}
function transverseMercatorRaw(lambda, phi) {
return [log(tan((halfPi + phi) / 2)), -lambda];
}
transverseMercatorRaw.invert = function(x, y) {
return [-y, 2 * atan(exp(x)) - halfPi];
};
If one work with discrete geometry ( polygons and polylines) then the projecting is much harder to imlement. One have to balance accuracy and performance.[4]
// https://github.com/adammaj1/Mandelbrot-Sets-Alternate-Parameter-Planes/blob/main/src/lcm/d.c
// projection from p to c
complex double map_parameter(const ParameterTypeT ParameterType, const complex double parameter){
complex double p;
// plane transformation
switch(ParameterType){
case c_identity :{p = parameter; break;}
case c_inverted :{p = 1.0/parameter; break;}
case c_parabola :{p = 0.25+ 1.0/parameter; break;}
case c_Myrberg_type :{p = cf - 1.0/parameter; break;}
case c_inverted_2_type :{p = -2.0 + 1.0/parameter; break;}
case c_exp :{p = cf + cexp(parameter) ; break;} // here one can change cf to get different image
case lambda_identity :{ p = parameter; break;}
case lambda_inverted_type :{p = 1.0/parameter; break;}
case lambda_inverted_1_type :{p =1.0+ 1.0/parameter; break;}
default: {p = parameter;}
}
classifications
[edit | edit source]Maps classifications
- object-based mappings ( Image objects are sets of connected pixels having the same integer value )
- pixel based mappings
Transformations ( maps) in 2-D graphics
- basic types
- Composite Transformation [5]
Implementations
[edit | edit source]Use of matrices:
- without matrices ( using functions)
- with matrices
Coordinate
- with Cartesian coordinate
- with homogenous coordinate
Matrix
[edit | edit source]- "Matrix multiplication is not commutative. The order of the transformations is vital– Rotation followed by translation isvery different from translation followed by rotation"[6]
Implementations
-
rows
-
columns
types
[edit | edit source]- zoom
- inversion
- unrolling (a closed curve )
- Conformal maps applied to pictures
- Moebius transformation
- Exponential and Mercator map
Affine transformations
[edit | edit source]To represent affine transformations with matrices, we can use homogeneous coordinates. This means representing a 2-vector (x, y) as a 3-vector (x, y, 1), and similarly for higher dimensions.
Transformation name | Affine matrix | Example |
---|---|---|
Identity (transform to original image) | ||
Translation | ||
Reflection | ||
Scale | ||
Rotate | where θ = π6 =30° | |
Shear |
The affine transforms are applicable to the registration process where two or more images are aligned (registered). An example of image registration is the generation of panoramic images that are the product of multiple images stitched together.
scale or resize
[edit | edit source]Scaling of object about origin by by a scale factor
becomes:
Scaling
- Uniform (maintains the object’s proportions as it scales): sx = sy
- non-uniform: sx != sy
Resizing objects while maintaining a fixed centre point = Scaling object about their own center
- width' = width * sx
- height' = height * sy
- compute coordinate of corners from the center
translation
[edit | edit source]Complex transtlation is a map[7]
where
Using this system, translation can be expressed with matrix multiplication. The functional form
becomes:
rotation
[edit | edit source]For rotation by an angle θ counterclockwise (positive direction) about the origin the functional form is
.
Written in matrix form, this becomes:[8]
Similarly, for a rotation clockwise (negative direction) about the origin, the functional form is
the matrix form is:
These formulae assume that the x axis points right and the y axis points up.
the counter-clockwise rotation matrix in normalised coordinate:
C code without matrix
/*
C program to rotate an object by a given angle about a given point
gcc r.c -Wall -Wextra -lm
./a.out
*/
#include <stdio.h>
#include <math.h>
#include <complex.h> // complex numbers : https://stackoverflow.com/questions/6418807/how-to-work-with-complex-numbers-in-c
//The sin() function returns the value in the range of [-1, 1]
/*
https://stackoverflow.com/questions/2259476/rotating-a-point-about-another-point-2d
First subtract the pivot point (cx,cy), then rotate it (counter clock-wise), then add the point again.
*/
complex double rotate_point(const complex double center, const double angle_in_radians, const complex double point )
{
// translate point to center
complex double translated_point = creal(point) - creal(center) + (cimag(point) - cimag(center))*I;
// rotate point counter clock-wise by a given angle about a given pivot point ( center)
double s = sin(angle_in_radians);
double c = cos(angle_in_radians);
complex double new_point = creal(translated_point) * c - cimag(translated_point) * s + (creal(translated_point) * s + cimag(translated_point) * c)*I;
// translate point back
new_point = creal(new_point) + creal(center) +(cimag(new_point) + cimag(center))*I;
return new_point;
}
#define kMax 6
// center, angle_rad, point
double examples[kMax][5] = {
{50,-50, -0.7853982, 100,100 },
{50,-50, -0.7853982, 100,200 },
{50,-50, -0.7853982, 200,200 },
{0,0, 1.570796, 100,100},
{0,0, 1.570796, 150,200},
{0,0, 1.570796, 200,200}
};
int main(void){
int k;
complex double center ;
double angle_r ;
complex double point ;
complex double rotated_point;
for (k=0; k<kMax; ++k){
center = examples[k][0] + examples[k][1] * I ;
angle_r = examples[k][2];
point = examples[k][3] + examples[k][4] * I ;
rotated_point = rotate_point(center, angle_r, point );
fprintf(stdout, "point %f%+f*I rotated about %f%+f*I by %f radians is %f%+f*I \n", creal(point), cimag(point), creal(center), cimag(center), angle_r, creal(rotated_point), cimag(rotated_point));
}
return 0;
}
Output:
point 100.000000+100.000000*I rotated about 50.000000-50.000000*I by -0.785398 radians is 191.421359+20.710673*I point 100.000000+200.000000*I rotated about 50.000000-50.000000*I by -0.785398 radians is 262.132040+91.421348*I point 200.000000+200.000000*I rotated about 50.000000-50.000000*I by -0.785398 radians is 332.842715+20.710668*I point 100.000000+100.000000*I rotated about 0.000000+0.000000*I by 1.570796 radians is -99.999967+100.000033*I point 150.000000+200.000000*I rotated about 0.000000+0.000000*I by 1.570796 radians is -199.999951+150.000065*I point 200.000000+200.000000*I rotated about 0.000000+0.000000*I by 1.570796 radians is -199.999935+200.000065*I
Other Interesting maps
[edit | edit source]-
with python code
- Jason Davies: maps
- barrel-distortion
- swirl[11]
- log-polar map [12]
- Parabolic Cylindrical Coordinates [13]
- Parabolic Coordinates[14]
- Numerical approximation of conformal mappings [15]
- description[16][17]
- inflection [18]
- Altmetric: 25Citations: 1More detail Article | OPEN Exponential Sensitivity and its Cost in Quantum Physics by András Gilyén, Tamás Kiss & Igor Jex
- Blaschke product [19]
- squaring the circle[20]
- elliptic by Claude Heiland-Allen
- by Paul Bourke
- A cartographic projection is a nonlinear transformation in two dimensions
- map projections and coordinate transformations
- to sphere[21]
- Mandelbrot set projected on a shrinking Riemann-sphere by Arneauxtje
- Mandelbrot's Elephant Valley (Short Version) Timothy Chase
- Mandelbrot Buds and Branches Timothy Chase Timothy Chase
- Mandelbrot Zoom on a Sphere video by craftvid : "This a 300-trillion time zoom-in on the Mandelbrot set. The images are set on a Spherical "mobius" projection, meant to be wrapped onto a spherical surface. The image zooms in on the front center of the Sphere, while fading away on the back of the sphere."
- Cat Eye : Inverted Mandelbrot Set by denis archambaud
- Inverse & Potens Mandelbrot Set by Jens-Peter Christensen
- Z² + Sin(Cˉᵐ+phase) by Jens-Peter Christensen
- snibgo's ImageMagick pages: Barrels and pincushions
- snibgo's ImageMagick pages: Scale, rotate and translate in 3D see Cube earth
Conformal map
[edit | edit source]- "Conformal maps preserve angles and take infinitesimal circles to infinitesimal circles. Non-conformal maps take infinitesimal circles to infinitesimal ellipses (or worse)." Claude Heiland-Allen
- "A complex function is conformal at infinity if the function is conformal at 0. This equivalent to the usual definition of conformal in terms of leaving angles unchanged in size and sense (clockwise/anticlockwise) if you think of as being conformal at infinity if it leaves angles unchanged at the "North Pole" of the Riemann sphere."[22]
Conformal maps
- henry seg: spherical_image_editing in python
- newconformist: Conformally map the hyperbolic plane to arbitrary shapes by Zeno Rogue
- examples of conformal maps applied to pictures
- Moebius transformation
- An Overview of Conformal Geometry Processing (2017) by Keenan Crane
- Discrete Conformal Deformation: Algorithm and Experiments by Jian Sun, Tianqi Wu, Xianfeng Gu, Feng Luo
- Conformal map
- Poincaré Hyperbolic Disk Conformal Mapping Recipe by bugman123
- Visualizing Conformal Maps in Python by MJ Gruber
- Conformal Animation by denis archambaud
- ConformalMaps is a Julia package for approximating the Riemann map from a simply connected planar domain to a disk. It uses the zipper algorithm as described in Convergence of the zipper algorithm for conformal mapping by Don Marshall and Steffen Rohde.
- sswatson: ConformalMaps
Dictionary of Conformal Mapping by John H. Mathews, Russell W. Howell ( 2008)
Cartographic Map projection
[edit | edit source]cylindrical projection
[edit | edit source]Cylindrical projection ( or cylindric p. ) maps from sphere ( without poles) to cylinder [23][24]
Joukowsky transformation (map)
[edit | edit source]Description :
- John D Cook[25]
domain coloring or complex phase plots
[edit | edit source]Visualisation of complex functions
- The 5 ways to visualize complex functions
- commons : Category:Complex_functions
- Complex Mappings by Rand Asswad
- Poincaré Hyperbolic Disk Conformal Mapping Recipe by Paul Nylander
- david lowry-duda : phase_mag_plot/
modular forms
[edit | edit source]Riemann mappings
[edit | edit source]- The Riemann Mapping Theorem by Christopher J. Bishop
- Riemman for anti-dummies by ©2015 LYM Canada
- Maping component to the unit disk ( Riemann map ):
- Multiplier map and internal ray
- on the parameter plane
- on the dynamic plane
- Boettcher map, complex potential and external ray
- on the parameter plane
- parameter ray = field lines
- complex potential , external angle
- on the parameter plane
- Multiplier map and internal ray
References
[edit | edit source]- ↑ Map projection in wikipedia
- ↑ observable: plot-projections
- ↑ Transverse_Mercator_projection in wikipedia
- ↑ : Geographic projections, spherical shapes and spherical trigonometry in JavaScript
- ↑ geeksforgeeks : composite-transformation-in-2-d-graphics
- ↑ 2D transformations and homogeneous coordinates by Dr Nicolas Holzschuch University of Cape Town
- ↑ Terr, David. "Complex Translation." From MathWorld--A Wolfram Web Resource, created by Eric W. Weisstein.
- ↑ http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-07-dynamics-fall-2009/lecture-notes/MIT16_07F09_Lec03.pdf Template:Bare URL PDF
- ↑ opentextbc.ca: nature of geographic information
- ↑ wolfram : ComplexFunctionsAppliedToASquare
- ↑ scikit-image.org docs: swirl
- ↑ Log-Polar Mapping by Alexandre Bernardino
- ↑ Weisstein, Eric W. "Parabolic Cylindrical Coordinates." From MathWorld--A Wolfram Web Resource
- ↑ Weisstein, Eric W. "Parabolic Coordinates." From MathWorld--A Wolfram Web Resource.
- ↑ Numerical approximation of conformal mappings by Bjørnar Steinnes Luteberget
- ↑ processing : transform2d
- ↑ Squares that Look Round: Transforming Spherical Images by Saul Schleimer Henry Segerman
- ↑ fractalforums inflection-mappings
- ↑ theinnerframe : playing-with-circular-images
- ↑ theinnerframe :squaring-the-circle
- ↑ fractalforums: fractal-on-sphere
- ↑ math.stackexchange question: conformal-mappings-of-riemann-sphere
- ↑ Spherical Projections (Stereographic and Cylindrical) Written by Paul Bourke
- ↑ Weisstein, Eric W. "Cylindrical Projection." From MathWorld--A Wolfram Web Resource.
- ↑ johndcook : joukowsky-transformation