Beispiel #1
0
/**
 * 通过传入kick的参数,计算kick后球的位置和速度
 * Calculate ball position and velocity after a kick action.
 * \param kick_power.
 * \param kick_angle.
 * \param player_state state of the player who is performing kick.
 * \param ball_state ball state before the kick action is performed.
 * \param ball_pos will be set to ball position after kick.
 * \param ball_vel will be set to ball velocity after kick.
 * \param is_self if the action is performed by the agent this process represents.
 */
void ActionEffector::ComputeInfoAfterKick(const double kick_power, const double kick_angle,
		const PlayerState &player_state, const BallState &ball_state, Vector &ball_pos, Vector &ball_vel, bool is_self)
{
	double power = GetNormalizeKickPower(kick_power);
	double dir = GetNormalizeMoment(kick_angle);

	Vector ball_2_player = (ball_state.GetPos() - player_state.GetPos()).Rotate(-player_state.GetBodyDir());
    double eff_power = power *
        (is_self ? player_state.GetKickRate() : GetKickRate(ball_2_player, player_state.GetPlayerType()));
	Vector accel = Polar2Vector(eff_power, player_state.GetBodyDir() + dir);

	ball_vel = ball_state.GetVel() + accel;
	ball_pos = ball_state.GetPos() + ball_vel;
	ball_vel *= ServerParam::instance().ballDecay();
}
Beispiel #2
0
/**
 * 通过传入turn的参数,计算turn后球员的身体朝向和脖子朝向
 * Calculate player body direction after a turn action.
 * \param turn_angle.
 * \param player_state state of the player who is turning.
 * \param body_dir will be set to player's body direction after turn.
 */
void ActionEffector::ComputeInfoAfterTurn(const AngleDeg moment,
		const PlayerState &player_state, AngleDeg &body_dir)
{
	double turn_angle = GetTurnAngle(moment, player_state.GetPlayerType(), player_state.GetVel().Mod());
	body_dir = GetNormalizeAngleDeg(player_state.GetBodyDir() + turn_angle);
}