UTIL AngleDiff

From Valve Developer Community
Revision as of 23:32, 12 April 2011 by Thelonesoldier (talk | contribs) (link)

Jump to: navigation, search

Template:Wrongtitle UTIL_AngleDiff is a UTIL provided in the Source code for finding the difference between two values, clamped between -180° and 180°.

Usage

//-----------------------------------------------------------------------------
// Purpose: Returns the difference between two values as a float. 
// Input  : destAngle - Value "B" to compare against
// Input  : srcAngle - Value "A" to compare with
// Output : float - Difference between the two values, interpreted as an angle
//-----------------------------------------------------------------------------
inline float UTIL_AngleDiff( float destAngle, float srcAngle )

Examples

//Restricts a value from going too far beyond another one.
//This is used in the jeep to keep you from looking too far left/right, etc.
float flAngleDiff = AngleDiff( vecViewAngles.y, vehicleEyeAngles.y );
flAngleDiff = clamp( flAngleDiff, pYawBounds[0], pYawBounds[1] );
vecViewAngles.y = vehicleEyeAngles.y + flAngleDiff;