//fzu1393
//题目意思:判断点是否在平面上
#include<cstdio>
#include<iostream>
#include<math.h>
#define eps 1e-8
struct Point3
{
double x,y,z;
};
struct Plane3
{
Point3 a,b,c;
};
Plane3 plane;
void input(Point3 &p)
{
scanf("%lf %lf %lf",&p.x,&p.y,&p.z);
}
Point3 xmult3(Point3 p1,Point3 p2)
{
Point3 ret;
ret.x=p1.y*p2.z-p1.z*p2.y;
ret.y=p1.z*p2.x-p2.z*p1.x;
ret.z=p1.x*p2.y-p1.y*p2.x;
return ret;
}
bool isOnit(Point3 p)
{
Point3 p1;
p1.x=plane.b.x-plane.a.x;
p1.y=plane.b.y-plane.a.y;
p1.z=plane.b.z-plane.a.z;
Point3 p2;
p2.x=plane.c.x-plane.a.x;
p2.y=plane.c.y-plane.a.y;
p2.z=plane.c.z-plane.a.z;
Point3 dir=xmult3(p1,p2);
if(fabs(dir.x*(p.x-plane.a.x)+dir.y*(p.y-plane.a.y)+dir.z*(p.z-plane.a.z))<eps)
return true;
else return false;
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
Point3 p;
input(plane.a);
input(plane.b);
input(plane.c);
input(p);
if(isOnit(p))printf("Yes\n");
else printf("No\n");
}
return 0;
}
fzu1393 点是否在平面上 简单三维几何
最新推荐文章于 2019-05-16 17:19:38 发布
本文介绍了一种通过计算向量叉乘来判断三维空间中一个点是否位于由三个顶点定义的平面上的方法。使用C++实现了一个简单的程序,该程序能够接收用户输入的三个顶点坐标和平面上的一个待验证点的坐标,最后输出该点是否位于所定义的平面上。

1万+

被折叠的 条评论
为什么被折叠?



