Considering that UAVs, serving as base stations, can enhance the flexibility of communication system transmission, reduce transmission delays, and provide temporary communication, this paper proposes a NOMA-assisted UAV downlink communication network model in a Rice fading channel, which is more suitable for air-to-ground transmission. The joint optimization of UAV three-dimensional trajectory, pitch angle, and user clustering is studied to improve the sum rate of the communication system. Among these, clustering users within different time intervals of UAV flight can lead to three scenarios: increasing, reducing, and replacing the number of users. Addressing the issue of nonlinear programming, this paper proposes an improved algorithm that combines the grey wolf optimization algorithm and the particle swarm optimization algorithm to overcome the insufficient global search ability of the grey wolf optimization algorithm. Simulation results show that the GWOPSO algorithm has a better convergence speed and accuracy, and the system also exhibits improved sum rate performance.