Code:
#include <iostream> #include <Eigen/Dense> #include <cmath>using eigen::matrixxd;using namespace std ; float pi=3.1415926;void mpoint (matrixxd m) {matrixxd T (n), A (+);cout<< "Please enter moving distance:"; fflush (stdin); scanf ("%*c %lf%*c%lf%*c ", &t (0,0), &t (0,1)); a=m+t;cout<< ' (' <<a (0,0) << ', ' <<a (0,1) << ') '; }void Rpoint (matrixxd m) {matrixxd R (2,2), A (;d ouble ang;cout<< "Please enter rotation angle:"; fflush (stdin);cin>>ang; R (0,0) =cos (ANG/180*PI); R (0,1) =sin (ANG/180*PI); R (1,0) =-sin (ANG/180*PI); R (=cos) (ANG/180*PI); a=m*r;cout<< ' (' <<a (0,0) << ', ' <<a (0,1) << ') ';} void Mline (Matrixxd m,matrixxd N) {matrixxd T, A1, A2;cout<< "Please enter moving distance:"; fflush (stdin); scanf ("%*c% Lf%*c%lf%*c ", &t (0,0), &t (0,1)); A1=m+t; a2=n+t;cout<< ' (' <<a1 (0,0) << ', ' <<a1 (0,1) << ') ' << ' << ' (' <<a2 ' (0,0) << ', ' <<a2 (0,1) << ') '; }void rline (matrixxd m,matrixxd N) {matrixxd R (2,2), A1 (UP), A2 (;d Oub)Le ang;cout<< "Please enter rotation angle:"; fflush (stdin);cin>>ang; R (0,0) =cos (ANG/180*PI); R (0,1) =sin (ANG/180*PI); R (1,0) =-sin (ANG/180*PI); R (=cos) (ANG/180*PI); A1=m*r; a2=n*r;cout<< ' (' <<a1 (0,0) << ', ' <<a1 (0,1) << ') ' << ' << ' (' <<a2 ' (0,0) << ', ' <<a2 (0,1) << ') '; }void mtriangle (matrixxd m,matrixxd n,matrixxd k) {Matrixxd T (n), A1, A2 (+), A3;cout<< "Please enter the moving distance:"; Fflush (stdin); scanf ("%*c%lf%*c%lf%*c", &t (0,0), &t (0,1)); A1=m+t; A2=n+t; a3=k+t;cout<< ' (' <<a1 (0,0) << ', ' <<a1 (0,1) << ') ' << ' << ' (' <<a2 ' (0,0) << ', ' <<a2 (0,1) << ') ' << ' << ' (' <<a3 (0,0) << ', ' <<a3 (0,1) << ') ' ; }void rtriangle (matrixxd m,matrixxd n,matrixxd k) {matrixxd R (2,2), A1 (UP), A2 (+), A3;d ouble ang;cout<< " Please enter the angle of rotation: "; fflush (stdin);cin>>ang; R (0,0) =cos (ANG/180*PI); R (0,1) =sin (ANG/180*PI); R (1,0) =-sin (ANG/180*PI); R (=cos) (ANG/180*PI); A1=m*r; A2=n*r; A3=k*r;cout<< ' (' <<a1 (0,0) << ', ' <<a1 (0,1) << ') ' << ' << ' (' <<a2 (0,0) << ', ' << A2 (0,1) << ' << ' << ' (' <<a3 (0,0) << ', ' <<a3 (0,1) << ') '; }void Point () {matrixxd m (n); char cal[21];int a;cout<< "Please enter dot coordinates:"; fflush (stdin); scanf ("%*c%lf%*c%lf%*c",& M (0,0), &m (0,1));a:cout<< "Please enter operation instruction:"; cin>>cal;if (cal[0]== ' m ' &&cal[1]== ' o ' &&cal[2 ]== ' V ' &&cal[3]== ' e ' &&cal[4]==0) {mpoint (m);} else if (cal[0]== ' R ' &&cal[1]== ' o ' &&cal[2]== ' t ' &&cal[3]== ' a ' &&cal[4]== ' t ' & &cal[5]== ' E ' &&cal[6]==0) {rpoint (m);} else{cout<< "Instruction Error! "<<endl;goto A;}} void Line () {matrixxd m (up), N (on), char cal[21];int a;cout<< "Please enter the linear endpoint coordinates:"; fflush (stdin); scanf ("%*c%lf%*c%lf%*c%*c%lf%*c%lf%*c", &m (0,0), &m (0,1), &n (0,0), &n (0,1)); a:cout<< "Please enter operation instruction:"; Cin>>cal;if (cal[0]== ' m ' &&cal[1]== ' o ' &&cal[2]== ' V ' &&cal[3]== ' E ' &&cal[4]==0) {mline (m,n);} else if (cal[0]== ' R ' &&cal[1]== ' o ' &&cal[2]== ' t ' &&cal[3]== ' a ' &&cal[4]== ' t ' & &cal[5]== ' E ' &&cal[6]==0) {rline (m,n);} else{cout<< "Instruction Error! "<<endl;goto A;}} void triangle () {matrixxd m (on), N (UP), K (on), char cal[21];int a;cout<< "Please enter triangle endpoint coordinates:"; fflush (stdin); scanf ("%* C%lf%*c%lf%*c%*c%lf%*c%lf%*c%*c%lf%*c%lf%*c ", &m (0,0), &m (0,1), &n (0,0), &n (0,1), &k (0,0),& K (0,1));a:cout<< "Please input operation instruction:"; cin>>cal;if (cal[0]== ' m ' &&cal[1]== ' o ' &&cal[2]== ' V ' & &cal[3]== ' E ' &&cal[4]==0) {mtriangle (m,n,k);} else if (cal[0]== ' R ' &&cal[1]== ' o ' &&cal[2]== ' t ' &&cal[3]== ' a ' &&cal[4]== ' t ' & &cal[5]== ' E ' &&cal[6]==0) {rtriangle (m,n,k);} else{cout<< "Instruction Error! "<<endl;goto A;}} int main () {char name[11];int i;cout<< "Please enter a graphic name and its end points:"; Cin.getline (name,10); for (i=0;i<11;i++) {if (Name[i] = = ") break;} if (name[i+1]== ' 1 ') {point ();}else if (name[i+1]== ' 2 ') {line ();} else if (name[i+1]== ' 3 ') {triangle ();} return 0;}
Results:
"Real-time control software Design" first time programming job