38 template <
class TSpeed>
60 template <
class TSpeed>
72 Bound(
const TSpeed &速度,
const Rect& 移動範囲,
double 進行方向) :
83 if (進行方向 >
PAI / 2 && 進行方向 <
PAI * 3 / 2)
91 if (進行方向 < PAI / 2 || 進行方向 >
PAI * 3 / 2)
100 進行方向 =
PAI * 2 - 進行方向;
111 if (進行方向 < 0) 進行方向 +=
PAI * 2;
112 if (進行方向 >
PAI * 2) 進行方向 -=
PAI * 2;
114 移動対象->
MoveA(speed.Update(), 進行方向);
120 template <
class TSpeed>
138 const double nowSpeed = speed.Update();
139 const double lx = 目標座標.
GetX() - 移動対象->
GetX();
140 const double ly = 目標座標.
GetY() - 移動対象->
GetY();
142 if (lx * lx + ly * ly <= nowSpeed * nowSpeed)
149 const double angle = atan2(ly, lx);
150 移動対象->
MoveA(nowSpeed, angle);
157 template <
class TSpeed>
173 Orbit(
const TSpeed &角速度 ,
double 半径X ,
double 半径Y ,
double 初期進行方向 = 0.0) :
177 角度(初期進行方向 -
PAI / 2),
178 前移動量X(cos(初期進行方向 -
PAI/2) * 半径X),
179 前移動量Y(sin(初期進行方向 -
PAI/2) * 半径Y)
185 角度 += speed.Update();
187 const double nextX = cos(角度) * 半径X;
188 const double nextY = sin(角度) * 半径Y;
190 移動対象->
Move(nextX - 前移動量X, nextY - 前移動量Y);
218 移動対象->
Move(randX-移動X, randY-移動Y);
目標座標に移動.
Definition: Motion.h:123
const double PAI
円周率
Definition: SDX.h:26
矩形を表す図形クラス.
Definition: Rect.h:22
virtual double GetAngle() const
角度を取得する.
Definition: IPosition.h:56
double GetBottom() const
下端のY座標を取得.
Definition: Rect.h:136
double GetTop() const
上端のY座標を取得.
Definition: Rect.h:124
double GetRight() const
右端のX座標を取得.
Definition: Rect.h:130
double GetLeft() const
左端のX座標を取得.
Definition: Rect.h:118
double GetY() const override
Y座標を取得.
Definition: Point.h:68
円周上を移動.
Definition: Motion.h:160
Bound(const TSpeed &速度, const Rect &移動範囲, double 進行方向)
速度と移動範囲、最初の移動方向を指定.
Definition: Motion.h:72
点を表す図形クラス.
Definition: Point.h:22
移動方法のインターフェース.
Definition: IMotion.h:14
ToFront(const TSpeed &速度)
速度を指定.
Definition: Motion.h:48
bool Update(IPosition *移動対象) override
Motion終了時はfalseを返す.
Definition: Motion.h:135
virtual double GetY() const =0
Y座標を取得.
bool Update(IPosition *移動対象) override
Motion終了時はfalseを返す.
Definition: Motion.h:214
Vibrate(double 最大振れ幅)
コンストラクタ.
Definition: Motion.h:210
virtual void Move(double X移動量, double Y移動量)=0
相対座標で移動.
ToPoint(const TSpeed &速度, const Point &目標座標)
コンストラクタ.
Definition: Motion.h:130
bool Update(IPosition *移動対象) override
Motion終了時はfalseを返す.
Definition: Motion.h:182
bool Update(IPosition *移動対象) override
Motion終了時はfalseを返す.
Definition: Motion.h:78
範囲内で跳ね返る.
Definition: Motion.h:63
その場所で停止.
Definition: Motion.h:31
前方に移動.
Definition: Motion.h:41
virtual void SetPos(double X座標, double Y座標)=0
指定座標に移動.
位置と方向を持つクラスのインターフェース.
Definition: IPosition.h:11
範囲内で振動.
Definition: Motion.h:201
virtual double GetX() const =0
X座標を取得.
static double Get(double 最大値)
0~最大値の乱数を取得.
Definition: Rand.h:29
bool Update(IPosition *移動対象) override
Motion終了時はfalseを返す.
Definition: Motion.h:52
double GetX() const override
X座標を取得.
Definition: Point.h:63
void MoveA(double 距離, double 方向)
極座標で移動.
Definition: IPosition.h:41
Orbit(const TSpeed &角速度, double 半径X, double 半径Y, double 初期進行方向=0.0)
コンストラクタ.
Definition: Motion.h:173