Hello,
I'm a Computer Engineer, and as such has taken Calculus courses and have extensive programming experience. The only part I don't understand of the description is exactly what length do you want to define. Is this the length between the two sensors? What are the sensors pointing at? What kind of calibration you which to perform?
If you are asking this code in C, I can pretty much guess you want this for an embedded system, must probable you have a microcontroller connected to the two sensors and such receiving data.
If this is your situation, please let me know more about what do you want to achieve. I'm sure I can help you with. I have good experience developing software for microcontrollers.
Best regards,
Héctor