Lua Math Library Tutorial 数学库教程


欢迎各位童鞋转载,转载请注明出处:http://blog.csdn.net/song_hui_xiang

作者新浪微博:http://weibo.com/u/3168848533

作者腾讯微博:http://t.qq.com/song_huixiang


The math library is documented in section 5.6 of the Reference Manual.[1] Below is a summary of the functions and variables provided. Each is described, with an example, on this page.

math.abs   math.acos  math.asin  math.atan math.atan2 math.ceil
math.cos   math.cosh  math.deg   math.exp  math.floor math.fmod
math.frexp math.huge  math.ldexp math.log  math.log10 math.max
math.min   math.modf  math.pi    math.pow  math.rad   math.random
math.randomseed       math.sin   math.sinh math.sqrt  math.tanh
math.tan

math.abs

Return the absolute, or non-negative value, of a given value.
> = math.abs(-100)
100
> = math.abs(25.67)
25.67
> = math.abs(0)
0

math.acos , math.asin

Return the inverse cosine and sine of the given value.
> = math.acos(1)
0
> = math.acos(0)
1.5707963267949
> = math.asin(0)
0
> = math.asin(1)
1.5707963267949

math.atan , math.atan2

Return the inverse tangent. We can do this by supplying y/x ourselves using  math.atan  or we can pass y and x to  math.atan2  to do this for us.
> c, s = math.cos(0.8), math.sin(0.8)
> = math.atan(s/c)
0.8
> = math.atan2(s,c)
0.8

math.atan2 should usually be preferred, particularly when converting rectangular co-ordinates to polar co-ordinates. math.atan2 uses the sign of both arguments to place the result into the correct quadrant, and also produces correct values when one of its arguments is 0 or very cl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值