質問編集履歴

1

注釈

2017/06/29 09:22

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -82,35 +82,21 @@
82
82
 
83
83
  ```C++
84
84
 
85
- #include <iostream>
85
+ void neutral_coor(int rot_num, int x, int y){ //(90°回転を何回するか, 回転したいx座標, y座標)
86
86
 
87
- #include <cmath>
87
+ double degree = rot_num*90*(M_PI / 180); //弧度からラジアンへ
88
88
 
89
- #define width 50
89
+ double O_x = width*0.5; //xの回転中心
90
90
 
91
- #define height 50
91
+ double O_y = height*0.5; //yの回転中心
92
92
 
93
- #define M_PI 3.14159265358979323846
93
+ double neutral_x = x*cos(degree) - y*sin(degree) + O_x*(1-cos(degree)) + O_y*sin(degree); //回転後のx
94
94
 
95
- using namespace std;
95
+ double neutral_y = x*sin(degree) + y*cos(degree) - O_x*sin(degree) + O_y*(1-cos(degree)); //回転後のy
96
96
 
97
+ cout << "neutral_y is " << int(neutral_y) << endl;
97
98
 
98
-
99
- void neutral_coor(int rot_num, int x, int y){
100
-
101
- double degree = rot_num*90*(M_PI / 180);
102
-
103
- double O_x = width*0.5;
104
-
105
- double O_y = height*0.5;
106
-
107
- double neutral_x = x*cos(degree) - y*sin(degree) + O_x*(1-cos(degree)) + O_y*sin(degree);
108
-
109
- double neutral_y = x*sin(degree) + y*cos(degree) - O_x*sin(degree) + O_y*(1-cos(degree));
110
-
111
- cout << "neutral_y is " << trunc(neutral_y) << endl;
112
-
113
- cout << "neutral_x is " << trunc(neutral_x) << endl;
99
+ cout << "neutral_x is " << int(neutral_x) << endl;
114
100
 
115
101
  cout << endl;
116
102