Test
2009年1月6号晚23时:
Test:
1//以下代码纯为测试,无它用
2#include "Triangle.h"
3
4Triangle::Triangle(double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3)
5{
6 this->x1 = x1,this->y1 = y1,this->z1 = z1;
7 this->x2 = x2,this->y2 = y2,this->z2 = z2;
8 this->x3 = x3,this->y3 = y3,this->z3 = z3;
9
10 a = (y2-y3)*(z1-z3)-(y1-y3)*(z2-z3);
11 b = (x1-x3)*(z2-z3)-(x2-x3)*(z1-z3);
12 c = (x2-x3)*(y1-y3)-(x1-x3)*(y2-y3);
13 d = -(a*x1+b*y1+c*z1);
14
15 dy = setdy();
16 ymax = setymax();
17}
18
19int Triangle::setdy()
20{
21 double max,min;
22 int dy;
23 if(y1 >= y2&&y1 >= y3)
24 max = y1;
25 else if(y2 >=y1&&y2>=y3)
26 max = y2;
27 else if(y3>=y1&&y3>=y2)
28 max = y3;
29 if(y1<=y2&&y1<=y3)
30 min = y1;
31 else if(y2<=y3&&y2<=y1)
32 min = y2;
33 else if(y3<=y1&&y3<=y2)
34 min = y3;
35 dy = max - min;
36 return dy;
37}
38
39int Triangle::setymax()
40{
41 int max;
42 if(y1 >= y2&&y1 >= y3)
43 max = y1;
44 else if(y2 >=y1&&y2>=y3)
45 max = y2;
46 else if(y3>=y1&&y3>=y2)
47 max = y3;
48 return max;
49}
2#include "Triangle.h"
3
4Triangle::Triangle(double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3)
5{
6 this->x1 = x1,this->y1 = y1,this->z1 = z1;
7 this->x2 = x2,this->y2 = y2,this->z2 = z2;
8 this->x3 = x3,this->y3 = y3,this->z3 = z3;
9
10 a = (y2-y3)*(z1-z3)-(y1-y3)*(z2-z3);
11 b = (x1-x3)*(z2-z3)-(x2-x3)*(z1-z3);
12 c = (x2-x3)*(y1-y3)-(x1-x3)*(y2-y3);
13 d = -(a*x1+b*y1+c*z1);
14
15 dy = setdy();
16 ymax = setymax();
17}
18
19int Triangle::setdy()
20{
21 double max,min;
22 int dy;
23 if(y1 >= y2&&y1 >= y3)
24 max = y1;
25 else if(y2 >=y1&&y2>=y3)
26 max = y2;
27 else if(y3>=y1&&y3>=y2)
28 max = y3;
29 if(y1<=y2&&y1<=y3)
30 min = y1;
31 else if(y2<=y3&&y2<=y1)
32 min = y2;
33 else if(y3<=y1&&y3<=y2)
34 min = y3;
35 dy = max - min;
36 return dy;
37}
38
39int Triangle::setymax()
40{
41 int max;
42 if(y1 >= y2&&y1 >= y3)
43 max = y1;
44 else if(y2 >=y1&&y2>=y3)
45 max = y2;
46 else if(y3>=y1&&y3>=y2)
47 max = y3;
48 return max;
49}
我没有什么雄心壮志,我只想给自己和关心自己的家人和朋友一个交代,仅此而已。