The guidance of railway vehicles is determined by a complex interaction between the wheels and rails, which requires a detailed characterization of the contact mechanism in order to permit a correct analysis of the dynamic behavior. The kinematics of guidance of the wheelsets is based on the wheels and rails geometries. The movement of the wheelsets along the rails is characterized by a complex contact with relative motions on the longitudinal and lateral directions and relative rotations of the wheels with respect to the rails. A generic wheel-rail contact detection formulation is presented here in order to determine online the contact points, even for the most general three-dimensional motion of the wheelset. This formulation also allows the study of lead and lag flange contact scenarios, both fundamental for the analysis of potential derailments or for the study of the dynamic behavior in the presence of switches. The methodology is used in conjunction with a general geometric description of the track, which includes the representation of the rails' spatial geometry and irregularities. In this work, the tangential creep forces and moments that develop in the wheel-rail contact area are evaluated using alternatively the Kalker linear theory, the Heuristic nonlinear model or the Polach formulation. The discussion on the benefits and drawbacks of these methodologies is supported by an application to the dynamic analysis of the bogie of the railway vehicle.