Project Submission (late)

Dependencies:   mbed

Committer:
el17tc
Date:
Fri May 10 08:07:10 2019 +0000
Revision:
0:72f372170a73
Child:
3:83e79d31930c
Save at functioning version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17tc 0:72f372170a73 1 #include "Vector2Di.h"
el17tc 0:72f372170a73 2
el17tc 0:72f372170a73 3 // Vector manipulation functions
el17tc 0:72f372170a73 4 Vector2Di Vector2Di::operator -() {
el17tc 0:72f372170a73 5 Vector2Di negV = {x*-1, y*-1};
el17tc 0:72f372170a73 6 return negV;
el17tc 0:72f372170a73 7 }
el17tc 0:72f372170a73 8
el17tc 0:72f372170a73 9 void Vector2Di::addVector(Vector2Di v) {
el17tc 0:72f372170a73 10 int newX = x + v.x;
el17tc 0:72f372170a73 11 int newY = y + v.y;
el17tc 0:72f372170a73 12 x = newX;
el17tc 0:72f372170a73 13 y = newY;
el17tc 0:72f372170a73 14 }
el17tc 0:72f372170a73 15
el17tc 0:72f372170a73 16 void Vector2Di::rotateVector(double angle) {
el17tc 0:72f372170a73 17 double newX = (x * cos(angle)) + (y * -sin(angle));
el17tc 0:72f372170a73 18 double newY = (x * sin(angle)) + (y * cos(angle));
el17tc 0:72f372170a73 19 x = static_cast<int>(newX);
el17tc 0:72f372170a73 20 y = static_cast<int>(newY);
el17tc 0:72f372170a73 21 }