mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
一些数学函数。
This commit is contained in:
parent
4604810a59
commit
a6e77c3d25
@ -1,29 +1,60 @@
|
||||
import WGS84 from '../core/WGS84';
|
||||
|
||||
/**
|
||||
* 经纬度、海拔转笛卡尔坐标
|
||||
* @param {THREE.Vector3} lonlat 经纬度、海拔
|
||||
* @param {THREE.Vector3} xyz 笛卡尔坐标
|
||||
*/
|
||||
function lonlatToXYZ(lonlat, xyz) {
|
||||
var lon = lonlat.x * Math.PI / 180;
|
||||
var lat = lonlat.y * Math.PI / 180;
|
||||
var r = WGS84.a + lonlat.z;
|
||||
|
||||
xyz.set(
|
||||
r * Math.cos(lat) * Math.cos(lon),
|
||||
r * Math.cos(lat) * Math.sin(lon),
|
||||
r * Math.sin(lat),
|
||||
);
|
||||
|
||||
return xyz;
|
||||
}
|
||||
|
||||
/**
|
||||
* 笛卡尔坐标转经纬度
|
||||
* @param {THREE.Vector3} xyz
|
||||
* @param {THREE.Vector3} lonlat
|
||||
*/
|
||||
function xyzToLonlat(xyz, lonlat) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 层级转海拔
|
||||
* @param {*} zoom
|
||||
*/
|
||||
function zoomToAltitude(zoom) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 海拔转层级
|
||||
* @param {*} alt
|
||||
*/
|
||||
function altitudeToZoom(alt) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 数学工具
|
||||
*/
|
||||
var MathUtils = {
|
||||
/**
|
||||
* 经纬度海拔转笛卡尔坐标
|
||||
*/
|
||||
lonlatToXYZ: function (lon, lat, alt) {
|
||||
lonlatToXYZ,
|
||||
|
||||
},
|
||||
xyzToLonlat,
|
||||
|
||||
/**
|
||||
* 笛卡尔坐标转经纬度
|
||||
*/
|
||||
xyzToLonlat: function (x, y, z) {
|
||||
zoomToAltitude,
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 层级转相机到地球表面距离
|
||||
*/
|
||||
zoomToDistance: function (zoom) {
|
||||
return 7820683 / Math.pow(2, level);
|
||||
}
|
||||
altitudeToZoom,
|
||||
};
|
||||
|
||||
export default MathUtils;
|
||||
Loading…
x
Reference in New Issue
Block a user