# include // OpenSiv3D v0.6.10 # include Vec2 sVec = { 0.0, -1.0 }; const double vLength = 100; const double PI = 3.14159265359; /// @brief 角度とラジアンを変換して返します /// @param _angle 角度を入力 /// @return ラジアンに変換された値 double Degree2Radians(double _angle) { return(_angle * (PI / 180.0)); } /// @brief _angle度だけ_vecを原点中心に回転して返す /// @param _vec 回転されるベクトル /// @param _angle 回転角度(度) /// @return 回転後のベクトル Vec2 RotateVec(Vec2 _vec, double _angle) { double theta = Degree2Radians(_angle); //ラジアン Vec2 res; res.x = _vec.x * cos(theta) - _vec.y * sin(theta); res.y = _vec.x * sin(theta) + _vec.y * cos(theta); return(res); } void Main() { // 背景の色を設定する | Set the background color Scene::SetBackground(ColorF{ 0.6, 0.8, 0.7 }); const Vec2 ORIGIN = { Scene::Width() / 2, Scene::Height() / 2 }; double rotAngle = 0; while (System::Update()) { if (MouseL.pressed()) { rotAngle += Scene::DeltaTime()* (20*(360/60)); } if (MouseR.pressed()) { rotAngle -= Scene::DeltaTime() * (20 * (360 / 60)); } Print << rotAngle; Vec2 rVec = RotateVec(sVec, rotAngle); //rVec.normalize(); Line{ ORIGIN, ORIGIN + vLength * rVec }.drawArrow(5, { 20,20 }, Palette::Black); } }