Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Point.cpp@5:d7d16cb9c974, 2015-08-17 (annotated)
- Committer:
- tyleralt
- Date:
- Mon Aug 17 21:56:25 2015 +0000
- Revision:
- 5:d7d16cb9c974
- Parent:
- 4:f1e33a234a74
export commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tyleralt | 0:ded79d89abdf | 1 | |
tyleralt | 0:ded79d89abdf | 2 | #include "Point.h" |
tyleralt | 0:ded79d89abdf | 3 | //*********************point class************************// |
tyleralt | 0:ded79d89abdf | 4 | |
tyleralt | 0:ded79d89abdf | 5 | Point :: Point (void){ |
tyleralt | 5:d7d16cb9c974 | 6 | positionRadian = 90; |
tyleralt | 0:ded79d89abdf | 7 | positionHeight = 4; |
tyleralt | 0:ded79d89abdf | 8 | positionDistance = 8; |
tyleralt | 1:bb1507f0bb64 | 9 | offAngles[0] = -6; |
tyleralt | 0:ded79d89abdf | 10 | offAngles[1] = 174; |
tyleralt | 0:ded79d89abdf | 11 | offAngles[2] = 44; |
tyleralt | 0:ded79d89abdf | 12 | offAngles[3] = 228; |
tyleralt | 5:d7d16cb9c974 | 13 | offAngles[4] = 92; |
tyleralt | 5:d7d16cb9c974 | 14 | offAngles[5] = 275; |
tyleralt | 5:d7d16cb9c974 | 15 | offAngles[6] = 145; |
tyleralt | 1:bb1507f0bb64 | 16 | offAngles[7] = 323; |
tyleralt | 5:d7d16cb9c974 | 17 | //Point(90, 4, 8); |
tyleralt | 0:ded79d89abdf | 18 | } |
tyleralt | 0:ded79d89abdf | 19 | |
tyleralt | 0:ded79d89abdf | 20 | Point :: Point (int posRadian, int posHeight, int posDistance){ |
tyleralt | 0:ded79d89abdf | 21 | positionRadian = posRadian; |
tyleralt | 0:ded79d89abdf | 22 | positionHeight = posHeight; |
tyleralt | 0:ded79d89abdf | 23 | positionDistance = posDistance; |
tyleralt | 1:bb1507f0bb64 | 24 | offAngles[0] = -6; |
tyleralt | 0:ded79d89abdf | 25 | offAngles[1] = 174; |
tyleralt | 0:ded79d89abdf | 26 | offAngles[2] = 44; |
tyleralt | 0:ded79d89abdf | 27 | offAngles[3] = 228; |
tyleralt | 5:d7d16cb9c974 | 28 | offAngles[4] = 92; |
tyleralt | 5:d7d16cb9c974 | 29 | offAngles[5] = 275; |
tyleralt | 5:d7d16cb9c974 | 30 | offAngles[6] = 145; |
tyleralt | 1:bb1507f0bb64 | 31 | offAngles[7] = 323; |
tyleralt | 5:d7d16cb9c974 | 32 | } |
tyleralt | 5:d7d16cb9c974 | 33 | |
tyleralt | 0:ded79d89abdf | 34 | int Point :: getArraySlice (void){ |
tyleralt | 5:d7d16cb9c974 | 35 | return ((positionRadian + offAngles[positionHeight])%360); |
tyleralt | 5:d7d16cb9c974 | 36 | } |
tyleralt | 5:d7d16cb9c974 | 37 | int Point :: getDegree (void){ |
tyleralt | 5:d7d16cb9c974 | 38 | return positionRadian % 360; |
tyleralt | 0:ded79d89abdf | 39 | } |
tyleralt | 0:ded79d89abdf | 40 | char Point :: getIdentifyingChar(void){ |
tyleralt | 0:ded79d89abdf | 41 | return 0x01 << positionHeight; |
tyleralt | 0:ded79d89abdf | 42 | } |
tyleralt | 0:ded79d89abdf | 43 | int Point :: getPositionDistance(void){ |
tyleralt | 4:f1e33a234a74 | 44 | return positionDistance; |
tyleralt | 0:ded79d89abdf | 45 | } |
tyleralt | 0:ded79d89abdf | 46 | void Point :: moveUp(){ |
tyleralt | 0:ded79d89abdf | 47 | if (positionHeight < 7){ |
tyleralt | 0:ded79d89abdf | 48 | positionHeight ++; |
tyleralt | 0:ded79d89abdf | 49 | } |
tyleralt | 0:ded79d89abdf | 50 | } |
tyleralt | 0:ded79d89abdf | 51 | void Point :: moveDown(){ |
tyleralt | 0:ded79d89abdf | 52 | if(positionHeight > 0){ |
tyleralt | 0:ded79d89abdf | 53 | positionHeight --; |
tyleralt | 0:ded79d89abdf | 54 | } |
tyleralt | 0:ded79d89abdf | 55 | } |
tyleralt | 0:ded79d89abdf | 56 | void Point :: rotateRight(){ |
tyleralt | 0:ded79d89abdf | 57 | positionRadian = (positionRadian + 1) % 360; |
tyleralt | 0:ded79d89abdf | 58 | } |
tyleralt | 0:ded79d89abdf | 59 | void Point :: rotateLeft(){ |
tyleralt | 0:ded79d89abdf | 60 | positionRadian = (positionRadian - 1) % 360; |
tyleralt | 0:ded79d89abdf | 61 | } |
tyleralt | 0:ded79d89abdf | 62 | void Point :: moveIn(){ |
tyleralt | 0:ded79d89abdf | 63 | if (positionDistance > 0){ |
tyleralt | 0:ded79d89abdf | 64 | positionDistance --; |
tyleralt | 0:ded79d89abdf | 65 | } |
tyleralt | 0:ded79d89abdf | 66 | } |
tyleralt | 0:ded79d89abdf | 67 | void Point :: moveOut(){ |
tyleralt | 0:ded79d89abdf | 68 | if (positionDistance < 15){ |
tyleralt | 0:ded79d89abdf | 69 | positionDistance ++; |
tyleralt | 0:ded79d89abdf | 70 | } |
tyleralt | 0:ded79d89abdf | 71 | } |