fzu1393 点是否在平面上 简单三维几何

 

 

//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;
	
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值