I'm a doctor, not a mechanic

Difference between revisions of "Clamp function"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (moved Clamp function to UE1:Clamp function: Inline only works on namespaces?... test)
m
Line 1: Line 1:
 
<noinclude>Clamp is math function provided by the {{classgames|Object}} class.</noinclude>
 
<noinclude>Clamp is math function provided by the {{classgames|Object}} class.</noinclude>
 
+
{{code|native(251) static final function [[int]]&nbsp;'''Clamp''' ([[int]]&nbsp;'''V''', [[int]]&nbsp;'''A''',[[int]]&nbsp;'''B''')}}
 
Limits ''V'' to the [[wp:interval (mathematics)|interval]] of [''A'', ''B'']. Exactly speaking, ''A'' will be returned if ''V'' is smaller than ''A'', ''B'' will be returned if ''V'' is larger than ''B'', otherwise ''V'' is returned.
 
Limits ''V'' to the [[wp:interval (mathematics)|interval]] of [''A'', ''B'']. Exactly speaking, ''A'' will be returned if ''V'' is smaller than ''A'', ''B'' will be returned if ''V'' is larger than ''B'', otherwise ''V'' is returned.
  
 
This also applies if ''A'' is larger than ''B''. So if ''V'' is larger than ''B'', but smaller than ''A'', the value of ''A'' is returned even though ''V'' is actually between the two values.
 
This also applies if ''A'' is larger than ''B''. So if ''V'' is larger than ''B'', but smaller than ''A'', the value of ''A'' is returned even though ''V'' is actually between the two values.
 
 
<noinclude>[[Category:Math functions]]</noinclude>
 
<noinclude>[[Category:Math functions]]</noinclude>

Revision as of 19:13, 2 July 2010

Clamp is math function provided by the Object(RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UDK, UT3) class.

native(251) static final function int Clamp (int V, int A,int B)

Limits V to the interval of [A, B]. Exactly speaking, A will be returned if V is smaller than A, B will be returned if V is larger than B, otherwise V is returned.

This also applies if A is larger than B. So if V is larger than B, but smaller than A, the value of A is returned even though V is actually between the two values.