How to clamp angles?

Posts 1–3 of 3 · Page 1 of 1
How to clamp angles?
Title says it all ^^^^^^
Code:
Vector3 Aimbot::NormalizeAngles(Vector3 AngleToNormalize)
{
	Vector3 vec = AngleToNormalize;
	if (vec.x > 89.0f && vec.x <= 180.0f)
	{
		vec.x = 89.0f;
	}
	while (vec.x > 180.f)
	{
		vec.x -= 360.f;
	}
	while (vec.x < -89.0f)
	{
		vec.x = -89.0f;
	}
	while (vec.y > 180.f)
	{
		vec.y -= 360.f;
	}
	while (vec.y < -180.f)
	{
		vec.y += 360.f;
	}

	vec.z = 0;
	return vec;
}
//Credits -> Dolphin
Quote Originally Posted by WasserEsser View Post
Code:
Vector3 Aimbot::NormalizeAngles(Vector3 AngleToNormalize)
{
	Vector3 vec = AngleToNormalize;
	if (vec.x > 89.0f && vec.x <= 180.0f)
	{
		vec.x = 89.0f;
	}
	while (vec.x > 180.f)
	{
		vec.x -= 360.f;
	}
	while (vec.x < -89.0f)
	{
		vec.x = -89.0f;
	}
	while (vec.y > 180.f)
	{
		vec.y -= 360.f;
	}
	while (vec.y < -180.f)
	{
		vec.y += 360.f;
	}

	vec.z = 0;
	return vec;
}
//Credits -> Dolphin
Thanks 2 u and Dolphin
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us