Determine four common points

Source: Internet
Author: User
1265. four-point common reference time limit: 1 second space limit: 65536 kb score: 0 gives four points in three-dimensional space (points and points are not the same ), determine whether the four vertices are in the same plane (the four vertices are collocated ). If it is a common area, "yes" is output; otherwise, "no" is output ". Input
Row 1st: A number t, indicating the number of input tests (1 <= T <= 1000) 2nd-4 t + 1 rows: 4 rows in each row indicates a group of data, the three numbers in each row, x, y, and z, indicate the coordinates of the point (-1000 <= x, y, z <= 1000 ).
Output
T rows are output. If yes is output, no is output ".
Input example
11 2 02 3 04 0 00 0 0
Output example
Yes

// Train of thought: create three vectors from four points to form a determinant. If the value of the determinant is 0, it is a common area.

How to calculate the level 3 determinant :.[28]

#include<cstdio>struct point{    int x,y,z;}p[1001];int main(){    int t,i,ans;    point s1,s2,s3;    scanf("%d",&t);    while(t--)    {        for(i=0;i<4;i++)        scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z);        s1.x=p[1].x-p[0].x;s1.y=p[1].y-p[0].y;s1.z=p[1].z-p[0].z;        s2.x=p[2].x-p[0].x;s2.y=p[2].y-p[0].y;s2.z=p[2].z-p[0].z;        s3.x=p[3].x-p[0].x;s3.y=p[3].y-p[0].y;s3.z=p[3].z-p[0].z;        ans=s1.x*s2.y*s3.z+s1.y*s2.z*s3.x+s1.z*s2.x*s3.y-s1.z*s2.y*s3.x-s1.x*s2.z*s3.y-s1.y*s2.x*s3.z;        if(ans==0) printf("Yes\n");        else printf("No\n");    }    return 0;}



 

Determine four common points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.