Bzoj 1964:hull Three-dimensional convex hull calculation geometry

Source: Internet
Author: User

1964:hull three-dimensional convex package time limit:1 Sec Memory limit:64 MB
submit:54 solved:39
[Submit] [Status] [Discuss] Description three-dimensional convex hull problem is a basic three-dimensional computational geometry problem, but this time you only need to do a simple version of the three-dimensional convex hull problem on the line. Input data has a total of several lines, three integers per line, representing the coordinates of a point. The number of points is five. Output outputs a real number that retains two decimal places representing the volume of the three-dimensional convex hull. Sample Input0 0 0
2 0 0
0 2 0
2 2 0
1 1 1
Sample Output1.33
HINT

For all data, the coordinate range is [0,100]*[0,100]*[0,100].

Direct water over, but the three-dimensional convex package on-line one than an unreliable, by a set of data shot out, plus my program, three programs three answers. The whole person is not good.

Enumerates a polygon so that the remaining two points are different from the forward volume symbol of the tetrahedron, then two points are calculated on both sides of the polygon.

The tetrahedron formula is a three-vector matrix determinant of 1/6.

This is actually my first three-dimensional calculation several questions.

#include <iostream>#include<cstring>#include<algorithm>#include<cstdio>#include<cmath>using namespacestd;#defineMAXN 10typedefDoubleReal;structpoint{real x, y, Z; Point (real x,real y,real z): X (x), Y (y), Z (z) {} point () {}voidRead () {scanf ("%lf%lf%lf",&x,&y,&z); }}PL[MAXN];; Real area (point P1,point p2,point p3) {return(p1.x*p2.y*p3.z + p1.z*p2.x*p3.y + p1.y*p2.z*p3.x-P1.X*P2.Z*P3.Y-P1.Z*P2.Y*P3.X-P1.Y*P2.X*P3.Z)/6;} Pointoperator-(Point p1,point p2) {returnPoint (p2.x-p1.x,p2.y-p1.y,p2.z-p1.z);} typedef Point Line;BOOLVIS[MAXN];intMain () {Freopen ("Input.txt","R", stdin);  for(intI=0;i<5; i++) {pl[i].read (); }//printf ("%.2lf\n", Area (Pl[1]-pl[0],pl[2]-pl[0],pl[3]-pl[0]));Real ans=0;        Real S1,S2,S3;  for(intA=0;a<5; a++) {Vis[a]=true;  for(intb=0;b<5; b++)                {                        if(Vis[b])Continue; VIS[B]=true;  for(intC=0;c<5; C + +)                        {                                if(Vis[c])Continue; VIS[C]=true;  for(intD=0;d <5;d + +)                                {                                        if(Vis[d])Continue; VIS[D]=true;  for(intE=0;e<5; e++)                                        {                                                if(Vis[e])Continue; Vis[e]=true; S3=abs (S1=area (pl[c]-pl[a],pl[b]-pl[a],pl[d]-pl[a)) +abs (S2=area (pl[c]-pl[a],pl[b]-pl[a],pl[e]-Pl[a])); if(s1*s2>0) {Vis[e]=false;Continue; }                                                if(s1==0&& s2==0) {Vis[e]=false;Continue; } ans=Max (ANS,S3); Vis[e]=false; } Vis[d]=false; } Vis[c]=false; } Vis[b]=false; } Vis[a]=false; } printf ("%.2lf\n", ans);}

Bzoj 1964:hull Three-dimensional convex hull calculation geometry

Related Article

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.