Basic experiments with conic sections in homogeneous coordinates

Contents

Define a circumference

Let's define circumference centered in 0,0 with radius 400

r=400
C=[1 0 0; 0 1 0; 0 0 -r^2]
r =

   400


C =

           1           0           0
           0           1           0
           0           0     -160000

Draw it

We pick every pixel, and compute the incidence relation.

im=zeros(500,500);
for i=1:500 for j=1:500
im(i,j)=[j i 1]*C*[j i 1]';
end
end

Show the actual values at each pixel: the smallest value will be black and the biggest one will be white.

imshow(im,[]);

We are interested in where the values are greater than zero or less than zero

imshow(im>0);

Check some other properties

Let's verify that the polar line to the circumference center is the line at infinity

C*[0 0 1]'
ans =

           0
           0
     -160000

Let's check the pole-polar duality relation

x1=[500,400,1]';
x2=[600,300,1]';
l1=C*x1;
l2=C*x2;
x3=cross(l1,l2);
l3=C*x3;
l3'*x1
ans =

     0

The polar of a point on the circumference is its tangent

l=C*[r 0 1]'
l =

         400
           0
     -160000

this is the vertical line at the right of the circumference. let's do the same with a point at the up-right of the circumference

l=C*[r*sqrt(2)/2 r*sqrt(2)/2 1]'
l =

   1.0e+05 *

    0.0028
    0.0028
   -1.6000

let's check where l intersects the y axis

x=cross(l,[1 0 0]');
x(2)/x(3)
r*sqrt(2)
ans =

  565.6854


ans =

  565.6854

Some transformations

Let's move the circumference to the center of the image, and scale it to half size. We will build a similarity transform

t=[200 200]';   % translation
s=.5;           % scale factor
Similarity=[s*eye(2) t; 0 0 1];

We transform the conic...

Cprime=inv(Similarity)'*C*inv(Similarity);

.. and we draw it as before:

im=zeros(500,500);
for i=1:500 for j=1:500
im(i,j)=[j i 1]*Cprime*[j i 1]';
end
end
imshow(im>0);

Obviously, the line at the infinity is unchanged by our similarity

inv(Similarity)'*[0 0 1]'
ans =

     0
     0
     1