17 Vector(
float x,
float y): x(x), y(y) {}
20 return {this->x + other.x, this->y + other.y};
23 Vector operator*(
float scalar)
const {
24 return {this->x * scalar, this->y * scalar};
27 float operator*(
Vector other)
const {
29 return this->x * other.x + this->y * other.y;
32 float getMagnitude()
const {
36 float getDirection()
const {
57 float magnitude = getMagnitude();
58 return {this->x / magnitude, this->y / magnitude};
61 Vector getPerpendicular()
const {
62 return {-this->y, this->x};
66 float magnitude = getMagnitude();
67 float angle = this->getDirection() - normal.getDirection();
72 float magnitude = getMagnitude();
73 float angle = normal.getDirection();
77 void print(
bool verbose =
true)
const {
79 printf(
"Vector x: %f, y: %f (%f, %f)\n", x, y, getMagnitude(), getDirection() * 180 /
Math::PI);
81 printf(
"%f |_ %f\n", getMagnitude(), getDirection() * 180 /
Math::PI);