分析
四个点组成三个向量,若三个向量混合积为0,则证明向量共面。
abc混合积:https://baike.baidu.com/item/混合积/10564182?fr=aladdin
即为:(a 叉乘 b) 点乘 c == 0
混合积可以用行列式来计算
[a.x a.y a.z]
[b.x b.y b.z]
[c.x c.y c.z]
#include <bits/stdc++.h>
#pragma GCC diagnostic error "-std=c++11"
#define d(x) cout << (x) << endl
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 14;
struct point
{
double x, y, z;
point(double x, double y, double z):x(x),y(y),z(z){}
point(){
scanf("%lf%lf%lf", &x, &y, &z);
}
};
point operator - (point a, point b)
{
return point(a.x - b.x, a.y - b.y, a.z - b.z);
}
int solve(point a, point b, point c)
{
return a.y * b.x * c.z + a.x * c.y * b.z + a.z * b.y * c.x - b.x * c.y * a.z - a.y * b.z * c.x - a.x * b.y * c.z;
}
int main()
{
int t;
for(cin >> t; t; t--){
point a = point();
point b = point();
point c = point();
point d = point();
point A = b - a;
point B = c - a;
point C = d - a;
if(solve(A, B, C) == 0){
d("Yes");
}else{
d("No");
}
}
return 0;
}