Since velocity Verlet is a generally useful algorithm in 3D applications, a general solution written in C++ could look like below. A simplified drag force is used to demonstrate change in acceleration, however it is only needed if acceleration is not constant.