vislite
Version:
灵活、快速、简单的数据可视化交互式跨端前端库
40 lines (38 loc) • 1.31 kB
JavaScript
/*!
* Eoap of VISLite JavaScript Library v1.3.0
* git+https://github.com/oi-contrib/VISLite.git
*/
var rotateX = function (deg, x, y, z) {
var cos = Math.cos(deg), sin = Math.sin(deg);
return [x, y * cos - z * sin, y * sin + z * cos];
};
var rotateY = function (deg, x, y, z) {
var cos = Math.cos(deg), sin = Math.sin(deg);
return [z * sin + x * cos, y, z * cos - x * sin];
};
var rotateZ = function (deg, x, y, z) {
var cos = Math.cos(deg), sin = Math.sin(deg);
return [x * cos - y * sin, x * sin + y * cos, z];
};
var Eoap = (function () {
function Eoap(scale, center) {
if (scale === void 0) { scale = 7; }
if (center === void 0) { center = [107, 36]; }
this.name = 'Eoap';
this.__scale = scale;
this.__center = center;
}
Eoap.prototype.use = function (λ, φ) {
var p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0);
p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2]);
p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2]);
p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2]);
return [
-p[0],
p[1],
p[2]
];
};
return Eoap;
}());
export { Eoap as default };