Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- struct Vector
- {
- float x,y,z;
- Vector() : Vector(0,0,0) {}
- Vector(float a, float b, float c) : x(a), y(b), z(c){}
- Vector operator/(float var)
- {
- return var == 0? Vector(0,0,0): Vector(x/var,y/var,z/var);
- }
- Vector operator-(const Vector& input)
- {
- return Vector(x-input.x, y-input.y, z-input.z);
- }
- float Length()
- {
- return sqrt(x*x+y*y+z*z);
- }
- };
- struct coord
- {
- float x,y,z;
- Vector ToVector()
- {
- return Vector(x,y,z);
- }
- coord() : coord(Vector(0,0,0)) {}
- coord(float a, float b, float c) : x(a), y(b), z(c) {}
- coord(Vector d) : x(d.x), y(d.y), z(d.z){}
- bool operator<(const coord& input)
- {
- if(x != input.x)
- return x < input.x;
- else if(y != input.y)
- return y < input.y;
- else return z < input.z;
- }
- };
- std::ostream& operator<<(std::ostream& os, const coord& input)
- {
- os<<input.x<<" "<<input.y<<" "<<input.z;
- return os;
- }
- std::ostream& operator<<(std::ostream& os, const Vector& input)
- {
- os<<input.x<<" "<<input.y<<" "<<input.z;
- return os;
- }
- int main()
- {
- std::vector<coord> positions;
- coord tmp;
- while(std::cin>>tmp.x>>tmp.y>>tmp.z)
- positions.push_back(tmp);
- std::cout<<"Points before: "<<positions.size()<<std::endl;
- for(int i=0;i<positions.size()-1;i++)
- {
- auto beg = positions[i].ToVector();
- for(int j = i+1; j < positions.size(); j++)
- {
- if((beg-positions[j].ToVector()).Length() < 50)
- {
- positions[j].x = 0.0f;
- positions[j].y = 0.0f;
- positions[j].z = 0.0f;
- }
- }
- auto it = std::remove_if(positions.begin(),positions.end(),[](coord& input){return input.x == 0.0f && input.y == 0.0f && input.z == 0.0f;});
- positions.erase(it, positions.end());
- }
- std::cout<<"Points after: "<<positions.size();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement