How to find polar angle made by the line by joining the given point in cartesian plane with origin. I want a unique angle which will be from [0,2*pi)

Use conditionnal expression operator ?. It works as:

condition ? expression-true : expression-false

so for your question:

func f = ( (x==0.0 && y==0.0) ? 0.0 : ( x^2-y^2 > 0.0 ? x^2/(x^2+y^2) : y^2/(x^2+y^2) ) );