LuaSTG-x Core API
math Class Reference

Classes

class  collision
 
class  distance
 
class  geometry
 
class  hull
 
class  intersection
 
class  mat4
 
class  matrix
 
class  quaternion
 
class  Random
 
class  spline
 
class  tween
 
class  vec2
 
class  vec3
 
class  vec4
 

Public Member Functions

static function abs (local x)
 
static function acos (local x)
 
static function asin (local x)
 
static function atan (local x)
 
static function atan2 (local y, local x)
 
static function barycentric (local v1, local v2, local v3, local a1, local a2)
 
static function cbrt (local v)
 
static function ceil (local x)
 
static function ChebyshevDistance (local v1, local v2)
 
static function clamp (local v, local lo, local hi)
 
static function cos (local x)
 
static function cosh (local x)
 
static function deg (local x)
 
static function EuclideanDistance (local v1, local v2)
 
static function exp (local x)
 
static function floor (local x)
 
static function fmod (local x, local y)
 
static function frexp (local x)
 
static function hypot (local v1, local v2)
 
static function isfinite (local v)
 
static function isinf (local v)
 
static function isnan (local v)
 
static function ldexp (local m, local e)
 
static function lerp (local v1, local v2, local a)
 
static function log (local x, local base)
 
static function log10 (local x)
 
static function ManhattanDistance (local v1, local v2)
 
static function max (local x, local ...)
 
static function min (local x, local ...)
 
static function MinkowskiDistance (local v1, local v2, local p)
 
static function modf (local x)
 
static function pow (local x, local y)
 
static function rad (local x)
 
static function random (local m, local n)
 
static function randomseed (local x)
 
static function remainder (local v1, local v2)
 
static function round (local v)
 
static function sin (local x)
 
static function sinh (local x)
 
static function smoothstep (local v1, local v2, local a)
 
static function solveLiner (local a1, local b1, local c1, local a2, local b2, local c2)
 
static function sqrt (local x)
 
static function tan (local x)
 
static function tanh (local x)
 
static function wrapangle (local v)
 

Public Attributes

number huge = inf
 
number M_1_PI = 0.318309886183790671538
 
number M_2_PI = 0.636619772367581343076
 
number M_2_SQRTPI = 1.12837916709551257390
 
number M_E = 2.71828182845904523536
 
number M_LN10 = 2.30258509299404568402
 
number M_LN2 = 0.693147180559945309417
 
number M_LOG10E = 0.434294481903251827651
 
number M_LOG2E = 1.44269504088896340736
 
number M_PI = 3.14159265358979323846
 
number M_PI_2 = 1.57079632679489661923
 
number M_PI_4 = 0.785398163397448309616
 
number M_PIx2 = 6.28318530717958647693
 
number M_PIx4 = 12.5663706143591729538
 
number M_SQRT1_2 = 0.707106781186547524401
 
number M_SQRT2 = 1.41421356237309504880
 
number pi = 3.1415926535898
 

Detailed Description

数学函数库

这个库提供了基本的数学函数,所有函数都放在表 math 中。

Member Function Documentation

◆ abs()

static function abs ( local  x)

返回 x 的绝对值。

Parameters
xnumber
Returns
number

◆ acos()

static function acos ( local  x)

返回 x 的反余弦值(用弧度表示)。

Parameters
xnumber
Returns
number

◆ asin()

static function asin ( local  x)

返回 x 的反正弦值(用弧度表示)。

Parameters
xnumber
Returns
number

◆ atan()

static function atan ( local  x)

返回 x 的反正切值(用弧度表示)。

Parameters
xnumber
Returns
number

◆ atan2()

static function atan2 ( local  y,
local  x 
)

返回 y/x 的反正切值(用弧度表示)。

它会使用两个参数的符号来找到结果落在哪个象限中。

(即使 x 为零时,也可以正确的处理。)

默认的 x 是 1 ,

因此调用 math.atan2(y) 将返回

