Visualizing homography in manim

51 Views Asked by At

I am trying to make an animation where I can see how is some region is transformed by a complex function. Specifically, right now I want to see how a unit disc is transformed by homography.

Let $f(z)=\frac{2z-1}{z-2}$. I think that this homography transforms the unit disc on itself, and I want to graphically check it. This is my code, which is copied and pasted from other sources:

from manim import *
import numpy as np

class homography(LinearTransformationScene):
    def construct(self):
        disc = Circle(radius=1, color=BLUE_B, fill_opacity=1)
        ring = AnnularSector(inner_radius=1, outer_radius=1.5, angle=360 * DEGREES, color=RED)
        point = Dot(point=np.array([1/2.,0.,0.]),radius=0.1,color=RED)
        "self.add_transformable_mobject(disc)"
        self.play(
            ApplyPointwiseFunction(
                lambda point: complex_to_R3((2*R3_to_complex(point)-1)/(R3_to_complex(point)-2)), disc
            )
            
        )
        self.play(
            ApplyPointwiseFunction(
                lambda point: complex_to_R3((2*R3_to_complex(point)-1)/(R3_to_complex(point)-2)), ring
            )
        )
        self.play(
            ApplyPointwiseFunction(
                lambda point: complex_to_R3((2*R3_to_complex(point)-1)/(R3_to_complex(point)-2)), point
            )    
        )
         
        self.wait()

I have some questions:

  1. What does the function complex_to_R3() do? I can't find a place where it is described; I think it changes complex plane to the R^2 plane. If so why there is 3 in the name instead of 2?

  2. How can I restrict the domain of the map? Now map is undefined at z=2. And it is not a problem in my code since I only use regions that do not contain z=2, but if I wanted to see how a disc of radius 2 is transformed then I couldn't, due to the division by 0. I want specific lines of code, I don't know this language. Today is my first time in a while writing code.

I tried to find a solution online but I failed.

0

There are 0 best solutions below