Added overloads for to_string to handle xyz_heading, xyz_location, and xy_location

This commit is contained in:
Arthur Ice 2014-11-26 17:21:33 -08:00
parent 408fdc7178
commit f63c5ab6ba
2 changed files with 20 additions and 0 deletions

View File

@ -1,4 +1,6 @@
#include "position.h"
#include <string>
#include "../common/string_util.h"
xy_location::xy_location(float x, float y) :
m_X(x),
@ -104,3 +106,16 @@ void xyz_location::ABS_XYZ(void) {
if (m_Z < 0)
m_Z = -m_Z;
}
std::string to_string(const xyz_heading &position) {
return StringFormat("(%.3f, %.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z,position.m_Heading);
}
std::string to_string(const xyz_location &position){
return StringFormat("(%.3f, %.3f, %.3f)", position.m_X,position.m_Y,position.m_Z);
}
std::string to_string(const xy_location &position){
return StringFormat("(%.3f, %.3f)", position.m_X,position.m_Y);
}

View File

@ -18,6 +18,8 @@
#ifndef POSITION_H
#define POSITION_H
#include <string>
class xy_location {
public:
float m_X;
@ -76,5 +78,8 @@ public:
bool isOrigin() const { return m_X == 0.0f && m_Y == 0.0f && m_Z == 0.0f;}
};
std::string to_string(const xyz_heading &position);
std::string to_string(const xyz_location &position);
std::string to_string(const xy_location &position);
#endif