Helper computes one or more features corresponding to the given points. Emitted features are on the line defined by: start_pt + lambda * (end_pt - start_pt) for scalar lambda. Features are spaced at feature_length intervals.
| 234 | // start_pt + lambda * (end_pt - start_pt) for scalar lambda. |
| 235 | // Features are spaced at feature_length intervals. |
| 236 | static int ComputeFeatures(const FCOORD& start_pt, const FCOORD& end_pt, |
| 237 | double feature_length, |
| 238 | GenericVector<INT_FEATURE_STRUCT>* features) { |
| 239 | FCOORD feature_vector(end_pt - start_pt); |
| 240 | if (feature_vector.x() == 0.0f && feature_vector.y() == 0.0f) return 0; |
| 241 | // Compute theta for the feature based on its direction. |
| 242 | uinT8 theta = feature_vector.to_direction(); |
| 243 | // Compute the number of features and lambda_step. |
| 244 | double target_length = feature_vector.length(); |
| 245 | int num_features = IntCastRounded(target_length / feature_length); |
| 246 | if (num_features == 0) return 0; |
| 247 | // Divide the length evenly into num_features pieces. |
| 248 | double lambda_step = 1.0 / num_features; |
| 249 | double lambda = lambda_step / 2.0; |
| 250 | for (int f = 0; f < num_features; ++f, lambda += lambda_step) { |
| 251 | FCOORD feature_pt(start_pt); |
| 252 | feature_pt += feature_vector * lambda; |
| 253 | INT_FEATURE_STRUCT feature(feature_pt, theta); |
| 254 | features->push_back(feature); |
| 255 | } |
| 256 | return num_features; |
| 257 | } |
| 258 | |
| 259 | // Gathers outline points and their directions from start_index into dirs by |
| 260 | // stepping along the outline and normalizing the coordinates until the |
no test coverage detected