The expansion of the railway industry has increased the demand for the three-dimensional modeling of railway tracks. Due to the increasing development of UAV technology and its application advantages, in this research, the detection and 3D modeling of rail tracks are investigated using dense point clouds obtained from UAV images. Accordingly, a projection-based approach based on the overall direction of the rail track is proposed in order to generate a 3D model of the railway. In order to extract the railway lines, the height jump of points is evaluated in the neighborhood to select the candidate points of rail tracks. Then, using the RANSAC algorithm, line fitting on these candidate points is performed, and the final points related to the rail are identified. In the next step, the pre-specified rail piece model is fitted to the rail points through a projection-based process, and the orientation parameters of the model are determined. These parameters are later improved by fitting the Fourier curve, and finally a continuous 3D model for all of the rail tracks is created. The geometric distance of the final model from rail points is calculated in order to evaluate the modeling accuracy. Moreover, the performance of the proposed method is compared with another approach. A median distance of about 3 cm between the produced model and corresponding point cloud proves the high quality of the proposed 3D modeling algorithm in this study.