Assuming that:
- +Z is up in your world.
- Your objects look in the direction of +X.
- No roll.
And vector delta is posB - posA...
Then object a first needs to yaw (around Z) with angle atan2f( delta.y, delta.x )
.
And then object a needs to tilt with angle -asin( delta.normalized().z )
.
As DMGregory mentioned, this all changes if you have different conventions in your world (Which axis is up, what is rotation sequence, left-handed coordinate systems or right-handed ones.)
Aside from this, note that it is often beneficial not to use euler angles, and just set a's transformation matrix by choosing x-axis as normalized view dir, y-axis is cross between (0,0,1) and this x-axis, normalized. And then z-axis as cross between x and y. After setting the translation component to the position, the resulting matrix can be used for object a.