In recent years, the rate of the highway traffic accident remains high, with rear-end collisions accounted for more than 75%. In order to effectively reduce the incidence of rear-end collisions, this paper proposes a safety warning algorithm based on relative speeds among vehicles approaching an intersection from different directions. This algorithm relies on the GPS navigation system to obtain vehicles position and speed information, calculates the relative angle information between vehicles, and uses the information to calculate the safety distance between vehicles to determine the relationship between the safe distance and the time to collision, and to choose a proper alert system. The safety warning algorithm was implemented, simulated and verified under Matlab environment with the considerations of the influences of all kinds of road environment added to the system. The method and the algorithm proposed in this research has the advantages of broader applications in many V2V communication network systems for automobile or pilotless automobile and robot systems, and less and more efficient computation. The developed system based on the proposed research is more adaptive, safer with better fault tolerance compared with other systems.