## 悢妛娭悢乮Math乯

[up] [prev] [next]

#### 仭 堦棗

abs(), acos(), asin(), atan(), atan2(), ceil(), cos(), E, exp(), floor(), LN10, LN2, log(), LOG10E, LOG2E, Math, max(), min(), PI, pow(), random(), round(), sin(), sqrt(), SQRT1_2, SQRT2, tan()

#### 仭 悢妛娭悢

仧 Math (e3/N3)

悢妛娭楢偺儊僜僢僪傗僾儘僷僥傿傪幚憰偡傞僆僽僕僃僋僩偱偡丅

#### 仭 棎悢

仧 Math.random() (e3/N3)

0埲忋丄1枹枮偺棎悢傪惗惉偟傑偡丅椺偊偽師偺傛偆偵偟偰丄0乣15偺棎悢傪惗惉偡傞偙偲偑偱偒傑偡丅

    xx = Math.floor(Math.random() * 16);

#### 仭 孞傝忋偘丒孞傝壓偘丒愨懳抣

仧 Math.ceil(n) (e3/N2)
仧 Math.floor(n) (e3/N2)
仧 Math.round(n) (e3/N2)

ceil() 偼 n 偺彫悢揰埲壓傪孞傝忋偘偨惍悢抣丄floor() 偼孞傝壓偘偨惍悢抣丄round() 偼巐幪屲擖偟偨惍悢抣傪曉偟傑偡丅

仧 Math.abs(n) (e3/N2)

n 偺愨懳抣傪曉偟傑偡丅

    xx = Math.abs(-8);

#### 仭 嶰妏娭悢

仧 Math.sin(x) (e3/N2)
仧 Math.cos(x) (e3/N2)
仧 Math.tan(x) (e3/N2)

x 偺惓尫乮-1乣1乯丄梋尫乮-1乣1乯丄惓愙乮-亣乣亣乯丅x 偼儔僕傾儞扨埵乮0搙偼0丄90搙偼兾/2丄180搙偼兾乯偱巜掕偟傑偡丅

    r = 10.0;  // 敿宎
    a = 30.0;  // 妏搙乮搙乯
    x = r * Math.cos(a / 180 * Math.PI);  // X嵗昗
    y = r * Math.sin(a / 180 * Math.PI);  // Y嵗昗

仧 Math.asin(x) (e3/N2)
仧 Math.acos(x) (e3/N2)
仧 Math.atan(x) (e3/N2)

x 偺媡惓尫乮-兾/2乣兾/2乯丄媡梋尫乮0乣兾乯丄媡惓愙乮-兾/2乣兾/2乯丅

仧 Math.atan2(y, x) (e3/N2)

嵗昗 x, y 偺妏搙(-兾乣兾)丅

仧 Math.PI (e3/N2)

墌廃棪兾(栺3.141592)丅

#### 仭 偦偺懠

仧 Math.max(x, y) (e3/N2)
仧 Math.min(x, y) (e3/N2)

max() 偼 x 偲 y 偺戝偒偄曽丄min() 偼 x 偲 y 偺彫偝偄曽丅

仧 Math.pow(n, m) (e3/N2)

n 偺 m 忔丅

仧 Math.sqrt(n) (e3/N2)

n 偺暯曽崻丅

仧 Math.SQRT2 (e3/N2)
仧 Math.SQRT1_2 (e3/N2)

SQRT2 偼 2 偺暯曽崻乮栺1.414乯丅SQRT1_2 偼 1/2 偺暯曽崻(栺0.707)丅

仧 Math.E (e3/N2)

帺慠懳悢 e 偺抣丅栺2.718丅

仧 Math.LN2 (e3/N2)
仧 Math.LN10 (e3/N2)
仧 Math.LOG2E (e3/N2)
仧 Math.LOG10E (e3/N2)

LN2 偼 e 傪掙偲偟偨2偺懳悢(栺0.693)丄LN10 偼 e 傪掙偲偟偨10偺懳悢(栺2.302)丄LOG2E 偼 2 傪掙偲偟偨 e 偺懳悢(栺1.442)丄LOG10E 偼 10 傪掙偲偟偨 e 偺懳悢(栺0.434)丅

仧 Math.exp(n) (e3/N2)

e 偺 n 忔丅

仧 Math.log(n) (e3/N2)

e 傪掙偲偟偨 n 偺懳悢丅

[up] [prev] [next]
Copyright (C) 1996-2002 搈曖乆
夵掶斉弶斉丗2002擭11寧30擔
http://www.tohoho-web.com/js/math.htm