ELEC2645 (2018/19) / Mbed 2 deprecated el17cd

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Face.cpp Source File

Face.cpp

00001 #ifndef FACE_H
00002 #define FACE_H
00003 #include "Face.h"
00004 #endif
00005 
00006 Face::Face() {
00007     visible = false; //Each instantiated face is not visible by default
00008 }
00009 
00010 bool Face::getVisible() { //Accessor returns whether the face is visible
00011     return visible;
00012 }
00013 
00014 
00015 void Face::setVisible(bool v) { //Mutator sets whether the face is visible or not
00016     visible = v;
00017 }
00018 
00019 void Face::setVerticies(float (&PointArray)[4][3]) { //Sets the verticies of the face to their xyz coordinate
00020     float z = 0;
00021     for(int vertex = 0; vertex < 4; vertex++) {
00022         for(int axis = 0; axis < 3; axis++) {
00023             verticies[vertex][axis] = PointArray[vertex][axis]; //copies the parameter to the private array
00024         }
00025         z += verticies[vertex][2];
00026     }
00027     avgZ = z/4; //store an average z axis value for each face
00028 }
00029 
00030 float Face::getVertexValue(int vertex, int axis){ //Accessor to return the value of a vertex depending on the index and axis
00031     return verticies[vertex][axis];
00032 }
00033 
00034 float Face::getAvgZ(){ //Accessor to return the average z value of the face
00035     return avgZ;
00036 }