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.
Dependencies: mbed
Face/Face.cpp@24:4e8bdcb74266, 2019-04-03 (annotated)
- Committer:
- el17cd
- Date:
- Wed Apr 03 16:19:05 2019 +0000
- Revision:
- 24:4e8bdcb74266
- Parent:
- 22:236319885874
- Child:
- 32:9c250eda7f3f
Documented Face class
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17cd | 1:044238f7bdda | 1 | #include "mbed.h" |
| el17cd | 4:759a5c34e239 | 2 | #ifndef FACE_H |
| el17cd | 4:759a5c34e239 | 3 | #define FACE_H |
| el17cd | 1:044238f7bdda | 4 | #include "Face.h" |
| el17cd | 4:759a5c34e239 | 5 | #endif |
| el17cd | 1:044238f7bdda | 6 | |
| el17cd | 24:4e8bdcb74266 | 7 | Face::Face() { |
| el17cd | 24:4e8bdcb74266 | 8 | visible = false; //Each instantiated face is not visible by default |
| el17cd | 13:f4de03202477 | 9 | } |
| el17cd | 13:f4de03202477 | 10 | |
| el17cd | 24:4e8bdcb74266 | 11 | bool Face::getVisible() { //Accessor returns whether the face is visible |
| el17cd | 13:f4de03202477 | 12 | return visible; |
| el17cd | 4:759a5c34e239 | 13 | } |
| el17cd | 13:f4de03202477 | 14 | |
| el17cd | 13:f4de03202477 | 15 | |
| el17cd | 24:4e8bdcb74266 | 16 | void Face::setVisible(bool v) { //Mutator sets whether the face is visible or not |
| el17cd | 13:f4de03202477 | 17 | visible = v; |
| el17cd | 13:f4de03202477 | 18 | } |
| el17cd | 13:f4de03202477 | 19 | |
| el17cd | 24:4e8bdcb74266 | 20 | void Face::setVerticies(float (&PointArray)[4][3]) { //Sets the verticies of the face to their xyz coordinate |
| el17cd | 17:3c9672c6e532 | 21 | float z = 0; |
| el17cd | 24:4e8bdcb74266 | 22 | for(int vertex = 0; vertex < 4; vertex++) { |
| el17cd | 24:4e8bdcb74266 | 23 | for(int axis = 0; axis < 3; axis++) { |
| el17cd | 24:4e8bdcb74266 | 24 | verticies[vertex][axis] = PointArray[vertex][axis]; //copies the parameter to the private array |
| el17cd | 1:044238f7bdda | 25 | } |
| el17cd | 10:07a23afd5088 | 26 | z += verticies[vertex][2]; |
| el17cd | 1:044238f7bdda | 27 | } |
| el17cd | 24:4e8bdcb74266 | 28 | avgZ = z/4; //store an average z axis value for each face |
| el17cd | 1:044238f7bdda | 29 | } |
| el17cd | 4:759a5c34e239 | 30 | |
| el17cd | 24:4e8bdcb74266 | 31 | float Face::getVertexValue(int vertex, int axis){ //Accessor to return the value of a vertex depending on the index and axis |
| el17cd | 1:044238f7bdda | 32 | return verticies[vertex][axis]; |
| el17cd | 9:5915fc800824 | 33 | } |
| el17cd | 9:5915fc800824 | 34 | |
| el17cd | 24:4e8bdcb74266 | 35 | float Face::getAvgZ(){ //Accessor to return the average z value of the face |
| el17cd | 9:5915fc800824 | 36 | return avgZ; |
| el17cd | 1:044238f7bdda | 37 | } |