Converting rotational power to vertical/horizontal

Probably not hard for anyone to figure out on their own but I came up with this contraption while messing around:

Was thinking how in certain builds it might be useful where you want more precise extension rather than a piston just popping out and stopping right before it breaks the sound barrier.