Beispiel #1
0
int MatchHelpers::inPenaltyArea(const Match& m, const Vector3& v)
{
	bool in_x = fabs(v.x) < 20.15f;
	float yp = v.y;

	if(!in_x)
		return 0;

	if(yp < m.getPitchHeight() * -0.5f + 16.5f)
		return -1;
	if(yp > m.getPitchHeight() * 0.5f - 16.5f)
		return 1;

	return 0;
}
Beispiel #2
0
double MatchHelpers::distanceToPitch(const Match& m,
		const Vector3& v)
{
	float r = m.getPitchWidth() * 0.5f;
	float l = -r;
	float u = m.getPitchHeight() * 0.5f;
	float d = -u;
	if(v.x >= l && v.x <= r && v.y >= d && v.y <= u)
		return 0.0f;
	float dhoriz = v.x < l ? l - v.x : v.x - r;
	float dvert  = v.y < d ? d - v.y : v.y - u;
	if(dvert < 0)
		return dhoriz;
	else if(dhoriz < 0)
		return dvert;
	else
		return sqrt(dvert * dvert + dhoriz * dhoriz);
}
Beispiel #3
0
bool MatchHelpers::onPitch(const Match& m, const Vector3& v)
{
	float pw2 = m.getPitchWidth() / 2.0f;
	float ph2 = m.getPitchHeight() / 2.0f;
	return v.x >= -pw2 && v.y >= -ph2 && v.x <= pw2 && v.y <= ph2;
}