Difference between revisions of "UTIL AngleDiff"

From Valve Developer Community
Jump to: navigation, search
m (Added the Degree symbol.)
m (link)
Line 1: Line 1:
 
{{wrongtitle|UTIL_AngleDiff}}
 
{{wrongtitle|UTIL_AngleDiff}}
UTIL_AngleDiff is a UTIL provided in the source code for finding the difference between two values, clamped between -180° and 180°.
+
UTIL_AngleDiff is a [[UTIL]] provided in the Source code for finding the difference between two values, clamped between -180° and 180°.
  
 
== Usage ==
 
== Usage ==

Revision as of 23:32, 12 April 2011

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;