-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeometry_3d.cpp
67 lines (54 loc) · 1.27 KB
/
geometry_3d.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// iran
#include <bits/stdc++.h>
using namespace std;
constexpr double EPS = 1e-10;
struct Point {
double x, y, z;
Point operator*(const int k) {
return {x * k, y * k, z * k};
}
Point operator+(const Point& rhs) {
return {x + rhs.x, y + rhs.y, z + rhs.z};
}
Point operator-(const Point& rhs) {
return {x - rhs.x, y - rhs.y, z - rhs.z};
}
bool operator==(const Point& rhs) {
return abs(x - rhs.x) < EPS && abs(y - rhs.y) < EPS && (z - rhs.z) < EPS;
}
};
struct Vector : Point {
double norm() {
return sqrt(x * x + y * y + z * z);
}
};
double dot(const Vector& lhs, const Vector& rhs) {
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
}
Vector cross(const Vector& lhs, const Vector& rhs) {
return {
lhs.y * rhs.z - lhs.z * rhs.y,
lhs.z * rhs.x - lhs.x * rhs.z,
lhs.x * rhs.y - lhs.y * rhs.x
};
}
double triple(const Vector& a, const Vector& b, const Vector& c) {
return dot(a, cross(b, c));
}
struct Line {
Point p;
Vector dir;
bool operator==(const Line rhs) {
}
};
struct Plane {
Point p;
Vector nor;
};
// 二点間のベクトル
// ベクトルの交点
// ベクトルと平面の交点
// 凸判定
// 体積
int main() {
}