1. The problem statement, all variables and given/known data

Find the expression for theEfield at an arbitrary point in space due to a straight line of length l uniformly charged with total charge Q. The ambient medium is air.

2. Relevant equations

3. The attempt at a solution

I am following this example with the solution given in my textbook and I am confused about one part.

He somehow makes the following transition,

Where does the ld in the denominator come from?

From trig relationships it can be shown that,

which accounts for the d in the denominator, but where does the l come from? Is it that,

?

And if so, why? (That doesn't make any sense to me)

Also, where does he get ? Where does this come from?

Also, he mentions that ranges from to , but is moving counterclockwise fashion, so shouldn't we conclude and for moving in a clockwise fashion, ? In his solution he has this reversed, so what am I mixing up?