y 的反正切值。

Parameters
ynumber
xnumber
Returns
number

◆ barycentric()

static function barycentric ( local  v1,
local  v2,
local  v3,
local  a1,
local  a2 
)

C# MathHelper.Barycentric

Parameters
v1number
v2number
v3number
a1number
a2number
Returns
number

◆ cbrt()

static function cbrt ( local  v)
Parameters
vnumber
Returns
number

◆ ceil()

static function ceil ( local  x)

返回不小于 x 的最小整数值。

Parameters
xnumber
Returns
number

◆ ChebyshevDistance()

static function ChebyshevDistance ( local  v1,
local  v2 
)

◆ clamp()

static function clamp ( local  v,
local  lo,
local  hi 
)
Parameters
vnumber
lonumber
hinumber
Returns
number

◆ cos()

static function cos ( local  x)

返回 x 的余弦(假定参数是弧度)。

Parameters
xnumber
Returns
number

◆ cosh()

static function cosh ( local  x)

返回 x 的双曲余弦。

Parameters
xnumber
Returns
number

◆ deg()

static function deg ( local  x)

将角 x 从弧度转换为角度。

Parameters
xnumber
Returns
number

◆ EuclideanDistance()

static function EuclideanDistance ( local  v1,
local  v2 
)

◆ exp()

static function exp ( local  x)

返回 e^x 的值

e 为自然对数的底)。

Parameters
xnumber
Returns
number

◆ floor()

static function floor ( local  x)

返回不大于 x 的最大整数值。

Parameters
xnumber
Returns
number

◆ fmod()

static function fmod ( local  x,
local  y 
)

返回 x 除以 y,将商向零圆整后的余数。

Parameters
xnumber
ynumber
Returns
number

◆ frexp()

static function frexp ( local  x)

Returns m and e such that x = m2^e, e is an integer and the

absolute value of m is in the range [0.5, 1) (or zero when x is zero).

Parameters
xnumber
Returns
number

◆ hypot()

static function hypot ( local  v1,
local  v2 
)
Parameters
v1number
v2number
Returns
number

◆ isfinite()

static function isfinite ( local  v)

v is not positive infinity, negative infinity, or NaN

◆ isinf()

static function isinf ( local  v)

v == +/-inf

◆ isnan()

static function isnan ( local  v)

◆ ldexp()

static function ldexp ( local  m,
local  e 
)

Returns m2^e (e should be an integer).

◆ lerp()

static function lerp ( local  v1,
local  v2,
local  a 
)
Parameters
v1number
v2number
anumber
Returns
number

◆ log()

static function log ( local  x,
local  base 
)

返回以指定底的 x 的对数。

默认的 basee

(因此此函数返回 x 的自然对数)。

重载
fun(x:number):number
Parameters
xnumber
basenumber
Returns
number

◆ log10()

static function log10 ( local  x)

Returns the base-10 logarithm of x.

Parameters
xnumber
Returns
number

◆ ManhattanDistance()

static function ManhattanDistance ( local  v1,
local  v2 
)

◆ max()

static function max ( local  x,
local ...   
)

返回参数中最大的值,

大小由 Lua 操作 < 决定。

Parameters
xnumber
Returns
number

◆ min()

static function min ( local  x,
local ...   
)

返回参数中最小的值,

大小由 Lua 操作 < 决定。

Parameters
xnumber
Returns
number

◆ MinkowskiDistance()

static function MinkowskiDistance ( local  v1,
local  v2,
local  p 
)

◆ modf()

static function modf ( local  x)

返回 x 的整数部分和小数部分。

Parameters
xnumber
Returns
number

◆ pow()

static function pow ( local  x,
local  y 
)

Returns x^y. (You can also use the expression x^y to compute this

value.)

Parameters
xnumber
ynumber
Returns
number

◆ rad()

static function rad ( local  x)

将角 x 从角度转换为弧度。

Parameters
xnumber
Returns
number

