1 #include <iostream> 2 #include <stdlib.h> 3 #include <orocos_kdl/src/frames.hpp> 4 #include <cstring> 5 using namespace std; 6 using namespace KDL; 7 class abc 8 {public: 9 char name[20]; 10 int m; 11 Vector2 point[3]; 12 abc() 13 { 14 for(int i=0;i<20;i++)name[i]=0; 15 m=0; 16 } 17 }; 18 int main() 19 { 20 char i,j; 21 char a[3][20]; 22 char b[6][10]; 23 double c[6]={0,0,0,0,0,0}; 24 char d[3][20]; 25 char e[2][10]; 26 double f[2]; 27 cout<<"请输入 "; 28 abc p; 29 cin>>p.name; 30 cin>>p.m; 31 switch(p.m) 32 { 33 case 1: 34 { 35 cin>>a[0]; 36 for(i=1;i<=10&&a[0][i]!=',';i++)b[0][i-1]=a[0][i]; 37 for(j=0,i++;j<10&&a[0][i]!=')';i++,j++)b[1][j]=a[0][i]; 38 c[0]=atof(b[0]);c[1]=atof(b[1]); 39 p.point[0]= (Vector2(c[0],c[1])); 40 } 41 break; 42 case 2: 43 { 44 cin>>a[0]; 45 cin>>a[1]; 46 for(i=1;i<=10&&a[0][i]!=',';i++)b[0][i-1]=a[0][i]; 47 for(j=0,i++;j<10&&a[0][i]!=')';i++,j++)b[1][j]=a[0][i]; 48 for(i=1;i<=10&&a[1][i]!=',';i++)b[2][i-1]=a[1][i]; 49 for(j=0,i++;j<10&&a[1][i]!=')';i++,j++)b[3][j]=a[1][i]; 50 c[0]=atof(b[0]);c[1]=atof(b[1]); 51 c[2]=atof(b[2]);c[3]=atof(b[3]); 52 p.point[0]= (Vector2(c[0],c[1])); 53 p.point[1]= (Vector2(c[2],c[3])); 54 } 55 break; 56 case 3: 57 { 58 cin>>a[0]; 59 cin>>a[1]; 60 cin>>a[2]; 61 for(i=1;i<=10&&a[0][i]!=',';i++)b[0][i-1]=a[0][i]; 62 for(j=0,i++;j<10&&a[0][i]!=')';i++,j++)b[1][j]=a[0][i]; 63 for(i=1;i<=10&&a[1][i]!=',';i++)b[2][i-1]=a[1][i]; 64 for(j=0,i++;j<10&&a[1][i]!=')';i++,j++)b[3][j]=a[1][i]; 65 for(i=1;i<=10&&a[2][i]!=',';i++)b[4][i-1]=a[2][i]; 66 for(j=0,i++;j<10&&a[2][i]!=')';i++,j++)b[5][j]=a[2][i]; 67 c[0]=atof(b[0]);c[1]=atof(b[1]); 68 c[2]=atof(b[2]);c[3]=atof(b[3]); 69 c[4]=atof(b[4]);c[5]=atof(b[5]); 70 p.point[0]= (Vector2(c[0],c[1])); 71 p.point[1]= (Vector2(c[2],c[3])); 72 p.point[2]= (Vector2(c[4],c[5])); 73 } 74 break; 75 default:cout<<"Error"; 76 } 77 for(int k=0;k<20;k++)d[0][k]=0; 78 cin>>d[0]; 79 if(d[0][0]=='m'&&d[0][1]=='o'&&d[0][2]=='v'&&d[0][3]=='e'&&d[0][4]==0) 80 { 81 for(int k=0;k<20;k++)d[1][k]=0; 82 cin>>d[1]; 83 if(!strcmp(d[1],p.name)) 84 { 85 cin>>d[2]; 86 for(i=1;i<=10&&d[2][i]!=',';i++)e[0][i-1]=d[2][i]; 87 for(j=0,i++;j<10&&d[2][i]!=')';i++,j++)e[1][j]=d[2][i]; 88 f[0]=atof(e[0]);f[1]=atof(e[1]); 89 for(i=0;i<3;i++)p.point[i]+=Vector2(f[0],f[1]); 90 } 91 else cout<<"error/n"; 92 } 93 else if(d[0][0]=='r'&&d[0][1]=='o'&&d[0][2]=='t'&&d[0][3]=='a'&&d[0][4]=='t'&&d[0][5]=='e'&&d[0][6]==0) 94 { 95 for(int k=0;k<20;k++)d[1][k]=0; 96 cin>>d[1]; 97 if(!strcmp(d[1],p.name)) 98 { 99 cin>>d[2]; 100 f[0]=atof(d[2]); 101 Rotation2 rot(f[0]/180*3.1415926); 102 for(i=0;i<3;i++)p.point[i]=rot.Inverse(p.point[i]); 103 } 104 else cout<<"error/n"; 105 } 106 else cout<<"error/n"; 107 for(i=0;i<p.m;i++) cout<<'('<<p.point[i].x()<<','<<p.point[i].y()<<") "; 108 cout<<endl; 109 }