Skip to content

Instantly share code, notes, and snippets.

@Soccolo
Created April 13, 2021 15:00
Show Gist options
  • Save Soccolo/728c93f86e1c63bd1805858525dcc493 to your computer and use it in GitHub Desktop.
Save Soccolo/728c93f86e1c63bd1805858525dcc493 to your computer and use it in GitHub Desktop.
A short program that computes the Cross-Ratios Mobius Transformation
#When treating the Mobius Transformation f(z)=(az+b)/(cz+d) that sends z1 to w1, z2 to w2 and z3 to w3 and create linear equations.
#The governing equations will be of the form a*zi+b-zi*wi*c-wi*d=0. There will be 3 equations with 4 unknowns, so we have an
#undetermined system of equations. We compute the null-space of the matrix using scipy, and then return the vector with first coefficient
#equal to 1.
from scipy.linalg import null_space
import numpy as np
def Mobius_transform(z1, z2, z3, w1, w2, w3):
A=np.array([[z1, 1, -z1*w1, -w1], [z2, 1, -z2*w2, -w2], [z3, 1, -z3*w3, -w3]])
x=null_space(A)
x=x/x[0]
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment