Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Point {
- float x;
- float y;
- float z;
- Point operator - (const Point& other) const {
- return { x - other.x, y - other.y, z - other.z };
- }
- };
- struct Eq {
- float a;
- float b;
- float c;
- float d;
- Eq() {}
- Eq(float a, float b, float c, float d) : a(a), b(b), c(c), d(d) {}
- Eq(const Point& A, const Point& B, const Point& C) {
- Point v1 = B - A;
- Point v2 = C - A;
- Point norm = { v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x };
- a = norm.x;
- b = norm.y;
- c = norm.z;
- d = -(norm.x * A.x + norm.y * A.y + norm.z * A.z);
- }
- float operator () (const Point& p) {
- float ans = (a * p.x + b * p.y + c * p.z + d) / sqrt(a * a + b * b + c * c);
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement