Fractals/Computer graphic techniques/2D/transformation

Plane transformations


  • transformations
  • projections
    • Cartographic Map projection[1] ( in case of 3D to 2D graphic)[2]
  • mappings


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



  •   is a point of complex plane ( input)
  •   is a point of image complex plane ( output = result)

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]


Maps clasifications

  • 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]




C program to rotate an object by a given angle about a given point
gcc r.c -Wall -Wextra -lm

#include <stdio.h>
#include <math.h> 
#include <complex.h> 		// complex numbers :

//The sin() function returns the value in the range of [-1, 1]

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;


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 mapsEdit


Conformal mapEdit

  • "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."[19]

Conformal maps

Dictionary of Conformal Mapping by John H. Mathews, Russell W. Howell ( 2008)

Cartographic Map projectionEdit

cylindrical projectionEdit

The geometry for the normal (equatorial) tangent projections of the sphere to the cylinder.

Cylindrical projection ( or cylindric p. ) maps from sphere ( without poles) to cylinder [20][21]

Joukowsky transformation (map)Edit

Description :

domain coloring or complex phase plotsEdit

Visualisation of complex functions

modular formsEdit

Riemann mappingsEdit


  1. Map projection in wikipedia
  2. observable: plot-projections
  3. Transverse_Mercator_projection in wikipedia
  4. : Geographic projections, spherical shapes and spherical trigonometry in JavaScript
  5. geeksforgeeks : composite-transformation-in-2-d-graphics
  6. nature of geographic information
  7. wolfram : ComplexFunctionsAppliedToASquare
  8. docs: swirl
  9. Log-Polar Mapping by Alexandre Bernardino
  10. Weisstein, Eric W. "Parabolic Cylindrical Coordinates." From MathWorld--A Wolfram Web Resource
  11. Weisstein, Eric W. "Parabolic Coordinates." From MathWorld--A Wolfram Web Resource.
  12. Numerical approximation of conformal mappings by Bjørnar Steinnes Luteberget
  13. processing : transform2d
  14. Squares that Look Round: Transforming Spherical Images by Saul Schleimer Henry Segerman
  15. fractalforums inflection-mappings
  16. theinnerframe : playing-with-circular-images
  17. theinnerframe :squaring-the-circle
  18. fractalforums: fractal-on-sphere
  19. math.stackexchange question: conformal-mappings-of-riemann-sphere
  20. Spherical Projections (Stereographic and Cylindrical) Written by Paul Bourke
  21. Weisstein, Eric W. "Cylindrical Projection." From MathWorld--A Wolfram Web Resource.
  22. johndcook : joukowsky-transformation