They got that x equation from using trig. For the first part of x, they’re looking at the triangle w/ sides A, B, and the bottom side is a small part of x, or “d”. So “d” is acostheta. For the second part of x, they’re looking at the other triagle w/ sides B, P, and the other side of x, or “e,” we’ll call it. By trig, “e” is equal to the sqrt(b2-a2sin2theta). Hope that helps! For clarification: x = d + e