mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
495 lines
4.8 KiB
Markdown
495 lines
4.8 KiB
Markdown
## 扩展数学函数
|
|
|
|
### 1.d2r
|
|
|
|
> 将角度转换成弧度,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
d2r(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(d2r(7));
|
|
```
|
|
|
|
### 2.r2d
|
|
|
|
> 将弧度转换成角度,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
r2d(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
r2d(7)
|
|
```
|
|
|
|
### 3.sin
|
|
|
|
> sin 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
sin(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(sin(0));
|
|
```
|
|
|
|
### 4.cos
|
|
|
|
> cos 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
cos(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(cos(0));
|
|
```
|
|
|
|
### 5.tan
|
|
|
|
> tan 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
tan(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(tan(1));
|
|
```
|
|
|
|
### 6.asin
|
|
|
|
> asin 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
asin(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(asin(1));
|
|
```
|
|
|
|
### 7.acos
|
|
|
|
> acos 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
acos(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(acos(1));
|
|
```
|
|
|
|
### 8.atan
|
|
|
|
> atan 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
atan(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(atan(1));
|
|
```
|
|
|
|
### 9.atan2
|
|
|
|
> atan2 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
atan2(a, b) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(atan2(2, 3));
|
|
```
|
|
|
|
### 10.sin_deg
|
|
|
|
> sin_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
sin_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(sin_deg(45));
|
|
```
|
|
|
|
### 11.cos_deg
|
|
|
|
> cos_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
cos_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(cos_deg(45));
|
|
```
|
|
|
|
### 12.tan_deg
|
|
|
|
> tan_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
tan_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(tan_deg(30));
|
|
```
|
|
|
|
### 13.asin_deg
|
|
|
|
> asin_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
asin_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(asin_deg(45));
|
|
```
|
|
|
|
### 14.acos_deg
|
|
|
|
> acos_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
acos_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(acos_deg(45));
|
|
```
|
|
|
|
### 15.atan_deg
|
|
|
|
> atan_deg 函数,传入参数单位是角度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
atan_deg(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(atan_deg(30));
|
|
```
|
|
|
|
### 16.atan2_deg
|
|
|
|
> atan2_deg 函数,传入参数单位是弧度。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
atan2_deg(a, b) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(atan2_deg(20, 30));
|
|
```
|
|
|
|
### 17.exp
|
|
|
|
> exp 函数
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
exp(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(exp(7));
|
|
```
|
|
|
|
### 18.sqrt
|
|
|
|
> sqrt 函数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
sqrt(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(sqrt(2));
|
|
```
|
|
|
|
### 19.pow
|
|
|
|
> pow 函数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
pow(a, b) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(pow(2, 3));
|
|
```
|
|
|
|
### 20.log10
|
|
|
|
> log10 函数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
log10(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(log10(9));
|
|
```
|
|
|
|
### 21.logf
|
|
|
|
> logf 函数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
logf(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(logf(0));
|
|
```
|
|
|
|
### 22.pow10
|
|
|
|
> pow10 函数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
pow10(a) => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(pow10(2));
|
|
```
|
|
|
|
### 23.is_prime
|
|
|
|
> 是否为质数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_prime(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_prime(7));
|
|
```
|
|
|
|
### 24.is_int
|
|
|
|
> 是否为整数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_int(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_int(7));
|
|
```
|
|
|
|
### 25.is_odd
|
|
|
|
> 是否为奇数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_odd(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_odd(7));
|
|
```
|
|
|
|
### 26.is_even
|
|
|
|
> 是否为偶数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_even(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_even(7));
|
|
```
|
|
|
|
### 27.is_negative
|
|
|
|
> 是否为负数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_negative(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_negative(7));
|
|
```
|
|
|
|
### 28.is_positive
|
|
|
|
> 是否为正数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
is_positive(a) => bool
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(is_positive(7));
|
|
```
|
|
|
|
### 29.random0to1
|
|
|
|
> 生成一个0到1之间的随机数。
|
|
----------------------------
|
|
|
|
#### 原型
|
|
|
|
```js
|
|
random0to1() => double
|
|
```
|
|
|
|
#### 示例
|
|
|
|
```js
|
|
print(random0to1());
|
|
```
|