| 101 | } |
| 102 | |
| 103 | inline void |
| 104 | depth2xyz (float v_viewing_angle, float h_viewing_angle, |
| 105 | int image_width, int image_height, int image_x, int image_y, |
| 106 | float depth, float &x, float &y, float &z) |
| 107 | { |
| 108 | constexpr float PI = 3.1415927; |
| 109 | |
| 110 | if (depth <= 0.0f) |
| 111 | { |
| 112 | x = y = z = std::numeric_limits<float>::quiet_NaN (); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | float width = depth * std::tan (h_viewing_angle * PI / 180 / 2) * 2; |
| 117 | float height = depth * std::tan (v_viewing_angle * PI / 180 / 2) * 2; |
| 118 | |
| 119 | x = (image_x - image_width / 2.0) / image_width * width; |
| 120 | y = (image_height / 2.0 - image_y) / image_height * height; |
| 121 | z = depth; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /* ---[ */ |
| 126 | int |