ART v1.0-alpha
A Robot Template that raises the floor for VRC teams
Loading...
Searching...
No Matches
Vec2.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <cmath>
18
19namespace art
20{
21
38 struct Vec2
39 {
46 double x;
47
54 double y;
55
63 Vec2();
64
74 double magnitude() const;
84 double direction() const;
85
96 Vec2 normalize() const;
97
115 double distTo(Vec2 target) const;
132 double angleTo(Vec2 target) const;
133
143 Vec2 operator+(Vec2 const &obj) const;
154 Vec2 operator-(Vec2 const &obj) const;
165 Vec2 operator*(double const &scale) const;
166
181 double operator*(Vec2 const &other) const;
182
191 Vec2 &operator+=(Vec2 const &obj);
200 Vec2 &operator-=(Vec2 const &obj);
209 Vec2 &operator*=(double const &scale);
210
226 static Vec2 XandY(double x, double y);
246 static Vec2 dirAndMag(double dir, double mag);
247
248 };
249
250} // namespace art
Definition PID.h:20
A Utility 2D Vector class.
Definition Vec2.h:39
Vec2 & operator+=(Vec2 const &obj)
Adds another vector to this one.
Definition Vec2.cpp:75
Vec2()
Construct a new Vec 2 object.
Definition Vec2.cpp:19
double y
Stores the Y component of the Vector.
Definition Vec2.h:54
Vec2 operator*(double const &scale) const
Returns a vector after scaling it.
Definition Vec2.cpp:64
double x
Stores the X component of the Vector.
Definition Vec2.h:46
Vec2 operator-(Vec2 const &obj) const
Returns the difference of 2 vectors.
Definition Vec2.cpp:58
double angleTo(Vec2 target) const
Gets the angle from this vector to another.
Definition Vec2.cpp:46
double direction() const
Gets the direction of the Vector.
Definition Vec2.cpp:26
Vec2 & operator*=(double const &scale)
Changes the vector by a scale.
Definition Vec2.cpp:89
Vec2 operator+(Vec2 const &obj) const
Returns the sum of 2 vectors.
Definition Vec2.cpp:52
double magnitude() const
Gets the magnitude of the Vector.
Definition Vec2.cpp:21
Vec2 & operator-=(Vec2 const &obj)
Substracts another vector from this one.
Definition Vec2.cpp:82
double distTo(Vec2 target) const
Gets the distance from this vector to another.
Definition Vec2.cpp:40
static Vec2 dirAndMag(double dir, double mag)
Constructs a vector with the specified direction and magnitude.
Definition Vec2.cpp:104
Vec2 normalize() const
Returns a unit Vector with the same direction.
Definition Vec2.cpp:33
static Vec2 XandY(double x, double y)
Constructs a vector with the specified x and y components.
Definition Vec2.cpp:96