函数名 描述 示例 结果
pi 圆周率 math.pi 3.1415926535898
abs 取绝对值 math.abs(-2012) 2012
ceil 向上取整 math.ceil(9.1) 10
floor 向下取整 math.floor(9.9) 9
max 取参数最大值 math.max(2,4,6,8) 8
min 取参数最小值 math.min(2,4,6,8) 2
pow 计算x的y次幂 math.pow(2,16) 65536
sqrt 开平方 math.sqrt(65536) 256
mod 取模 math.mod(65535,2) 1
modf 取整数和小数部分 math.modf(20.12) 20   0.12
randomseed 设随机数种子 math.randomseed(os.time())  
random 取随机数 math.random(5,90) 5~90
rad 角度转弧度 math.rad(180) 3.1415926535898
deg 弧度转角度 math.deg(math.pi) 180
exp e的x次方 math.exp(4) 54.598150033144
log 计算x的自然对数 math.log(54.598150033144) 4
log10 计算10为底,x的对数 math.log10(1000) 3
frexp 将参数拆成x * (2 ^ y)的形式 math.frexp(160) 0.625    8
ldexp 计算x * (2 ^ y) math.ldexp(0.625,8) 160
sin 正弦 math.sin(math.rad(30)) 0.5
cos 余弦 math.cos(math.rad(60)) 0.5
tan 正切 math.tan(math.rad(45)) 1
asin 反正弦 math.deg(math.asin(0.5)) 30
acos 反余弦 math.deg(math.acos(0.5)) 60
atan 反正切 math.deg(math.atan(1)) 45
函数名 描述 示例 结果
pi 圆周率 math.pi 3.1415926535898
abs 取绝对值 math.abs(-2012) 2012
ceil 向上取整 math.ceil(9.1) 10
floor 向下取整 math.floor(9.9) 9
max 取参数最大值 math.max(2,4,6,8) 8
min 取参数最小值 math.min(2,4,6,8) 2
pow 计算x的y次幂 math.pow(2,16) 65536
sqrt 开平方 math.sqrt(65536) 256
mod 取模 math.mod(65535,2) 1
modf 取整数和小数部分 math.modf(20.12) 20   0.12
randomseed 设随机数种子 math.randomseed(os.time())  
random 取随机数 math.random(5,90) 5~90
rad 角度转弧度 math.rad(180) 3.1415926535898
deg 弧度转角度 math.deg(math.pi) 180
exp e的x次方 math.exp(4) 54.598150033144
log 计算x的自然对数 math.log(54.598150033144) 4
log10 计算10为底,x的对数 math.log10(1000) 3
frexp 将参数拆成x * (2 ^ y)的形式 math.frexp(160) 0.625    8
ldexp 计算x * (2 ^ y) math.ldexp(0.625,8) 160
sin 正弦 math.sin(math.rad(30)) 0.5
cos 余弦 math.cos(math.rad(60)) 0.5
tan 正切 math.tan(math.rad(45)) 1
asin 反正弦 math.deg(math.asin(0.5)) 30
acos 反余弦 math.deg(math.acos(0.5)) 60
atan 反正切 math.deg(math.atan(1)) 45

lua math libary的更多相关文章

  1. lua math 库

    lua math库 (2012-05-18 17:26:28) 转载▼ 标签: 游戏 分类: Lua atan2.sinh.cosh.tanh这4个应该用不到. 函数名 描述 示例 结果 pi 圆周率 ...

  2. Lua math库

    函数名 描述 示例 结果 pi 圆周率 math.pi 3.1415926535898 abs 取绝对值 math.abs(-2012) 2012 ceil 向上取整 math.ceil(9.1) 1 ...

  3. lua math.random()

    math.random([n [,m]]) 用法:1.无参调用,产生[0, 1)之间的浮点随机数. 2.一个参数n,产生[1, n]之间的整数. 3.两个参数,产生[n, m]之间的整数. math. ...

  4. lua function

    This is the main reference for the World of Warcraft Lua Runtime. Note that these are mostly standar ...

  5. lua学习笔记(2)-常用调用

    assert(loadstring("math.max(7,8,9)"))dofile("scripts/xxx.lua")math.floor()math.r ...

  6. math.floor实现四舍五入

     lua math.floor 实现四舍五入: lua 中的math.floor函数是向下取整函数. math.floor(5.123) -- 5 math.floor(5.523) -- 5 用此特 ...

  7. 深入redis内部--初始化服务器

    初始化服务器代码如下: void initServer() { int j; signal(SIGHUP, SIG_IGN); signal(SIGPIPE, SIG_IGN); setupSigna ...

  8. Redis(四):独立功能的实现

    发布与订阅 Redis 的发布与订阅功能有PUBLISH命令,SUBSCRIBE命令,PSUBSCRIBE命令,PUBSUB命令等组成. 客户端可以通过SUBSCRIBE命令订阅一个或多个频道,当其它 ...

  9. Lua之math

    Lua之math函数: 转载请注明出处:http://www.cnblogs.com/jietian331/p/8032555.html abs 取绝对值 math.abs(-15) 15 acos ...

随机推荐

  1. LightOJ 1085(树状数组+离散化+DP,线段树)

    All Possible Increasing Subsequences Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format: ...

  2. DB Query Analyzer 5.04 is released, 63 articles concerned have been published

    DB Query Analyzer 5.04 is released, 63 articles concerned have been published DB QueryAnalyzer is pr ...

  3. kubernetes之kube-ApiServer代码分析

    一.概述: kube-ApiServer相当于是k8集群的一个入口,不论通过kubectl还是使用remote api 直接控制,都要经过apiserver.apiserver说白了就是一个serve ...

  4. 业务需求那些事,使用WCF如何实现业务需求!

    最近遇到一个新项目,需要与硬件结合,进行读取信息并保存在数据库中.业务要求也在昨天发布一个问题,当然感谢许多园内的朋友出谋划策,截图有真相! 关于这个问题,我做了如下假设.目前处于测试状态,代码比较简 ...

  5. table+js实现网站左侧列表下拉隐藏

    <script language="javascript">                    function showHide(obj){            ...

  6. 浏览器返回按钮不会触发onLoad事件

    最近在做一个移动端项目,发现移动端某些返回和PC端是有差异的, 比如ios中返回按钮是直接使用缓存的, 不会执行任何js代码, 这个问题很蛋疼, 例如, 在提交的时候将按钮设置为loading状态, ...

  7. JS原型,Prototype,原型

    对于javascript这样一种前端语言,个人觉得,要真正的理解其oop, 就必须要彻底搞清楚javascript的对象,原型链,作用域,闭包,以及this所引用的对象等概念.这些对弄明白了,应该就可 ...

  8. C++引用和函数返回值

    这是老师上课讲的内容,现在把它写下来,一方面当做复习,另一方面真的想学点东西.废话不多说,先贴上测试的代码: #include <iostream.h> float temp; float ...

  9. Android GridView 二维布局界面

    GridView用于在界面上按行.列分布的方式来显示多个组件. <LinearLayout xmlns:android="http://schemas.android.com/apk/ ...

  10. Arduino周边模块:执行部件(舵机、直流电机、步进电机)

    Arduino周边模块:执行部件 Arduino周边模块:执行部件 嵌入式系统的构成 如今已经有各种各样的基于Arduino的嵌入式系统, 比如:智能小车.3D打印机.机器人,甚至还有基于Arduin ...