判断四点共面模版、
2016-08-30 21:54
141 查看
采用混合积的方式判断四点是否共面、
混合积资料:传送门
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cmath>
using namespace std;
struct Point{
double x,y,z;
Point operator - (const Point &a){
Point tmp;
tmp.x = x - a.x;
tmp.y = y - a.y;
tmp.z = z - a.z;
return tmp;
}
}point[5];
Point Cross_product(Point a, Point b){
Point tmp;
tmp.x = a.y*b.z-a.z*b.y;
tmp.y = a.z*b.x-b.z*a.x;
tmp.z = a.x*b.y-a.y*b.x;
return tmp;
}
double Dot_product(Point a, Point b){
Point tmp;
tmp.x = a.x*b.x;
tmp.y = a.y*b.y;
tmp.z = a.z*b.z;
return tmp.x+tmp.y+tmp.z;
}
int main(){
int t;scanf("%d",&t);
while(t--){
for(int i=0; i<4; ++i)
scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].z);
puts(Dot_product(point[3]-point[0], Cross_product(point[1]-point[0], point[2]-point[0]))==0.0?"Yes":"No");
}
return 0;
}
混合积资料:传送门
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cmath>
using namespace std;
struct Point{
double x,y,z;
Point operator - (const Point &a){
Point tmp;
tmp.x = x - a.x;
tmp.y = y - a.y;
tmp.z = z - a.z;
return tmp;
}
}point[5];
Point Cross_product(Point a, Point b){
Point tmp;
tmp.x = a.y*b.z-a.z*b.y;
tmp.y = a.z*b.x-b.z*a.x;
tmp.z = a.x*b.y-a.y*b.x;
return tmp;
}
double Dot_product(Point a, Point b){
Point tmp;
tmp.x = a.x*b.x;
tmp.y = a.y*b.y;
tmp.z = a.z*b.z;
return tmp.x+tmp.y+tmp.z;
}
int main(){
int t;scanf("%d",&t);
while(t--){
for(int i=0; i<4; ++i)
scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].z);
puts(Dot_product(point[3]-point[0], Cross_product(point[1]-point[0], point[2]-point[0]))==0.0?"Yes":"No");
}
return 0;
}
相关文章推荐
- 判断四点共面
- 判断四点共面
- 51Nod - 1265 四点共面 (叉积判断)
- 51nod1265判断四点共面
- HDU5839-Special Tetrahedron(判断四点共面,叉乘求平面垂直向量)
- 判断四点共面
- hdoj 5839 Special Tetrahedron 叉积点积判断四点共面模板
- 计算几何初步——共面判断(FZU1393)
- [51nod]1265 四点共面
- 51nod--1265 四点共面 (计算几何基础, 点积, 叉积)
- 判断四个点是否共面
- 【51Nod】1265 - 四点共面(行列式 & 数论)
- (几何)51Nod - 1265 四点共面
- 已知两线段的四点坐标,如何判断两线段是否相交的思路
- js模版引擎handlebars.js实用教程——if-判断的基本用法
- 四点判断能否围成矩形
- 1265 四点共面
- 51nod 1265 四点共面(判四点共面)
- 数学公式——判断三向量是否共面
- 51nod 四点共面(数学)