User:Andrew Nikitin/Projective transformation

From J Wiki
Jump to navigation Jump to search

This calculator determines parameters of projective transformation that maps four given points into 4 given points.


Projective plane

Let's consider all triplets of real numbers . We will call triplets and equivalent when . We will call the set of equivalence classes the projective plane and each equivalence class a point on this plane.

Point of the regular plane can be identified wit point of the projective plane and point can be identified with point of the regular plane.

Points of the projective plane do not have corresponding points on the regular plane and are called inifinite points.

Point constitutes a class in itself.

For any given set of coefficients the set of points defined by is called a projective straight line.

Projective transformation

Linear transformation in the projective plane

corresponds to projective transformation of the regular plane

The important property of this transformation is that it transforms straight lines into straight lines.

The following J verb implements a projective transformation. It accepts a 3-element vector, which represents an arbitrary point on the projective plane. Alternatively, as a shortcut, 2-element vector (x,y) corresponds to finite point (x,y,1). [{{#file: "projective transformation"}} Download script: projective transformation ]

NB. M is in transposed form compared to natural
amv=:(}:%{:)@(+/ . * 3&({.!.1))"2 1

To visualise the transformation, we will use grid G0 as defined below and transform it to a projected grid. Then we will plot both grids. We will define a variant of the amv verb, called amc, which treats complex numbers as finite points of the projective plane and transforms them appropriately. [{{#file: "projective transformation"}} Download script: projective transformation ]

amc=: (j./"1@amv +.)
G0=:(<: %~ [: j./~ i.)11

Choosing a projective transformation

A projective transformation is defined by its 9 coefficients, but since projective transformation remains the same if all coefficients are multiplied by a non-zero number, only 8 of them are independent.

If we want point to become under some projective transformation, then coefficients of this transformation must satisfy


0 : 0
x0 y0 1 0  0  0 -x1x0 -x1y0 -x1
0  0  0 x0 y0 1 -y1x0 -y1y0 -y1

   straight lines are set of points (x,y,z) so that ax+by+cz=0, denoted (a,b,c)
   lx0=.1 0 0 NB. vertical line x=0
   lx1=.1 0 _1 NB. vertical line x=1
   lx2=.1 0 _2 NB. vertical x=2
   cleanup (1 0 _2 mp %. M) mp |:1,.~ M amv t


If M is a transformation, then straight line L=(a,b,c) transforms into L·inv(M) Indeed, (L·inv(M))·(M p)=L p=0.