worked on floorplan (v2)
worked on grid-generation (v2) new helper methods for geometry new test cases
This commit is contained in:
33
geo/Point3.h
33
geo/Point3.h
@@ -21,6 +21,8 @@ struct Point3 {
|
||||
Point3(const float x, const float y, const float z) : x(x), y(y), z(z) {;}
|
||||
|
||||
|
||||
Point3 operator - () const {return Point3(-x, -y, -z);}
|
||||
|
||||
|
||||
Point3 operator + (const Point3& o) const {return Point3(x+o.x, y+o.y, z+o.z);}
|
||||
|
||||
@@ -37,19 +39,43 @@ struct Point3 {
|
||||
|
||||
Point3& operator /= (const float v) {x/=v; y/=v; z/=v; return *this;}
|
||||
|
||||
|
||||
Point3& operator += (const Point3& o) {x+=o.x; y+=o.y; z+=o.z; return *this;}
|
||||
|
||||
Point3& operator -= (const Point3& o) {x-=o.x; y-=o.y; z-=o.z; return *this;}
|
||||
|
||||
Point3& operator *= (const Point3& o) {x*=o.x; y*=o.y; z*=o.z; return *this;}
|
||||
|
||||
Point3& operator /= (const Point3& o) {x/=o.x; y/=o.y; z/=o.z; return *this;}
|
||||
|
||||
|
||||
bool operator < (const Point3& o) const {return x<o.x && y<o.y && z<o.z;}
|
||||
|
||||
bool operator == (const Point3& o) const {return x==o.x && y==o.y && z==o.z;}
|
||||
|
||||
bool operator != (const Point3& o) const {return x!=o.x || y!=o.y || z!=o.z;}
|
||||
bool operator != (const Point3& o) const {return x!=o.x || y!=o.y || z!=o.z;}
|
||||
|
||||
bool eq (const Point3& o, const float delta) const { return eq(x,o.x,delta) && eq(y,o.y,delta) && eq(z,o.z,delta); }
|
||||
|
||||
|
||||
Point2 xy() const {return Point2(x,y);}
|
||||
|
||||
|
||||
Point3 rotX(const float r) const {
|
||||
return Point3(x, y*cos(r) - z*sin(r), y*sin(r) + z*cos(r));
|
||||
}
|
||||
Point3 rotY(const float r) const {
|
||||
return Point3(z*sin(r) + x*cos(r), y, z*cos(r) - x*sin(r));
|
||||
}
|
||||
Point3 rotZ(const float r) const {
|
||||
return Point3(x*cos(r) - y*sin(r), x*sin(r) + y*cos(r), z);
|
||||
}
|
||||
Point3 rot(const float rx, const float ry, const float rz) const {
|
||||
return rotX(rx).rotY(ry).rotZ(rz);
|
||||
//return rotZ(rz).rotY(ry).rotX(rx);
|
||||
}
|
||||
|
||||
|
||||
/** read-only array access */
|
||||
float operator [] (const int idx) const {
|
||||
Assert::isBetween(idx, 0, 2, "index out of bounds");
|
||||
@@ -76,6 +102,11 @@ struct Point3 {
|
||||
), 1.0f/norm);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static inline bool eq(const float a, const float b, const float delta) {return std::abs(a-b) <= delta;}
|
||||
static inline bool ne(const float a, const float b, const float delta) {return std::abs(a-b) > delta;}
|
||||
|
||||
};
|
||||
|
||||
#endif // POINT3_H
|
||||
|
||||
Reference in New Issue
Block a user