forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMath.js
More file actions
73 lines (63 loc) · 2.56 KB
/
Copy pathMath.js
File metadata and controls
73 lines (63 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
/**
* @private
* @class SuperMap.LevelRenderer.Tool.Math
* @category Visualization Theme
* @classdesc LevelRenderer 工具-数学辅助类
*/
export class MathTool {
/**
* @function SuperMap.LevelRenderer.Tool.Math.constructor
* @description 构造函数。
*/
constructor() {
/**
* @member {number} SuperMap.LevelRenderer.Tool.Math._radians
* @description 角度与弧度转化参数
*/
this._radians = window.Math.PI / 180;
this.CLASS_NAME = "SuperMap.LevelRenderer.Tool.Math";
}
/**
* @function SuperMap.LevelRenderer.Tool.Math.prototype.sin
* @description 正弦函数。
* @param {number} angle - 弧度(角度)参数。
* @param {boolean} [isDegrees=false] - angle参数是否为角度计算,angle为以弧度计量的角度。
* @returns {number} sin 值。
*/
sin(angle, isDegrees) {
return window.Math.sin(isDegrees ? angle * this._radians : angle);
}
/**
* @function SuperMap.LevelRenderer.Tool.Math.prototype.cos
* @description 余弦函数。
* @param {number} angle - 弧度(角度)参数。
* @param {boolean} [isDegrees=false] - angle参数是否为角度计算,angle为以弧度计量的角度。
* @returns {number} cos 值。
*/
cos(angle, isDegrees) {
return window.Math.cos(isDegrees ? angle * this._radians : angle);
}
/**
* @function SuperMap.LevelRenderer.Tool.Math.prototype.degreeToRadian
* @description 角度转弧度。
* @param {number} angle - 弧度(角度)参数。
* @param {boolean} [isDegrees=false] - angle参数是否为角度计算,angle为以弧度计量的角度。
* @returns {number} 弧度值。
*/
degreeToRadian(angle) {
return angle * this._radians;
}
/**
* @function SuperMap.LevelRenderer.Tool.Math.prototype.radianToDegree
* @description 弧度转角度。
* @param {number} angle - 弧度(角度)参数。
* @param {boolean} [isDegrees=false] - angle参数是否为角度计算,angle为以弧度计量的角度。
* @returns {number} 角度。
*/
radianToDegree(angle) {
return angle / this._radians;
}
}