• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 16179668883

09 Jul 2025 08:36PM UTC coverage: 74.263% (+0.1%) from 74.129%
16179668883

push

github

paulmthompson
test quadtree implementation

24 of 24 new or added lines in 1 file covered. (100.0%)

44 existing lines in 5 files now uncovered.

13233 of 17819 relevant lines covered (74.26%)

1337.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/WhiskerToolbox/DataManager/utils/polynomial/parametric_polynomial_utils.cpp
1
#include "parametric_polynomial_utils.hpp"
2

3
#include "armadillo" // For arma::mat, arma::vec, arma::solve, arma::conv_to
4

5
#include <vector>
6
#include <cmath> // For std::sqrt, std::pow
7

8
// Helper function to compute t-values based on cumulative distance
UNCOV
9
std::vector<double> compute_t_values(Line2D const & line) {
×
UNCOV
10
    if (line.empty()) {
×
11
        return {};
×
12
    }
13
    
UNCOV
14
    std::vector<double> distances;
×
UNCOV
15
    distances.reserve(line.size());
×
16
    distances.push_back(0.0);  // First point has distance 0
×
17
    
18
    double total_distance = 0.0;
×
UNCOV
19
    for (size_t i = 1; i < line.size(); ++i) {
×
20
        double dx = line[i].x - line[i-1].x;
×
21
        double dy = line[i].y - line[i-1].y;
×
22
        double segment_distance = std::sqrt(dx*dx + dy*dy);
×
23
        total_distance += segment_distance;
×
24
        distances.push_back(total_distance);
×
25
    }
26
    
UNCOV
27
    std::vector<double> t_values;
×
UNCOV
28
    t_values.reserve(line.size());
×
29
    if (total_distance > 0.0) {
×
30
        for (double d : distances) {
×
31
            t_values.push_back(d / total_distance);
×
32
        }
33
    } else {
UNCOV
34
        for (size_t i = 0; i < line.size(); ++i) {
×
UNCOV
35
            t_values.push_back(static_cast<double>(i) / static_cast<double>(line.size() > 1 ? line.size() - 1 : 1));
×
36
        }
37
    }
38
    
UNCOV
39
    return t_values;
×
UNCOV
40
}
×
41

42

43

44

45
// Helper function to fit a single dimension (x or y) of a parametric polynomial.
UNCOV
46
std::vector<double> fit_single_dimension_polynomial_internal(
×
47
    const std::vector<double>& dimension_coords,
48
    const std::vector<double>& t_values,
49
    int order) {
50
    
UNCOV
51
    if (dimension_coords.size() <= static_cast<size_t>(order) || t_values.size() != dimension_coords.size()) {
×
UNCOV
52
        return {}; // Not enough data or mismatched sizes
×
53
    }
54

UNCOV
55
    arma::mat X_vandermonde(t_values.size(), order + 1);
×
UNCOV
56
    arma::vec Y_coords(const_cast<double*>(dimension_coords.data()), dimension_coords.size(), false); // Use const_cast and non-copy for efficiency
×
57

58
    for (size_t i = 0; i < t_values.size(); ++i) {
×
UNCOV
59
        for (int j = 0; j <= order; ++j) {
×
60
            X_vandermonde(i, j) = std::pow(t_values[i], j);
×
61
        }
62
    }
63

UNCOV
64
    arma::vec coeffs_arma;
×
UNCOV
65
    bool success = arma::solve(coeffs_arma, X_vandermonde, Y_coords);
×
66

67
    if (!success) {
×
UNCOV
68
        return {};
×
69
    }
70
    return arma::conv_to<std::vector<double>>::from(coeffs_arma);
×
UNCOV
71
} 
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc