Skip to content
Snippets Groups Projects

Refactor

Merged Bruno Freitas Tissei requested to merge refactor into master
9 files
+ 93
15
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 22
0
/**
* Geometry functions
*/
struct Vector {
double x, y;
Vector(double x, double y) : x(x), y(y) {}
double dot_product(Vector v) { return x * v.x + y * v.y; }
double cross_product(Vector v) { return x * v.y - v.x * y; }
/**
* Returns angle between this and v.
*/
double angle(Vector v) {
// atan2(y, x) is in the range [-180,180]. To get [0, 360],
// atan2(-y, -x) + 180 is used
return ((atan2(-cross_product(v), -dot_product(v)) * 180.0) / M_PI) + 180.0;
}
};
Loading