The line
Code:
double range = (kTopTargetHeightIn-kCameraHeightIn)/Math.tan((y*kVerticalFOVDeg/2.0 + kCameraPitchDeg)*Math.PI/180.0);
is the same as the formula I provided before, if you substitute y*kVerticalFOVDeg/2.0 for relativeTargetAngle, substitute kCameraPitchDeg for cameraAngle, then convert it to radians before calculating tan() (multiplying by Math.PI/180.0 does this).
This method has some serious advantages over using height and linear perspective; you don't have to worry about distortions or weird angles, and these cameras are pretty accurate when it comes to relative angles. Make sure you use the right values for your horizontal and vertical field of view values though. For the M1011, it has a 47 degree horizontal field of view and
this stackexchange question provides a calculation for the vertical field of view yielding about 36.13 degrees.