3d-render/src/object/point.cpp

31 lines
857 B
C++
Raw Normal View History

2025-10-09 21:33:37 +02:00
#include "point.h"
#include <string>
2025-10-10 10:21:36 +02:00
Point::Point(std::string& txt) {
if (txt != "") {
size_t pos = 0;
2025-10-09 21:33:37 +02:00
2025-10-10 10:21:36 +02:00
while ((pos = txt.find(",")) != std::string::npos) {
this->xyz.push_back(new float(std::stof(txt.substr(0, pos))));
txt.erase(0, pos + 1);
}
this->xyz.push_back(new float(std::stof(txt)));
}
if (this->xyz.size() != 3) {
this->xyz = {new float(0), new float(0), new float(0)};
}
2025-10-10 15:32:57 +02:00
2025-10-09 21:33:37 +02:00
}
2025-10-10 10:21:36 +02:00
uint16_t Point::translate3D() { return 0; }
2025-10-09 21:33:37 +02:00
float Point::getX() { return (*this->xyz.at(0)); }
float Point::getY() { return (*this->xyz.at(1)); }
float Point::getZ() { return (*this->xyz.at(2)); }
std::ostream & operator<<(std::ostream& os, Point& p){
2025-10-10 15:32:57 +02:00
os << " - *Point " << &p << "*: *X*: " << p.getX() << ", *Y*: "<< p.getY() << ", *Z*: "<< p.getZ() << std::endl;
2025-10-09 21:33:37 +02:00
return os;
}