Along with the popularity of GPS system and smart cell phone, trajectories of pedestrians or vehicles are recorded at any time. The great amount of works had been carried out in order to discover traffic paradigms or other regular patterns buried in the huge trajectory dataset. The core of the mining algorithm is how to evaluate the similarity, that is, the "distance", between trajectories appropriately, then the mining results will be accordance to the reality. Euclidean distance is commonly used in the lots of existed algorithms to measure the similarity, however, the trend of trajectories is usually ignored during the measurement. In this paper, a novel segment transform distance (STD) algorithm is proposed, in which a rule system of line segment transformation is established. The similarity of two-line segments is quantified by the cost of line segment transformation. Further, an improvement of STD, named ST-DTW, is advanced with the use of the traditional method dynamic time warping algorithm (DTW), accelerating the speed of calculating STD. The experimental results show that the error rate of ST-DTW algorithm is 53.97%, which is lower than that of the LCSS algorithm. Besides, all the weights of factors could be adjusted dynamically, making the algorithm suitable for various kinds of applications.