RIT VEXU Core API
Loading...
Searching...
No Matches
math_util.h
1#pragma once
2#include "Eigen/Dense"
3#include "core/utils/geometry.h"
4#include "math.h"
5#include "vex.h"
6#include <vector>
7#include "core/utils/math/geometry/translation2d.h"
8
16double clamp(double value, double low, double high);
17
24double lerp(double a, double b, double t);
31double sign(double x);
32
33double wrap_angle_deg(double input);
34double wrap_angle_rad(double input);
35
36/*
37Calculates the variance of a set of numbers (needed for linear regression)
38https://en.wikipedia.org/wiki/Variance
39@param values the values for which the variance is taken
40@param mean the average of values
41*/
42double variance(std::vector<double> const &values, double mean);
43
44/*
45Calculates the average of a vector of doubles
46@param values the list of values for which the average is taken
47*/
48double mean(std::vector<double> const &values);
49
50/*
51Calculates the covariance of a set of points (needed for linear regression)
52https://en.wikipedia.org/wiki/Covariance
53
54@param points the points for which the covariance is taken
55@param meanx the mean value of all x coordinates in points
56@param meany the mean value of all y coordinates in points
57*/
58double covariance(std::vector<std::pair<double, double>> const &points, double meanx, double meany);
59
60/*
61Calculates the slope and y intercept of the line of best fit for the data
62@param points the points for the data
63*/
64std::pair<double, double> calculate_linear_regression(std::vector<std::pair<double, double>> const &points);
65
66double estimate_path_length(const std::vector<Translation2d> &points);