Ok i think i figured out how to do it using ugly math but i want a nice algebraic formula with letters and stuff.