Lua MathExtra: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
Line 1: Line 1:
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}
[[Engine_Development|Development]] < [[Lua_Scripting|Lua Scripting]] < {{FULLPAGENAME}}


== Additional math functions {{HeaderNotice|(added with: 94.1.1-1311)}}==
== Additional math functions=
'''math.hypot'''
'''math.hypot''' {{new|95}}
   ( number x, number y ) -> number
   ( number x, number y ) -> number
   <span class="note">Returns the length of hypotenuse of right angle triangle with sides x and y, equivalent
   <span class="note">Returns the length of hypotenuse of right angle triangle with sides x and y, equivalent
Line 8: Line 8:
   overflows/underflows, but is also slower.</span>
   overflows/underflows, but is also slower.</span>


'''math.diag'''
'''math.diag''' {{new|95}}
   ( number x1 [, ... ] ] ) -> number
   ( number x1 [, ... ] ] ) -> number
   <span class="note">Returns the length of diagonal of an n-dimensional box. Rather quick method that does not
   <span class="note">Returns the length of diagonal of an n-dimensional box. Rather quick method that does not
   handle intermediate overflows/underflows nor is made for numerical stability.</span>
   handle intermediate overflows/underflows nor is made for numerical stability.</span>


'''math.clamp'''
'''math.clamp''' {{new|95}}
   ( number x, number min, number max ) -> number
   ( number x, number min, number max ) -> number
   <span class="note">Returns x clamped to min and max boundaries.</span>
   <span class="note">Returns x clamped to min and max boundaries.</span>
[[category: Lua]]
[[category: Lua]]

Revision as of 15:32, 9 October 2013

Development < Lua Scripting < Lua MathExtra

= Additional math functions

math.hypot New in version 95

 ( number x, number y ) -> number
 Returns the length of hypotenuse of right angle triangle with sides x and y, equivalent
 to sqrt(x*x + y*y), but has better numerical stability and internaly handles intermediate
 overflows/underflows, but is also slower.

math.diag New in version 95

 ( number x1 [, ... ] ] ) -> number
 Returns the length of diagonal of an n-dimensional box. Rather quick method that does not
 handle intermediate overflows/underflows nor is made for numerical stability.

math.clamp New in version 95

 ( number x, number min, number max ) -> number
 Returns x clamped to min and max boundaries.