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