The car can get Cartesian coordinate (x-asix) feedback (mm unit) from encoder to MCU. I think my question should be how to write the algorithm to generate the speed value, and then put this value on my function which control the speed of the motor.
I think you are saying (and please correct me if I am wrong) ...
The Arduino will be counting the encoder pulses and at any moment the number of pulses represents the distance traveled.
And as the distance changes you want to change the speed (RPM of the motor).
That should (in general) be perfectly possible but you have not told us how you will be measuring the speed or how you want the speed to vary as the distance varies.
I think you may find it useful to study the code in the AccelStepper library because a key part of that library is to smoothly accelerate and decelerate a stepper motor though a specified number of steps.
And what do you mean, in Reply #3, by "I can't provide more detail now for some reasons" I hope you are not looking for free advice for a commercial project just so you can make profit at our expense.