51NOD1265(四点共面)
来源:互联网 发布:windows tts 语音库 编辑:程序博客网 时间:2024/04/30 12:01
题目链接:点击打开链接
解题思路:
判断四点共面,先求出三点构成的平面的法向量(叉积),如果第四个点和前三点任意一点构成的向量与平面法向量垂直(点积为0),则四点共面.
回忆下叉积和点积.对于三位空间向量,叉积公式为
=(),=(),a×b=(-)i+(-)j+(-)k,写成行列式形式 .点积公式为
和 , x1 * x2 + y1 * y2,自行扩展至三维.完整代码:
#include <algorithm>#include <iostream>#include <cstring>#include <climits>#include <cstdio>#include <string>#include <cmath>#include <set>#include <queue>#include <map>#include <vector>#include <cstdlib>#include <stack>#include <time.h>using namespace std;typedef long long LL;const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = acos(-1.0); //M_PI;const int maxn = 100001;class Point_3{public: double x , y , z; Point_3() {} Point_3(double xx , double yy , double zz) : x(xx) , y(yy) , z(zz) {} void input() { scanf("%lf%lf%lf",&x,&y,&z); } friend Point_3 operator - (const Point_3 &a , const Point_3 &b) { return Point_3(a.x - b.x , a.y - b.y , a.z - b.z); }};Point_3 det(const Point_3 &a , const Point_3 &b){ return Point_3(a.y * b.z - a.z * b.y , a.z *b.x - a.x * b.z , a.x * b.y - a.y * b.x);}double dot(const Point_3 &a , const Point_3 &b){ return a.x * b.x + a.y * b.y + a.z * b.z;}Point_3 pvec(Point_3 &s1 , Point_3 &s2 , Point_3 s3){ return det((s1 - s2) , (s2 - s3));}bool zreo(double x){ return fabs(x) < EPS;}int dots_onplane(Point_3 a , Point_3 b , Point_3 c , Point_3 d ){ return zreo(dot(pvec(a , b , c ) , d - a));}int main(){#ifdef DoubleQ freopen("in.txt","r",stdin);#endif int T; scanf("%d",&T); while(T--) { Point_3 a , b , c , d; a.input(); b.input(); c.input(); d.input(); if(dots_onplane(a , b , c , d)) printf("Yes\n"); else printf("No\n"); } return 0;}/*************************************************** Copyright By DoubleQ* Written in 2015* Blog Address : zhanghe.ac.cn* http://blog.csdn.net/u013447865* Email Address: acmer_doubleq@qq.com**************************************************/
0 0
- 51NOD1265(四点共面)
- 51nod1265四点共面
- 51nod1265 四点共面
- 51nod1265判断四点共面
- 【51nod1265】—四点共面
- 51nod_1265 四点共面
- 51nod 1265 四点共面
- 51NOD 1265 四点共面
- 51 nod 1265 四点共面
- [51nod]1265 四点共面
- 51nod 1265 四点共面
- 51NOD-1265四点共面
- 51nod 1265 四点共面
- 51nod 1265 四点共面
- 51nod 四点共面(数学)
- 51nod 1265 四点共面
- 51Nod 1265 四点共面
- 51Nod 1265 四点共面
- 将上传文件添加到数据库
- 短信拒绝服务漏洞
- x的平方根
- 关于闭包
- 分分钟学会一门语言之Python篇
- 51NOD1265(四点共面)
- 算法导论之2.3-7练习题
- 以太网OAM技术介绍 http://blog.chinaunix.net/uid-113269-id-267427.html
- Spring AOP的底层实现技术
- 协同过滤工具推荐
- hadoop 读书笔记(1)
- 2.11 行列式
- Java-ServletRequestListener-ServletRequestAttributeListener
- 【FastDev4Android框架开发】Android 列表下拉刷新组件PullToRefreshListView使用(三)