#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Funktion arg für Aufgabe 36 

from ngsolve import *
import numpy as np
# ab jetzt sind x, y, z CoefficientFunctions aus dem Modul ngsolve.fem

def arg(x, y):
    '''
    gibt den Winkel phi in [0, 2pi) aus der Darstellung x + iy = r exp(i phi) zurück, 
    phi ist wieder eine CoefficientFunction
    '''
    g1 = atan(y/x)
    g2 = atan(y/x) + np.pi
    g3 = atan(y/x) + 2*np.pi
    g4 = np.pi/2 + 0*x
    g5 = 3*np.pi/2 + 0*x
    
    return IfPos(x, IfPos(y, g1, g3), IfPos(-x, g2, IfPos(y, g4, g5)))