4. The moving point $A$ corresponds to the complex number $z=4(\cos \theta+\mathrm{i} \sin \theta)$, the fixed point $B$ corresponds to the complex number 2, and point $C$ is the midpoint of line segment $A B$. A perpendicular line to $A B$ through point $C$ intersects $O A$ at $D$. Then the equation of the locus of point $D$ is $\qquad$.
4. $\frac{(x-1)^{2}}{4}+\frac{y^{2}}{3}=1$.

From $C D$ being the perpendicular bisector of $A B$, we get $D A=D B$. Therefore, $D O+D B=D O+D A=O A=4$.

It is evident that the sum of the distances from point $D$ to the fixed points $U$ and $B$ is a constant 4, so its trajectory is an ellipse with foci at $O$ and $B$, and $2a=4$. Also, $2c=2$, so $b^{2}=a^{2}-c^{2}=3$. Therefore, the equation of the trajectory is
$$
\frac{(x-1)^{2}}{4}+\frac{y^{2}}{3}=1 \text {. }
$$