Hi Pauln
Can you please give me a complete formula? I tried it, <-- it would be very helpful for us to see how you've done this
but it's not working very well.
I am also very interested in your application.
In am not a mathematician. ( as you see I make typos

)
I have been (retired) an Electrical Engineer (Agilent) and Computer Scientist (HP).
In the past I have been very involved in user interfaces where the user controls what appears on the display.
Including Vertical, Horizontal, and Rotation in 3D.
The reason I'm telling you this, is that (in my experience) these topics are not easy to communicate.
Stick with us. I'm sure that we can help once we understand your application or need. I have 4 questions.
1) What is your intended use for this information? (Homework, Job, hobby project, other)
2) What do you mean by "doesn't work"?
3) By your definition of "doesn't work" -- did it "work" after I fixed the typo?
4) "I tried it" -- in what way?
I suspect that my answer still "doesn't work" and that your question is more interesting than my answer.
It is easy for us to assume you are asking something that you are not.