Sorry.. I just used trial and error..and a page full of scribbling..

I am sure there is a X+y+z type equation..