判断空间四点共面

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;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值