UTIL AngleDiff

From Valve Developer Community
Revision as of 17:19, 9 April 2011 by LordNed (talk | contribs) (Created page with 'UTIL_AngleDiff is a UTIL provided in the source code for finding the difference between two values, interpreted as angles. {{Todo|Check if this is true. Source is hidden inside o…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

UTIL_AngleDiff is a UTIL provided in the source code for finding the difference between two values, interpreted as angles.

Todo: Check if this is true. Source is hidden inside of mathlib, and the header contains no descriptions!

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;