# Speed between two cars with radar

I found a programming problem that calculated the speed between two cars as below and I would like to know how the calculation is done. It is about determining the speed of lead car. The coordinate reference system (y,x) is attached to the ego vehicle (as shown in the attached figure).

The relative speed of the lead car is estimated with the radar of the ego vehicle (using the Doppler effect). So, the goal is to determine the speed of the lead car from the relative speed and that of ego vehicle.

As mentioned in the program reference: The true ground speed of a radar-reported object from the relative speed and the ego vehicle speed is calculated as follows:

(Vxi,Vyi) : relative object speed
egoSpeed  : ego vehicle speed
[Vx,Vy]   : ground object speed

Vx = Vxi + egoSpeed    :Calculate longitudinal ground speed
theta = atan2(Vyi,Vxi) :Calculate heading angle
Vy = Vx * tan(theta)   :Calculate lateral ground speed


Is there anyone who can explain how Vx and Vy are calculated?