Project Submission (late)
Dependencies: mbed
Vector2Di/Vector2Di.h@3:83e79d31930c, 2019-05-10 (annotated)
- Committer:
- el17tc
- Date:
- Fri May 10 14:52:28 2019 +0000
- Revision:
- 3:83e79d31930c
- Parent:
- 0:72f372170a73
final commit, API is added.; I'm not sure if there is a specific statement of academic integrity wanted but- I declare that this work is 100% my own, I have not plagiarised any work or attempted to fabricate any part of it for extra marks.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17tc | 0:72f372170a73 | 1 | #ifndef VECTOR2DI_H |
el17tc | 0:72f372170a73 | 2 | #define VECTOR2DI_H |
el17tc | 0:72f372170a73 | 3 | |
el17tc | 0:72f372170a73 | 4 | #include <math.h> |
el17tc | 0:72f372170a73 | 5 | #define PI 3.14159265358979323846 |
el17tc | 3:83e79d31930c | 6 | /** Vector2Di class |
el17tc | 3:83e79d31930c | 7 | * @brief stores a 1x2 vector as _integer_ values. |
el17tc | 3:83e79d31930c | 8 | * @brief I am aware one exists already in Gamepad.h that uses floats |
el17tc | 3:83e79d31930c | 9 | * @brief but my project only uses vectors as integers and I didn't want to risk |
el17tc | 3:83e79d31930c | 10 | * @brief errors or complications arrising from converting back and forth between float and int. |
el17tc | 3:83e79d31930c | 11 | * |
el17tc | 3:83e79d31930c | 12 | * @brief Version 1.0 |
el17tc | 3:83e79d31930c | 13 | * @author Thomas Caine |
el17tc | 3:83e79d31930c | 14 | * @date May 2019 |
el17tc | 3:83e79d31930c | 15 | */ |
el17tc | 0:72f372170a73 | 16 | class Vector2Di { |
el17tc | 0:72f372170a73 | 17 | |
el17tc | 0:72f372170a73 | 18 | public: |
el17tc | 0:72f372170a73 | 19 | |
el17tc | 0:72f372170a73 | 20 | int x; |
el17tc | 3:83e79d31930c | 21 | int y; |
el17tc | 3:83e79d31930c | 22 | /** Negation operator overload |
el17tc | 3:83e79d31930c | 23 | * Made the stepBack() function in Player.h easier to implement. |
el17tc | 3:83e79d31930c | 24 | * Simply negates the x and y components of the vector. |
el17tc | 3:83e79d31930c | 25 | */ |
el17tc | 0:72f372170a73 | 26 | Vector2Di operator -(); |
el17tc | 3:83e79d31930c | 27 | /** Adds another vector to this one |
el17tc | 3:83e79d31930c | 28 | * @param vector - the Vector2Di object to be added to this vector. |
el17tc | 3:83e79d31930c | 29 | */ |
el17tc | 0:72f372170a73 | 30 | void addVector(Vector2Di v); |
el17tc | 3:83e79d31930c | 31 | /** Rotate the current vector by a given angle |
el17tc | 3:83e79d31930c | 32 | * @param angle - rotates the vector by a given angle with some simple trig functions |
el17tc | 3:83e79d31930c | 33 | * The angle will always be a multiple of PI/2. |
el17tc | 3:83e79d31930c | 34 | */ |
el17tc | 0:72f372170a73 | 35 | void rotateVector(double angle); |
el17tc | 0:72f372170a73 | 36 | |
el17tc | 0:72f372170a73 | 37 | }; |
el17tc | 0:72f372170a73 | 38 | |
el17tc | 0:72f372170a73 | 39 | #endif |