1:利用四点坐标计算三个向量(a1, b1, c1), (a2, b2, c2), (a3, b3, c3)
2:利用行列式判断,若行列式结果为0则四点共面(共线情况也包含了)
|a1 a2 a3|
|b1 b2 b3| = a1b2c3 - a1b3c2 - a2b1c3 + a2b3c1 + a3b1c2 - a3b2c1
|c1 c2 c3|
本文转自http://www.cnblogs.com/AndyJee/p/3491487.html
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define PI acos(-1)
#define fs first
#define sc second
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int mod = 1000000007;
int main(){
double x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3;
double a1, a2, a3, b1, b2, b3, c1, c2, c3;
int t;
cin>>t;
while(t--)
{
cin>>x1>>y1>>z1>>x2>>y2>>z2;
a1 = x2 - x1;
b1 = y2 - y1;
c1 = z2 - z1;
cin>>x2>>y2>>z2;
a2 = x2 - x1;
b2 = y2 - y1;
c2 = z2 - z1;
cin>>x2>>y2>>z2;
a3 = x2 - x1;
b3 = y2 - y1;
c3 = z2 - z1;
if((a1*b2*c3 - a1*b3*c2 - a2*b1*c3 + a2*b3*c1 + a3*b1*c2 - a3*b2*c1) == 0)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}