coordinates
coordinates.cpp
- Committer:
- firstsignupoftheweek
- Date:
- 2019-07-03
- Revision:
- 0:95200a539562
File content as of revision 0:95200a539562:
#include "mbed.h" #include "coordinates.h" #include <vector> Coordinates::Coordinates(){ //constructor xpos = 0; ypos = 0; restdistY = 0.0; restdistX = 0.0; } void Coordinates::increaseY(){ ypos+= 1; } void Coordinates::decreaseY(){ ypos-=1; } void Coordinates::increaseX(){ xpos+= 1; } void Coordinates::decreaseX(){ xpos-=1; } int Coordinates::getY(){ return ypos; } int Coordinates::getX(){ return xpos; } double Coordinates::getYdist(){ return (ypos*stepsize)+restdistY; //zet coordinaat om naar cm in y-as, voeg daar de overige cm aan toe } double Coordinates::getXdist(){ return (xpos*stepsize)+restdistX; } void Coordinates::distToY(double dist){ printf("Dist: %f\n", dist); dist += restdistY; printf("newDist: %f\n", dist); int partdist = int(dist/stepsize); printf("partdist: %i\n", partdist); restdistY = dist - partdist*stepsize; printf("restdist: %f\n", restdistY); ypos += partdist; } void Coordinates::distToX(double dist){ printf("Dist: %f\n", dist); dist += restdistX; printf("newDist: %f\n", dist); int partdist = int(dist/stepsize); printf("partdist: %i\n", partdist); restdistX = dist - partdist*stepsize; printf("restdist: %f\n", restdistX); xpos += partdist; }