This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/grid/GridPoint.h
kazu cdf97322f8 added new data-structures
added new test-cases
added flexible dijkstra calculation
added debugging log
modified: plotting, grid-generation, grid-importance,
refactoring
2016-01-22 18:47:06 +01:00

49 lines
1.1 KiB
C++
Executable File

#ifndef GRIDPOINT_H
#define GRIDPOINT_H
#include <cmath>
#include "../geo/Point3.h"
struct GridPoint {
/** x-position (in centimeter) */
float x_cm;
/** y-position (in centimeter) */
float y_cm;
/** z-position (in centimeter) */
float z_cm;
/** empty ctor */
GridPoint() : x_cm(0), y_cm(0), z_cm(0) {;}
/** ctor */
GridPoint(const float x_cm, const float y_cm, const float z_cm) : x_cm(x_cm), y_cm(y_cm), z_cm(z_cm) {;}
/** equal? */
bool operator == (const GridPoint& o) const {
return x_cm == o.x_cm && y_cm == o.y_cm && z_cm == o.z_cm;
}
/** get the distance (in meter) betwen this and the given point */
float getDistanceInMeter(const GridPoint& other) const {
const int dx = x_cm - other.x_cm;
const int dy = y_cm - other.y_cm;
const int dz = z_cm - other.z_cm;
return std::sqrt(dx*dx + dy*dy + dz*dz) / 100.0f;
}
/** cast to Point3 */
operator Point3() const {return Point3(x_cm, y_cm, z_cm);}
/** cast to string */
operator std::string() const {return "(" + std::to_string(x_cm) + "," + std::to_string(y_cm) + "," + std::to_string(z_cm) + ")";}
};
#endif // GRIDPOINT_H