◆ random()

static function random ( local  m,
local  n 
)

当不带参数调用时,返回一个 [0,1) 区间内一致分布的浮点伪随机数。

当以两个整数 mn 调用时, math.random 返回一个 [m, n] 区间

内均匀分布的整数伪随机数。

(值 n-m 不能是负数,且必须在 Lua 整数的表示范围内。)

调用 math.random(n) 等价于 math.random(1,n)

这个函数是对 C 提供的位随机数函数的封装。

对其统计属性不作担保。

重载
fun():number
Parameters
mnumber
nnumber
Returns
number

◆ randomseed()

static function randomseed ( local  x)

x 设为伪随机数发生器的“种子”:

相同的种子产生相同的随机数列。

Parameters
xnumber

◆ remainder()

static function remainder ( local  v1,
local  v2 
)

C++ std::remainder

C# Math.IEEERemainder

Parameters
v1number
v2number
Returns
number

◆ round()

static function round ( local  v)
Parameters
vnumber
Returns
number

◆ sin()

static function sin ( local  x)

返回 x 的正弦值(假定参数是弧度)。

Parameters
xnumber
Returns
number

◆ sinh()

static function sinh ( local  x)

返回 x 的双曲正弦值。

Parameters
xnumber
Returns
number

◆ smoothstep()

static function smoothstep ( local  v1,
local  v2,
local  a 
)

C# MathHelper.SmoothStep

Parameters
v1number
v2number
anumber
Returns
number

◆ solveLiner()

static function solveLiner ( local  a1,
local  b1,
local  c1,
local  a2,
local  b2,
local  c2 
)

solve:

a1 x + b1 y = c1

a2 x + b2 y = c2

Returns
number,number,boolean

◆ sqrt()

static function sqrt ( local  x)

返回 x 的平方根。

Parameters
xnumber
Returns
number

◆ tan()

static function tan ( local  x)

返回 x 的正切值(假定参数是弧度)。

Parameters
xnumber
Returns
number

◆ tanh()

static function tanh ( local  x)

返回 x 的双曲正切值。

Parameters
xnumber
Returns
number

◆ wrapangle()

static function wrapangle ( local  v)

C# MathHelper.WrapAngle

Returns
number
Parameters
vnumber

Member Data Documentation

◆ huge

number huge = inf

浮点数 HUGE_VAL, 这个数比任何数字值都大。

◆ M_1_PI

number M_1_PI = 0.318309886183790671538

1/pi

◆ M_2_PI

number M_2_PI = 0.636619772367581343076

2/pi

◆ M_2_SQRTPI

number M_2_SQRTPI = 1.12837916709551257390

2/sqrt(pi)

◆ M_E

number M_E = 2.71828182845904523536

math_const.lua

Copyright (C) 2018-2019 Xrysnow. All rights reserved.

e

◆ M_LN10

number M_LN10 = 2.30258509299404568402

ln(10)

◆ M_LN2

number M_LN2 = 0.693147180559945309417

ln(2)

◆ M_LOG10E

number M_LOG10E = 0.434294481903251827651

log10(e)

◆ M_LOG2E

number M_LOG2E = 1.44269504088896340736

log2(e)

◆ M_PI

number M_PI = 3.14159265358979323846

pi

◆ M_PI_2

number M_PI_2 = 1.57079632679489661923

pi/2

◆ M_PI_4

number M_PI_4 = 0.785398163397448309616

pi/4

◆ M_PIx2

number M_PIx2 = 6.28318530717958647693

pi*2

◆ M_PIx4

number M_PIx4 = 12.5663706143591729538

pi*4

◆ M_SQRT1_2

number M_SQRT1_2 = 0.707106781186547524401

1/sqrt(2)

◆ M_SQRT2

number M_SQRT2 = 1.41421356237309504880

sqrt(2)

◆ pi

number pi = 3.1415926535898

π的值。


The documentation for this class was generated from the following files: