UTIL AngleDiff: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(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…')
 
m (→‎top: Unicodifying)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
UTIL_AngleDiff is a UTIL provided in the source code for finding the difference between two values, interpreted as angles.
{{DISPLAYTITLE:UTIL_AngleDiff}}
{{Todo|Check if this is true. Source is hidden inside of mathlib, and the header contains no descriptions!}}
UTIL_AngleDiff is a [[UTIL]] provided in the Source code for finding the difference between two values, clamped between -180° and 180°.


== Usage ==
== Usage ==

Latest revision as of 02:08, 9 January 2024

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;