Lua之math
Lua之math函数:
转载请注明出处:http://www.cnblogs.com/jietian331/p/8032555.html
|
abs |
取绝对值 |
math.abs(-15) |
15 |
|
acos |
反余弦函数 |
math.acos(0.5) |
1.04719755 |
|
asin |
反正弦函数 |
math.asin(0.5) |
0.52359877 |
|
atan2 |
x / y的反正切值 |
math.atan2(90.0, 45.0) |
1.10714871 |
|
atan |
反正切函数 |
math.atan(0.5) |
0.463647609 |
|
ceil |
不小于x的最大整数 |
math.ceil(5.8) |
6 |
|
cosh |
双曲线余弦函数 |
math.cosh(0.5) |
1.276259652 |
|
cos |
余弦函数 |
math.cos(0.5) |
0.87758256 |
|
deg |
弧度转角度 |
math.deg(math.pi) |
180 |
|
exp |
计算以e为底x次方值 |
math.exp(2) |
2.718281828 |
|
floor |
不大于x的最大整数 |
math.floor(5.6) |
5 |
|
fmod (mod) |
取模运算 |
math.mod(14, 5) |
4 |
|
frexp |
把双精度数val分解为数字部分(尾数)和以2为底的指数n,即val=x*2n |
math.frexp(10.0) |
0.625 4 |
|
ldexp |
计算value * 2的n次方 |
math.ldexp(10.0, 3) |
80 = 10 * (2 ^3) |
|
log10 |
计算以10为基数的对数 |
math.log10(100) |
2 |
|
log |
计算一个数字的自然对数 |
math.log(2.71) |
0.9969 |
|
max |
取得参数中最大值 |
math.max(2.71, 100, -98, 23) |
100 |
|
min |
取得参数中最小值 |
math.min(2.71, 100, -98, 23) |
-98 |
|
modf |
把数分为整数和小数 |
math.modf(15.98) |
15 98 |
|
pow |
得到x的y次方 |
math.pow(2, 5) |
32 |
|
rad |
角度转弧度 |
math.rad(180) |
3.14159265358 |
|
random |
获取随机数 |
math.random(1, 100) |
获取1-100的随机数 |
|
randomseed |
设置随机数种子 |
math.randomseed(os.time()) |
在使用math.random函数之前必须使用此函数设置随机数种子 |
|
sinh |
双曲线正弦函数 |
math.sinh(0.5) |
0.5210953 |
|
sin |
正弦函数 |
math.sin(math.rad(30)) |
0.5 |
|
sqrt |
开平方函数 |
math.sqrt(16) |
4 |
|
tanh |
双曲线正切函数 |
math.tanh(0.5) |
0.46211715 |
|
tan |
正切函数 |
math.tan(0.5) |
0.5463024 |
Lua之math的更多相关文章
- lua 随机数 math.random()和math.randomseed()用法
用法一: 不给范围,就随机算一个0~1之间的小数: 用法二:给一个参数,就取1~n之间的随机数 用法三:给两个参数,就取m~n之间的随机数 math.randomseed()用法: 由于C中 ...
- [lua]紫猫lua教程-命令宝典-L1-01-08. math数学函数库
L1[math]01. 取绝对值 L1[math]02. 三角函数 小知识:注意 lua下三角函数用的参数是弧度 而不是角度 弧度=角度*pi/180 -->弧度角度换算公式 lua的mat ...
- lua随机数的问题
在看 lua 的 math.random 函数的时候发现一个问题,就是在没有重新设置随机种子的时候, random 返回的前几个随机数并不是那么特别随机,尤其当随机范围很小的时候,比如 100 左右的 ...
- 【腾讯Bugly干货分享】手游热更新方案xLua开源:Unity3D下Lua编程解决方案
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/2bY7A6ihK9IMcA0bOFyB-Q 导语 xL ...
- 腾讯开源手游热更新方案,Unity3D下的Lua编程
原文:http://www.sohu.com/a/123334175_355140 作者|车雄生 编辑|木环 腾讯最近在开源方面的动作不断:先是微信跨平台基础组件Mars宣布开源,腾讯手游又于近期开源 ...
- Lua语言中文手册 转载自网络
Programming in LuaCopyright ® 2005, Translation Team, www.luachina.net Programming in LuaProgramming ...
- lua ffi简介
本文转自网络 由来 FFI库,是LuaJIT中最重要的一个扩展库.它允许从纯Lua代码调用外部C函数,使用C数据结构.有了它,就不用再像Lua标准math库一样,编写Lua扩展库.把开发者从开发Lua ...
- Lua 学习之基础篇七<Lua Module,Package介绍>
Lua 之Module介绍 包管理库提供了从 Lua 中加载模块的基础库. 只有一个导出函数直接放在全局环境中: [require]. 所有其它的部分都导出在表 package 中. require ...
- Nginx_Lua
http://www.ttlsa.com/nginx/nginx-lua/ 1.1. 介绍ngx_lua – 把lua语言嵌入nginx中,使其支持lua来快速开发基于nginx下的业务逻辑该模块不在 ...
随机推荐
- gitignore 不起作用的解决办法
gitignore 不起作用的解决办法 - sloong - 博客园 https://www.cnblogs.com/sloong/p/5523244.html Administrator@PC-20 ...
- android&sqlsever
http://blog.csdn.net/chaoyu168/article/details/51910601
- 苹果审核被拒,Guideline 1.1.6 - Safety - Objectionable Content;Guideline 3.1.1 - Business - Payments - In-App Purchase
Guideline 1.1.6 - Safety - Objectionable Content Thank you for your resubmission. We noticed that yo ...
- tornado框架&三层架构&MVC&MTV&模板语言&cookie&session
web框架的本质其实就是socket服务端再加上业务逻辑处理, 比如像是Tornado这样的框架. 有一些框架则只包含业务逻辑处理, 例如Django, bottle, flask这些框架, 它们的使 ...
- LeetCode 876 Middle of the Linked List 解题报告
题目要求 Given a non-empty, singly linked list with head node head, return a middle node of linked list. ...
- 2018/04/24 PHP 设计模式之注册树模式
之前学习了工厂模式和单例模式,明白了他们的意义. 但是我们在之后的使用中会发现一个问题,在新建一个实例的时候还是需要调用一个单例或者工厂,之后还是造成了代码和耦合和不好处理. 下面开始说一下: -- ...
- 注解之@PathVariable
@PathVariable只支持一个属性value,类型是为String,代表绑定的属性名称.默认不传递时,绑定为同名的形参. 用来便捷地提取URL中的动态参数.其英文注释如下: Annotation ...
- ntpdata 同步时间
ntpdate用来同步时间 [root@localhost ~]# yum install -y ntp [root@localhost ~]# ntpdate time.windows.com # ...
- c# 文件或者文件夹改名的最简单方法
使用cmd命令 ren Process.Start( "cmd", "/C " + "ren f:\\first c code.txt zhou.tx ...
- 多线程——继承Thread类实现一个多线程
继承Thread类实现一个多线程 Thread类部分源码: package java.lang; //该类实现了Runnable接口 public class Thread implements Ru ...