number3d.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
  2. /*
  3. * number3d.cc
  4. * Copyright (C) 2016 Fran??ois Gautrais <francois@gautrais.eu>
  5. *
  6. * histodex is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * histodex is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "number3d.h"
  20. #include "utils.h"
  21. Number3d::Number3d(double x, double y, double z)
  22. {
  23. m_x=x;
  24. m_y=y;
  25. m_z=z;
  26. }
  27. Number3d::~Number3d()
  28. {
  29. }
  30. const Number3d& Number3d::operator=(const Number3d& a)
  31. {
  32. m_x=a.m_x;
  33. m_y=a.m_y;
  34. m_z=a.m_z;
  35. }
  36. Number3d::Number3d(Json::Value& v)
  37. {
  38. m_x = v[0].asDouble();
  39. m_y = v[1].asDouble();
  40. m_z = v[2].asDouble();
  41. }
  42. Json::Value Number3d::getJson()
  43. {
  44. Json::Value v(Json::arrayValue);
  45. v[0] = m_x;
  46. v[1] = m_y;
  47. v[2] = m_z;
  48. return v;
  49. }
  50. std::string Number3d::toString()
  51. {
  52. std::string x = "(";
  53. return x+tstr(m_x)+", "+tstr(m_y)+", "+tstr(m_z)+")";
  54. }