Measurements of angular distance and momentum ratio distributions in three-jet and Z + two-jet final states in pp collisions