Too much math ;) but I think I understand the basic idea