41103C 26/27
Documentation for 41103C 1/3 for the 2026/2027 Vex V5 Season Override
Loading...
Searching...
No Matches
helpers.hpp
1#pragma once
2#include <string>
3#include <sstream>
4#include <cstdint>
5#include <cmath>
6#include <iostream>
7
8typedef uint8_t pros_adi_port;
9typedef int8_t pros_standard_port;
10typedef void (*SimpleCallback)();
11
12template <typename T>
13std::string to_string(T value)
14{
15 std::ostringstream os;
16 os << value;
17 return os.str();
18}
19
20class Vector2 {
21public:
22 float X;
23 float Y;
24
25 Vector2(void);
26 Vector2(float x, float y);
27
28 Vector2 operator+(const Vector2& other);
29 Vector2 operator-(const Vector2& other);
30 Vector2 operator*(const float& other);
31 Vector2 operator/(const float& other);
32 Vector2 operator=(const Vector2& other);
33
34 Vector2 operator+=(const Vector2& other);
35 Vector2 operator-=(const Vector2& other);
36 Vector2 operator*=(const float& other);
37 Vector2 operator/=(const float& other);
38
39 // Unary minus
40 Vector2 operator-();
41
42
43 float MagSquared(void);
44 float Mag(void);
45 float DistanceSquared(Vector2 other);
46 float Distance(Vector2 other);
47
48 float Dot(Vector2 other);
49 float Cross2(Vector2 other);
50
51 static float Arg(Vector2 vec);
52 static float ArgD(Vector2 vec); // Pls don't use, try always use rads
53
54 float AngleBetween(Vector2 vec);
55
56 std::string ToString(void);
57};
58
59const float IN_TO_MM = 2.54f;
60const float MM_TO_IN = 1 / IN_TO_MM;
61
62const float PI = 3.142f;
63const float SQRT2 = 1.414f;
64
65const float MILLISECONDS_TO_SECONDS = 0.001f;
66const float SECONDS_TO_MILLISECONDS = 1000.0f;
67
68const float sin90 = 1.0f;
69const float cos90 = 0.0f;
70
71float Clamp(float value, float low, float high);
72float FloatModulus(float value, float moduland);
73bool Within(float value, float target, float plusMinus);
74float SignedHeadingDifference(float value, float target);
75bool WithinHeading(float value, float target, float plusMinus);