@pggis/pg-sdk 3.3.9 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.js +1966 -4
- package/dist/pggis.min.css +1 -1
- package/dist/resources/ThirdParty/Workers/pako_deflate.min.js +1 -2
- package/dist/resources/ThirdParty/Workers/pako_inflate.min.js +1 -2
- package/dist/resources/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/dist/resources/ThirdParty/google-earth-dbroot-parser.js +1 -8337
- package/dist/resources/ThirdParty/wasm_splats_bg.wasm +0 -0
- package/dist/resources/Workers/chunk-35SHYARM.js +26 -0
- package/dist/resources/Workers/chunk-37F5JSTI.js +26 -0
- package/dist/resources/Workers/chunk-3SSKC3VN.js +26 -0
- package/dist/resources/Workers/chunk-3W4GT7KQ.js +26 -0
- package/dist/resources/Workers/chunk-4IW2T6GF.js +26 -0
- package/dist/resources/Workers/chunk-5YEWO3HT.js +26 -0
- package/dist/resources/Workers/chunk-64RSHJUE.js +28 -0
- package/dist/resources/Workers/chunk-77IHZJJ3.js +26 -0
- package/dist/resources/Workers/chunk-7HTKERZY.js +26 -0
- package/dist/resources/Workers/{chunk-F3YA3Y2Z.js → chunk-A56XVLQR.js} +2 -13
- package/dist/resources/Workers/chunk-AJYK4IVJ.js +26 -0
- package/dist/resources/Workers/{chunk-EHWHNOEX.js → chunk-ARG42DC4.js} +2 -31
- package/dist/resources/Workers/chunk-AU7IKHOH.js +26 -0
- package/dist/resources/Workers/chunk-B4AA3ARO.js +26 -0
- package/dist/resources/Workers/chunk-CNCV5UL7.js +26 -0
- package/dist/resources/Workers/chunk-CYCB63OH.js +26 -0
- package/dist/resources/Workers/{chunk-4H7PY4U5.js → chunk-D6AA5QVT.js} +2 -20
- package/dist/resources/Workers/chunk-D6C66QON.js +26 -0
- package/dist/resources/Workers/chunk-DEPHB2WM.js +26 -0
- package/dist/resources/Workers/chunk-DMEY62ID.js +26 -0
- package/dist/resources/Workers/chunk-DQQ63PYM.js +26 -0
- package/dist/resources/Workers/chunk-ED5JPB3S.js +27 -0
- package/dist/resources/Workers/chunk-EZUYS2JF.js +26 -0
- package/dist/resources/Workers/chunk-FEVXJ54I.js +26 -0
- package/dist/resources/Workers/chunk-G5AGHVVC.js +26 -0
- package/dist/resources/Workers/{chunk-BBWDMCVU.js → chunk-GBYLG25F.js} +2 -15
- package/dist/resources/Workers/chunk-GILIDQNQ.js +26 -0
- package/dist/resources/Workers/chunk-HMIYSTF6.js +26 -0
- package/dist/resources/Workers/chunk-HTFSEEMT.js +26 -0
- package/dist/resources/Workers/chunk-HWXX4CWK.js +26 -0
- package/dist/resources/Workers/chunk-IYTZ52EY.js +26 -0
- package/dist/resources/Workers/chunk-J6UP6FLE.js +26 -0
- package/dist/resources/Workers/chunk-LEYMRMBK.js +27 -0
- package/dist/resources/Workers/chunk-M3MGYQSL.js +26 -0
- package/dist/resources/Workers/chunk-N4VJKXZS.js +26 -0
- package/dist/resources/Workers/chunk-NB3ML6JO.js +26 -0
- package/dist/resources/Workers/chunk-OFUUQVMR.js +26 -0
- package/dist/resources/Workers/chunk-OSW76XDF.js +26 -0
- package/dist/resources/Workers/chunk-PSPPBZWI.js +66 -0
- package/dist/resources/Workers/chunk-QN3VOORQ.js +26 -0
- package/dist/resources/Workers/chunk-QOUAJ6TL.js +26 -0
- package/dist/resources/Workers/chunk-RCV6KWXS.js +26 -0
- package/dist/resources/Workers/chunk-TCGIRNHN.js +26 -0
- package/dist/resources/Workers/chunk-U4IEOH5K.js +26 -0
- package/dist/resources/Workers/chunk-UP6I5URU.js +26 -0
- package/dist/resources/Workers/chunk-VTAIKJXX.js +26 -0
- package/dist/resources/Workers/chunk-VTBDSFTG.js +26 -0
- package/dist/resources/Workers/chunk-VW6VD53G.js +26 -0
- package/dist/resources/Workers/chunk-WGGIH7QW.js +26 -0
- package/dist/resources/Workers/chunk-WWA5PL4H.js +26 -0
- package/dist/resources/Workers/chunk-WZDE3RYP.js +28 -0
- package/dist/resources/Workers/chunk-XRL4AVS5.js +26 -0
- package/dist/resources/Workers/combineGeometry.js +2 -44
- package/dist/resources/Workers/createBoxGeometry.js +2 -34
- package/dist/resources/Workers/createBoxOutlineGeometry.js +2 -211
- package/dist/resources/Workers/createCircleGeometry.js +2 -173
- package/dist/resources/Workers/createCircleOutlineGeometry.js +2 -123
- package/dist/resources/Workers/createCoplanarPolygonGeometry.js +2 -482
- package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +2 -201
- package/dist/resources/Workers/createCorridorGeometry.js +2 -1239
- package/dist/resources/Workers/createCorridorOutlineGeometry.js +2 -544
- package/dist/resources/Workers/createCylinderGeometry.js +2 -36
- package/dist/resources/Workers/createCylinderOutlineGeometry.js +2 -207
- package/dist/resources/Workers/createEllipseGeometry.js +2 -47
- package/dist/resources/Workers/createEllipseOutlineGeometry.js +2 -40
- package/dist/resources/Workers/createEllipsoidGeometry.js +2 -35
- package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +2 -37
- package/dist/resources/Workers/createFrustumGeometry.js +2 -34
- package/dist/resources/Workers/createFrustumOutlineGeometry.js +2 -211
- package/dist/resources/Workers/createGeometry.js +2 -147
- package/dist/resources/Workers/createGroundPolylineGeometry.js +2 -1584
- package/dist/resources/Workers/createPlaneGeometry.js +2 -200
- package/dist/resources/Workers/createPlaneOutlineGeometry.js +2 -100
- package/dist/resources/Workers/createPolygonGeometry.js +2 -1387
- package/dist/resources/Workers/createPolygonOutlineGeometry.js +2 -519
- package/dist/resources/Workers/createPolylineGeometry.js +2 -472
- package/dist/resources/Workers/createPolylineVolumeGeometry.js +2 -355
- package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +2 -253
- package/dist/resources/Workers/createRectangleGeometry.js +2 -1250
- package/dist/resources/Workers/createRectangleOutlineGeometry.js +2 -455
- package/dist/resources/Workers/createSimplePolylineGeometry.js +2 -376
- package/dist/resources/Workers/createSphereGeometry.js +2 -94
- package/dist/resources/Workers/createSphereOutlineGeometry.js +2 -94
- package/dist/resources/Workers/createTaskProcessorWorker.js +2 -8
- package/dist/resources/Workers/createVectorTileClampedPolylines.js +2 -468
- package/dist/resources/Workers/createVectorTileGeometries.js +2 -363
- package/dist/resources/Workers/createVectorTilePoints.js +2 -88
- package/dist/resources/Workers/createVectorTilePolygons.js +2 -361
- package/dist/resources/Workers/createVectorTilePolylines.js +2 -238
- package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +2 -545
- package/dist/resources/Workers/createVerticesFromHeightmap.js +2 -2254
- package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +2 -722
- package/dist/resources/Workers/createWallGeometry.js +2 -466
- package/dist/resources/Workers/createWallOutlineGeometry.js +2 -314
- package/dist/resources/Workers/decodeDraco.js +2 -345
- package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2626
- package/dist/resources/Workers/decodeI3S.js +2 -1320
- package/dist/resources/Workers/gaussianSplatSorter.js +26 -0
- package/dist/resources/Workers/gaussianSplatTextureGenerator.js +26 -0
- package/dist/resources/Workers/transcodeKTX2.js +29 -3398
- package/dist/resources/Workers/transferTypedArrayTest.js +2 -17
- package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +2 -795
- package/package.json +9 -8
- package/dist/pggis.min.js +0 -14796
- package/dist/resources/ThirdParty/Workers/basis_transcoder.js +0 -21
- package/dist/resources/Workers/chunk-23UFSGND.js +0 -236
- package/dist/resources/Workers/chunk-2A75IWRS.js +0 -218
- package/dist/resources/Workers/chunk-2FRVPMCS.js +0 -1258
- package/dist/resources/Workers/chunk-2FWRMUTY.js +0 -138
- package/dist/resources/Workers/chunk-2UPKWTMJ.js +0 -117
- package/dist/resources/Workers/chunk-34FXV7D7.js +0 -73
- package/dist/resources/Workers/chunk-3VAZEH7M.js +0 -101
- package/dist/resources/Workers/chunk-4DO5W5XZ.js +0 -196
- package/dist/resources/Workers/chunk-5QULIR53.js +0 -501
- package/dist/resources/Workers/chunk-7TC63SJW.js +0 -302
- package/dist/resources/Workers/chunk-7ZFGPDJA.js +0 -122
- package/dist/resources/Workers/chunk-A5DWLWCY.js +0 -834
- package/dist/resources/Workers/chunk-BG4UCVXN.js +0 -73
- package/dist/resources/Workers/chunk-BIKA3NRA.js +0 -59
- package/dist/resources/Workers/chunk-BROJAZRZ.js +0 -390
- package/dist/resources/Workers/chunk-DDUQAJ4P.js +0 -476
- package/dist/resources/Workers/chunk-EERJKOAF.js +0 -305
- package/dist/resources/Workers/chunk-EG6PTBY2.js +0 -2716
- package/dist/resources/Workers/chunk-F4HFJMGM.js +0 -353
- package/dist/resources/Workers/chunk-FJKNFAKQ.js +0 -8219
- package/dist/resources/Workers/chunk-FNIRWHJB.js +0 -289
- package/dist/resources/Workers/chunk-FZRIVR7Y.js +0 -100
- package/dist/resources/Workers/chunk-G43QFN4Q.js +0 -157
- package/dist/resources/Workers/chunk-GATZHF3K.js +0 -1860
- package/dist/resources/Workers/chunk-GRC2ZTAF.js +0 -398
- package/dist/resources/Workers/chunk-HU6N6EXB.js +0 -767
- package/dist/resources/Workers/chunk-I46ZRR5W.js +0 -1052
- package/dist/resources/Workers/chunk-JURN7NPV.js +0 -1075
- package/dist/resources/Workers/chunk-KKCR2YOP.js +0 -421
- package/dist/resources/Workers/chunk-LPR3YNP2.js +0 -138
- package/dist/resources/Workers/chunk-M7ERACJJ.js +0 -511
- package/dist/resources/Workers/chunk-MDWEGWPA.js +0 -1007
- package/dist/resources/Workers/chunk-OGXZVPPM.js +0 -2365
- package/dist/resources/Workers/chunk-PGSJK77E.js +0 -634
- package/dist/resources/Workers/chunk-PPH7OFP3.js +0 -258
- package/dist/resources/Workers/chunk-SH5USDPI.js +0 -456
- package/dist/resources/Workers/chunk-SOWMRMWA.js +0 -629
- package/dist/resources/Workers/chunk-STW2DGFI.js +0 -58
- package/dist/resources/Workers/chunk-T3XIFPYR.js +0 -1477
- package/dist/resources/Workers/chunk-TTUZP4BO.js +0 -501
- package/dist/resources/Workers/chunk-UEXTBDBE.js +0 -693
- package/dist/resources/Workers/chunk-VOXYEYJT.js +0 -684
- package/dist/resources/Workers/chunk-X4356LRH.js +0 -368
- package/dist/resources/Workers/chunk-XGI5BXZY.js +0 -163
- package/dist/resources/Workers/chunk-Y2ME2IJV.js +0 -781
- package/dist/resources/Workers/chunk-Y5UQJLYE.js +0 -171
- package/dist/resources/Workers/chunk-YJEBABKH.js +0 -2977
- package/dist/resources/Workers/chunk-YWTJ2B4B.js +0 -77
- package/dist/resources/Workers/chunk-Z3TIFFGF.js +0 -430
- package/dist/resources/Workers/chunk-ZT7KWISZ.js +0 -102
|
@@ -1,2365 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Cesium - https://github.com/CesiumGS/cesium
|
|
4
|
-
* Version 1.115
|
|
5
|
-
*
|
|
6
|
-
* Copyright 2011-2022 Cesium Contributors
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*
|
|
20
|
-
* Columbus View (Pat. Pend.)
|
|
21
|
-
*
|
|
22
|
-
* Portions licensed separately.
|
|
23
|
-
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
Math_default
|
|
28
|
-
} from "./chunk-5QULIR53.js";
|
|
29
|
-
import {
|
|
30
|
-
defaultValue_default
|
|
31
|
-
} from "./chunk-BBWDMCVU.js";
|
|
32
|
-
import {
|
|
33
|
-
Check_default,
|
|
34
|
-
DeveloperError_default
|
|
35
|
-
} from "./chunk-XGI5BXZY.js";
|
|
36
|
-
import {
|
|
37
|
-
defined_default
|
|
38
|
-
} from "./chunk-YWTJ2B4B.js";
|
|
39
|
-
|
|
40
|
-
// packages/engine/Source/Core/Cartesian3.js
|
|
41
|
-
function Cartesian3(x, y, z) {
|
|
42
|
-
this.x = defaultValue_default(x, 0);
|
|
43
|
-
this.y = defaultValue_default(y, 0);
|
|
44
|
-
this.z = defaultValue_default(z, 0);
|
|
45
|
-
}
|
|
46
|
-
Cartesian3.fromSpherical = function(spherical, result) {
|
|
47
|
-
Check_default.typeOf.object("spherical", spherical);
|
|
48
|
-
if (!defined_default(result)) {
|
|
49
|
-
result = new Cartesian3();
|
|
50
|
-
}
|
|
51
|
-
const clock = spherical.clock;
|
|
52
|
-
const cone = spherical.cone;
|
|
53
|
-
const magnitude = defaultValue_default(spherical.magnitude, 1);
|
|
54
|
-
const radial = magnitude * Math.sin(cone);
|
|
55
|
-
result.x = radial * Math.cos(clock);
|
|
56
|
-
result.y = radial * Math.sin(clock);
|
|
57
|
-
result.z = magnitude * Math.cos(cone);
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
Cartesian3.fromElements = function(x, y, z, result) {
|
|
61
|
-
if (!defined_default(result)) {
|
|
62
|
-
return new Cartesian3(x, y, z);
|
|
63
|
-
}
|
|
64
|
-
result.x = x;
|
|
65
|
-
result.y = y;
|
|
66
|
-
result.z = z;
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
Cartesian3.clone = function(cartesian, result) {
|
|
70
|
-
if (!defined_default(cartesian)) {
|
|
71
|
-
return void 0;
|
|
72
|
-
}
|
|
73
|
-
if (!defined_default(result)) {
|
|
74
|
-
return new Cartesian3(cartesian.x, cartesian.y, cartesian.z);
|
|
75
|
-
}
|
|
76
|
-
result.x = cartesian.x;
|
|
77
|
-
result.y = cartesian.y;
|
|
78
|
-
result.z = cartesian.z;
|
|
79
|
-
return result;
|
|
80
|
-
};
|
|
81
|
-
Cartesian3.fromCartesian4 = Cartesian3.clone;
|
|
82
|
-
Cartesian3.packedLength = 3;
|
|
83
|
-
Cartesian3.pack = function(value, array, startingIndex) {
|
|
84
|
-
Check_default.typeOf.object("value", value);
|
|
85
|
-
Check_default.defined("array", array);
|
|
86
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
87
|
-
array[startingIndex++] = value.x;
|
|
88
|
-
array[startingIndex++] = value.y;
|
|
89
|
-
array[startingIndex] = value.z;
|
|
90
|
-
return array;
|
|
91
|
-
};
|
|
92
|
-
Cartesian3.unpack = function(array, startingIndex, result) {
|
|
93
|
-
Check_default.defined("array", array);
|
|
94
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
95
|
-
if (!defined_default(result)) {
|
|
96
|
-
result = new Cartesian3();
|
|
97
|
-
}
|
|
98
|
-
result.x = array[startingIndex++];
|
|
99
|
-
result.y = array[startingIndex++];
|
|
100
|
-
result.z = array[startingIndex];
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
Cartesian3.packArray = function(array, result) {
|
|
104
|
-
Check_default.defined("array", array);
|
|
105
|
-
const length = array.length;
|
|
106
|
-
const resultLength = length * 3;
|
|
107
|
-
if (!defined_default(result)) {
|
|
108
|
-
result = new Array(resultLength);
|
|
109
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
110
|
-
throw new DeveloperError_default(
|
|
111
|
-
"If result is a typed array, it must have exactly array.length * 3 elements"
|
|
112
|
-
);
|
|
113
|
-
} else if (result.length !== resultLength) {
|
|
114
|
-
result.length = resultLength;
|
|
115
|
-
}
|
|
116
|
-
for (let i = 0; i < length; ++i) {
|
|
117
|
-
Cartesian3.pack(array[i], result, i * 3);
|
|
118
|
-
}
|
|
119
|
-
return result;
|
|
120
|
-
};
|
|
121
|
-
Cartesian3.unpackArray = function(array, result) {
|
|
122
|
-
Check_default.defined("array", array);
|
|
123
|
-
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 3);
|
|
124
|
-
if (array.length % 3 !== 0) {
|
|
125
|
-
throw new DeveloperError_default("array length must be a multiple of 3.");
|
|
126
|
-
}
|
|
127
|
-
const length = array.length;
|
|
128
|
-
if (!defined_default(result)) {
|
|
129
|
-
result = new Array(length / 3);
|
|
130
|
-
} else {
|
|
131
|
-
result.length = length / 3;
|
|
132
|
-
}
|
|
133
|
-
for (let i = 0; i < length; i += 3) {
|
|
134
|
-
const index = i / 3;
|
|
135
|
-
result[index] = Cartesian3.unpack(array, i, result[index]);
|
|
136
|
-
}
|
|
137
|
-
return result;
|
|
138
|
-
};
|
|
139
|
-
Cartesian3.fromArray = Cartesian3.unpack;
|
|
140
|
-
Cartesian3.maximumComponent = function(cartesian) {
|
|
141
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
142
|
-
return Math.max(cartesian.x, cartesian.y, cartesian.z);
|
|
143
|
-
};
|
|
144
|
-
Cartesian3.minimumComponent = function(cartesian) {
|
|
145
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
146
|
-
return Math.min(cartesian.x, cartesian.y, cartesian.z);
|
|
147
|
-
};
|
|
148
|
-
Cartesian3.minimumByComponent = function(first, second, result) {
|
|
149
|
-
Check_default.typeOf.object("first", first);
|
|
150
|
-
Check_default.typeOf.object("second", second);
|
|
151
|
-
Check_default.typeOf.object("result", result);
|
|
152
|
-
result.x = Math.min(first.x, second.x);
|
|
153
|
-
result.y = Math.min(first.y, second.y);
|
|
154
|
-
result.z = Math.min(first.z, second.z);
|
|
155
|
-
return result;
|
|
156
|
-
};
|
|
157
|
-
Cartesian3.maximumByComponent = function(first, second, result) {
|
|
158
|
-
Check_default.typeOf.object("first", first);
|
|
159
|
-
Check_default.typeOf.object("second", second);
|
|
160
|
-
Check_default.typeOf.object("result", result);
|
|
161
|
-
result.x = Math.max(first.x, second.x);
|
|
162
|
-
result.y = Math.max(first.y, second.y);
|
|
163
|
-
result.z = Math.max(first.z, second.z);
|
|
164
|
-
return result;
|
|
165
|
-
};
|
|
166
|
-
Cartesian3.clamp = function(value, min, max, result) {
|
|
167
|
-
Check_default.typeOf.object("value", value);
|
|
168
|
-
Check_default.typeOf.object("min", min);
|
|
169
|
-
Check_default.typeOf.object("max", max);
|
|
170
|
-
Check_default.typeOf.object("result", result);
|
|
171
|
-
const x = Math_default.clamp(value.x, min.x, max.x);
|
|
172
|
-
const y = Math_default.clamp(value.y, min.y, max.y);
|
|
173
|
-
const z = Math_default.clamp(value.z, min.z, max.z);
|
|
174
|
-
result.x = x;
|
|
175
|
-
result.y = y;
|
|
176
|
-
result.z = z;
|
|
177
|
-
return result;
|
|
178
|
-
};
|
|
179
|
-
Cartesian3.magnitudeSquared = function(cartesian) {
|
|
180
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
181
|
-
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z;
|
|
182
|
-
};
|
|
183
|
-
Cartesian3.magnitude = function(cartesian) {
|
|
184
|
-
return Math.sqrt(Cartesian3.magnitudeSquared(cartesian));
|
|
185
|
-
};
|
|
186
|
-
var distanceScratch = new Cartesian3();
|
|
187
|
-
Cartesian3.distance = function(left, right) {
|
|
188
|
-
Check_default.typeOf.object("left", left);
|
|
189
|
-
Check_default.typeOf.object("right", right);
|
|
190
|
-
Cartesian3.subtract(left, right, distanceScratch);
|
|
191
|
-
return Cartesian3.magnitude(distanceScratch);
|
|
192
|
-
};
|
|
193
|
-
Cartesian3.distanceSquared = function(left, right) {
|
|
194
|
-
Check_default.typeOf.object("left", left);
|
|
195
|
-
Check_default.typeOf.object("right", right);
|
|
196
|
-
Cartesian3.subtract(left, right, distanceScratch);
|
|
197
|
-
return Cartesian3.magnitudeSquared(distanceScratch);
|
|
198
|
-
};
|
|
199
|
-
Cartesian3.normalize = function(cartesian, result) {
|
|
200
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
201
|
-
Check_default.typeOf.object("result", result);
|
|
202
|
-
const magnitude = Cartesian3.magnitude(cartesian);
|
|
203
|
-
result.x = cartesian.x / magnitude;
|
|
204
|
-
result.y = cartesian.y / magnitude;
|
|
205
|
-
result.z = cartesian.z / magnitude;
|
|
206
|
-
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z)) {
|
|
207
|
-
throw new DeveloperError_default("normalized result is not a number");
|
|
208
|
-
}
|
|
209
|
-
return result;
|
|
210
|
-
};
|
|
211
|
-
Cartesian3.dot = function(left, right) {
|
|
212
|
-
Check_default.typeOf.object("left", left);
|
|
213
|
-
Check_default.typeOf.object("right", right);
|
|
214
|
-
return left.x * right.x + left.y * right.y + left.z * right.z;
|
|
215
|
-
};
|
|
216
|
-
Cartesian3.multiplyComponents = function(left, right, result) {
|
|
217
|
-
Check_default.typeOf.object("left", left);
|
|
218
|
-
Check_default.typeOf.object("right", right);
|
|
219
|
-
Check_default.typeOf.object("result", result);
|
|
220
|
-
result.x = left.x * right.x;
|
|
221
|
-
result.y = left.y * right.y;
|
|
222
|
-
result.z = left.z * right.z;
|
|
223
|
-
return result;
|
|
224
|
-
};
|
|
225
|
-
Cartesian3.divideComponents = function(left, right, result) {
|
|
226
|
-
Check_default.typeOf.object("left", left);
|
|
227
|
-
Check_default.typeOf.object("right", right);
|
|
228
|
-
Check_default.typeOf.object("result", result);
|
|
229
|
-
result.x = left.x / right.x;
|
|
230
|
-
result.y = left.y / right.y;
|
|
231
|
-
result.z = left.z / right.z;
|
|
232
|
-
return result;
|
|
233
|
-
};
|
|
234
|
-
Cartesian3.add = function(left, right, result) {
|
|
235
|
-
Check_default.typeOf.object("left", left);
|
|
236
|
-
Check_default.typeOf.object("right", right);
|
|
237
|
-
Check_default.typeOf.object("result", result);
|
|
238
|
-
result.x = left.x + right.x;
|
|
239
|
-
result.y = left.y + right.y;
|
|
240
|
-
result.z = left.z + right.z;
|
|
241
|
-
return result;
|
|
242
|
-
};
|
|
243
|
-
Cartesian3.subtract = function(left, right, result) {
|
|
244
|
-
Check_default.typeOf.object("left", left);
|
|
245
|
-
Check_default.typeOf.object("right", right);
|
|
246
|
-
Check_default.typeOf.object("result", result);
|
|
247
|
-
result.x = left.x - right.x;
|
|
248
|
-
result.y = left.y - right.y;
|
|
249
|
-
result.z = left.z - right.z;
|
|
250
|
-
return result;
|
|
251
|
-
};
|
|
252
|
-
Cartesian3.multiplyByScalar = function(cartesian, scalar, result) {
|
|
253
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
254
|
-
Check_default.typeOf.number("scalar", scalar);
|
|
255
|
-
Check_default.typeOf.object("result", result);
|
|
256
|
-
result.x = cartesian.x * scalar;
|
|
257
|
-
result.y = cartesian.y * scalar;
|
|
258
|
-
result.z = cartesian.z * scalar;
|
|
259
|
-
return result;
|
|
260
|
-
};
|
|
261
|
-
Cartesian3.divideByScalar = function(cartesian, scalar, result) {
|
|
262
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
263
|
-
Check_default.typeOf.number("scalar", scalar);
|
|
264
|
-
Check_default.typeOf.object("result", result);
|
|
265
|
-
result.x = cartesian.x / scalar;
|
|
266
|
-
result.y = cartesian.y / scalar;
|
|
267
|
-
result.z = cartesian.z / scalar;
|
|
268
|
-
return result;
|
|
269
|
-
};
|
|
270
|
-
Cartesian3.negate = function(cartesian, result) {
|
|
271
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
272
|
-
Check_default.typeOf.object("result", result);
|
|
273
|
-
result.x = -cartesian.x;
|
|
274
|
-
result.y = -cartesian.y;
|
|
275
|
-
result.z = -cartesian.z;
|
|
276
|
-
return result;
|
|
277
|
-
};
|
|
278
|
-
Cartesian3.abs = function(cartesian, result) {
|
|
279
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
280
|
-
Check_default.typeOf.object("result", result);
|
|
281
|
-
result.x = Math.abs(cartesian.x);
|
|
282
|
-
result.y = Math.abs(cartesian.y);
|
|
283
|
-
result.z = Math.abs(cartesian.z);
|
|
284
|
-
return result;
|
|
285
|
-
};
|
|
286
|
-
var lerpScratch = new Cartesian3();
|
|
287
|
-
Cartesian3.lerp = function(start, end, t, result) {
|
|
288
|
-
Check_default.typeOf.object("start", start);
|
|
289
|
-
Check_default.typeOf.object("end", end);
|
|
290
|
-
Check_default.typeOf.number("t", t);
|
|
291
|
-
Check_default.typeOf.object("result", result);
|
|
292
|
-
Cartesian3.multiplyByScalar(end, t, lerpScratch);
|
|
293
|
-
result = Cartesian3.multiplyByScalar(start, 1 - t, result);
|
|
294
|
-
return Cartesian3.add(lerpScratch, result, result);
|
|
295
|
-
};
|
|
296
|
-
var angleBetweenScratch = new Cartesian3();
|
|
297
|
-
var angleBetweenScratch2 = new Cartesian3();
|
|
298
|
-
Cartesian3.angleBetween = function(left, right) {
|
|
299
|
-
Check_default.typeOf.object("left", left);
|
|
300
|
-
Check_default.typeOf.object("right", right);
|
|
301
|
-
Cartesian3.normalize(left, angleBetweenScratch);
|
|
302
|
-
Cartesian3.normalize(right, angleBetweenScratch2);
|
|
303
|
-
const cosine = Cartesian3.dot(angleBetweenScratch, angleBetweenScratch2);
|
|
304
|
-
const sine = Cartesian3.magnitude(
|
|
305
|
-
Cartesian3.cross(
|
|
306
|
-
angleBetweenScratch,
|
|
307
|
-
angleBetweenScratch2,
|
|
308
|
-
angleBetweenScratch
|
|
309
|
-
)
|
|
310
|
-
);
|
|
311
|
-
return Math.atan2(sine, cosine);
|
|
312
|
-
};
|
|
313
|
-
var mostOrthogonalAxisScratch = new Cartesian3();
|
|
314
|
-
Cartesian3.mostOrthogonalAxis = function(cartesian, result) {
|
|
315
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
316
|
-
Check_default.typeOf.object("result", result);
|
|
317
|
-
const f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);
|
|
318
|
-
Cartesian3.abs(f, f);
|
|
319
|
-
if (f.x <= f.y) {
|
|
320
|
-
if (f.x <= f.z) {
|
|
321
|
-
result = Cartesian3.clone(Cartesian3.UNIT_X, result);
|
|
322
|
-
} else {
|
|
323
|
-
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
324
|
-
}
|
|
325
|
-
} else if (f.y <= f.z) {
|
|
326
|
-
result = Cartesian3.clone(Cartesian3.UNIT_Y, result);
|
|
327
|
-
} else {
|
|
328
|
-
result = Cartesian3.clone(Cartesian3.UNIT_Z, result);
|
|
329
|
-
}
|
|
330
|
-
return result;
|
|
331
|
-
};
|
|
332
|
-
Cartesian3.projectVector = function(a, b, result) {
|
|
333
|
-
Check_default.defined("a", a);
|
|
334
|
-
Check_default.defined("b", b);
|
|
335
|
-
Check_default.defined("result", result);
|
|
336
|
-
const scalar = Cartesian3.dot(a, b) / Cartesian3.dot(b, b);
|
|
337
|
-
return Cartesian3.multiplyByScalar(b, scalar, result);
|
|
338
|
-
};
|
|
339
|
-
Cartesian3.equals = function(left, right) {
|
|
340
|
-
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y && left.z === right.z;
|
|
341
|
-
};
|
|
342
|
-
Cartesian3.equalsArray = function(cartesian, array, offset) {
|
|
343
|
-
return cartesian.x === array[offset] && cartesian.y === array[offset + 1] && cartesian.z === array[offset + 2];
|
|
344
|
-
};
|
|
345
|
-
Cartesian3.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
346
|
-
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
|
|
347
|
-
left.x,
|
|
348
|
-
right.x,
|
|
349
|
-
relativeEpsilon,
|
|
350
|
-
absoluteEpsilon
|
|
351
|
-
) && Math_default.equalsEpsilon(
|
|
352
|
-
left.y,
|
|
353
|
-
right.y,
|
|
354
|
-
relativeEpsilon,
|
|
355
|
-
absoluteEpsilon
|
|
356
|
-
) && Math_default.equalsEpsilon(
|
|
357
|
-
left.z,
|
|
358
|
-
right.z,
|
|
359
|
-
relativeEpsilon,
|
|
360
|
-
absoluteEpsilon
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
Cartesian3.cross = function(left, right, result) {
|
|
364
|
-
Check_default.typeOf.object("left", left);
|
|
365
|
-
Check_default.typeOf.object("right", right);
|
|
366
|
-
Check_default.typeOf.object("result", result);
|
|
367
|
-
const leftX = left.x;
|
|
368
|
-
const leftY = left.y;
|
|
369
|
-
const leftZ = left.z;
|
|
370
|
-
const rightX = right.x;
|
|
371
|
-
const rightY = right.y;
|
|
372
|
-
const rightZ = right.z;
|
|
373
|
-
const x = leftY * rightZ - leftZ * rightY;
|
|
374
|
-
const y = leftZ * rightX - leftX * rightZ;
|
|
375
|
-
const z = leftX * rightY - leftY * rightX;
|
|
376
|
-
result.x = x;
|
|
377
|
-
result.y = y;
|
|
378
|
-
result.z = z;
|
|
379
|
-
return result;
|
|
380
|
-
};
|
|
381
|
-
Cartesian3.midpoint = function(left, right, result) {
|
|
382
|
-
Check_default.typeOf.object("left", left);
|
|
383
|
-
Check_default.typeOf.object("right", right);
|
|
384
|
-
Check_default.typeOf.object("result", result);
|
|
385
|
-
result.x = (left.x + right.x) * 0.5;
|
|
386
|
-
result.y = (left.y + right.y) * 0.5;
|
|
387
|
-
result.z = (left.z + right.z) * 0.5;
|
|
388
|
-
return result;
|
|
389
|
-
};
|
|
390
|
-
Cartesian3.fromDegrees = function(longitude, latitude, height, ellipsoid, result) {
|
|
391
|
-
Check_default.typeOf.number("longitude", longitude);
|
|
392
|
-
Check_default.typeOf.number("latitude", latitude);
|
|
393
|
-
longitude = Math_default.toRadians(longitude);
|
|
394
|
-
latitude = Math_default.toRadians(latitude);
|
|
395
|
-
return Cartesian3.fromRadians(longitude, latitude, height, ellipsoid, result);
|
|
396
|
-
};
|
|
397
|
-
var scratchN = new Cartesian3();
|
|
398
|
-
var scratchK = new Cartesian3();
|
|
399
|
-
var wgs84RadiiSquared = new Cartesian3(
|
|
400
|
-
6378137 * 6378137,
|
|
401
|
-
6378137 * 6378137,
|
|
402
|
-
6356752314245179e-9 * 6356752314245179e-9
|
|
403
|
-
);
|
|
404
|
-
Cartesian3.fromRadians = function(longitude, latitude, height, ellipsoid, result) {
|
|
405
|
-
Check_default.typeOf.number("longitude", longitude);
|
|
406
|
-
Check_default.typeOf.number("latitude", latitude);
|
|
407
|
-
height = defaultValue_default(height, 0);
|
|
408
|
-
const radiiSquared = defined_default(ellipsoid) ? ellipsoid.radiiSquared : wgs84RadiiSquared;
|
|
409
|
-
const cosLatitude = Math.cos(latitude);
|
|
410
|
-
scratchN.x = cosLatitude * Math.cos(longitude);
|
|
411
|
-
scratchN.y = cosLatitude * Math.sin(longitude);
|
|
412
|
-
scratchN.z = Math.sin(latitude);
|
|
413
|
-
scratchN = Cartesian3.normalize(scratchN, scratchN);
|
|
414
|
-
Cartesian3.multiplyComponents(radiiSquared, scratchN, scratchK);
|
|
415
|
-
const gamma = Math.sqrt(Cartesian3.dot(scratchN, scratchK));
|
|
416
|
-
scratchK = Cartesian3.divideByScalar(scratchK, gamma, scratchK);
|
|
417
|
-
scratchN = Cartesian3.multiplyByScalar(scratchN, height, scratchN);
|
|
418
|
-
if (!defined_default(result)) {
|
|
419
|
-
result = new Cartesian3();
|
|
420
|
-
}
|
|
421
|
-
return Cartesian3.add(scratchK, scratchN, result);
|
|
422
|
-
};
|
|
423
|
-
Cartesian3.fromDegreesArray = function(coordinates, ellipsoid, result) {
|
|
424
|
-
Check_default.defined("coordinates", coordinates);
|
|
425
|
-
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
426
|
-
throw new DeveloperError_default(
|
|
427
|
-
"the number of coordinates must be a multiple of 2 and at least 2"
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
const length = coordinates.length;
|
|
431
|
-
if (!defined_default(result)) {
|
|
432
|
-
result = new Array(length / 2);
|
|
433
|
-
} else {
|
|
434
|
-
result.length = length / 2;
|
|
435
|
-
}
|
|
436
|
-
for (let i = 0; i < length; i += 2) {
|
|
437
|
-
const longitude = coordinates[i];
|
|
438
|
-
const latitude = coordinates[i + 1];
|
|
439
|
-
const index = i / 2;
|
|
440
|
-
result[index] = Cartesian3.fromDegrees(
|
|
441
|
-
longitude,
|
|
442
|
-
latitude,
|
|
443
|
-
0,
|
|
444
|
-
ellipsoid,
|
|
445
|
-
result[index]
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
return result;
|
|
449
|
-
};
|
|
450
|
-
Cartesian3.fromRadiansArray = function(coordinates, ellipsoid, result) {
|
|
451
|
-
Check_default.defined("coordinates", coordinates);
|
|
452
|
-
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
|
|
453
|
-
throw new DeveloperError_default(
|
|
454
|
-
"the number of coordinates must be a multiple of 2 and at least 2"
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
const length = coordinates.length;
|
|
458
|
-
if (!defined_default(result)) {
|
|
459
|
-
result = new Array(length / 2);
|
|
460
|
-
} else {
|
|
461
|
-
result.length = length / 2;
|
|
462
|
-
}
|
|
463
|
-
for (let i = 0; i < length; i += 2) {
|
|
464
|
-
const longitude = coordinates[i];
|
|
465
|
-
const latitude = coordinates[i + 1];
|
|
466
|
-
const index = i / 2;
|
|
467
|
-
result[index] = Cartesian3.fromRadians(
|
|
468
|
-
longitude,
|
|
469
|
-
latitude,
|
|
470
|
-
0,
|
|
471
|
-
ellipsoid,
|
|
472
|
-
result[index]
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
return result;
|
|
476
|
-
};
|
|
477
|
-
Cartesian3.fromDegreesArrayHeights = function(coordinates, ellipsoid, result) {
|
|
478
|
-
Check_default.defined("coordinates", coordinates);
|
|
479
|
-
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
480
|
-
throw new DeveloperError_default(
|
|
481
|
-
"the number of coordinates must be a multiple of 3 and at least 3"
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
const length = coordinates.length;
|
|
485
|
-
if (!defined_default(result)) {
|
|
486
|
-
result = new Array(length / 3);
|
|
487
|
-
} else {
|
|
488
|
-
result.length = length / 3;
|
|
489
|
-
}
|
|
490
|
-
for (let i = 0; i < length; i += 3) {
|
|
491
|
-
const longitude = coordinates[i];
|
|
492
|
-
const latitude = coordinates[i + 1];
|
|
493
|
-
const height = coordinates[i + 2];
|
|
494
|
-
const index = i / 3;
|
|
495
|
-
result[index] = Cartesian3.fromDegrees(
|
|
496
|
-
longitude,
|
|
497
|
-
latitude,
|
|
498
|
-
height,
|
|
499
|
-
ellipsoid,
|
|
500
|
-
result[index]
|
|
501
|
-
);
|
|
502
|
-
}
|
|
503
|
-
return result;
|
|
504
|
-
};
|
|
505
|
-
Cartesian3.fromRadiansArrayHeights = function(coordinates, ellipsoid, result) {
|
|
506
|
-
Check_default.defined("coordinates", coordinates);
|
|
507
|
-
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
|
|
508
|
-
throw new DeveloperError_default(
|
|
509
|
-
"the number of coordinates must be a multiple of 3 and at least 3"
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
const length = coordinates.length;
|
|
513
|
-
if (!defined_default(result)) {
|
|
514
|
-
result = new Array(length / 3);
|
|
515
|
-
} else {
|
|
516
|
-
result.length = length / 3;
|
|
517
|
-
}
|
|
518
|
-
for (let i = 0; i < length; i += 3) {
|
|
519
|
-
const longitude = coordinates[i];
|
|
520
|
-
const latitude = coordinates[i + 1];
|
|
521
|
-
const height = coordinates[i + 2];
|
|
522
|
-
const index = i / 3;
|
|
523
|
-
result[index] = Cartesian3.fromRadians(
|
|
524
|
-
longitude,
|
|
525
|
-
latitude,
|
|
526
|
-
height,
|
|
527
|
-
ellipsoid,
|
|
528
|
-
result[index]
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
return result;
|
|
532
|
-
};
|
|
533
|
-
Cartesian3.ZERO = Object.freeze(new Cartesian3(0, 0, 0));
|
|
534
|
-
Cartesian3.ONE = Object.freeze(new Cartesian3(1, 1, 1));
|
|
535
|
-
Cartesian3.UNIT_X = Object.freeze(new Cartesian3(1, 0, 0));
|
|
536
|
-
Cartesian3.UNIT_Y = Object.freeze(new Cartesian3(0, 1, 0));
|
|
537
|
-
Cartesian3.UNIT_Z = Object.freeze(new Cartesian3(0, 0, 1));
|
|
538
|
-
Cartesian3.prototype.clone = function(result) {
|
|
539
|
-
return Cartesian3.clone(this, result);
|
|
540
|
-
};
|
|
541
|
-
Cartesian3.prototype.equals = function(right) {
|
|
542
|
-
return Cartesian3.equals(this, right);
|
|
543
|
-
};
|
|
544
|
-
Cartesian3.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
|
|
545
|
-
return Cartesian3.equalsEpsilon(
|
|
546
|
-
this,
|
|
547
|
-
right,
|
|
548
|
-
relativeEpsilon,
|
|
549
|
-
absoluteEpsilon
|
|
550
|
-
);
|
|
551
|
-
};
|
|
552
|
-
Cartesian3.prototype.toString = function() {
|
|
553
|
-
return `(${this.x}, ${this.y}, ${this.z})`;
|
|
554
|
-
};
|
|
555
|
-
var Cartesian3_default = Cartesian3;
|
|
556
|
-
|
|
557
|
-
// packages/engine/Source/Core/scaleToGeodeticSurface.js
|
|
558
|
-
var scaleToGeodeticSurfaceIntersection = new Cartesian3_default();
|
|
559
|
-
var scaleToGeodeticSurfaceGradient = new Cartesian3_default();
|
|
560
|
-
function scaleToGeodeticSurface(cartesian, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, result) {
|
|
561
|
-
if (!defined_default(cartesian)) {
|
|
562
|
-
throw new DeveloperError_default("cartesian is required.");
|
|
563
|
-
}
|
|
564
|
-
if (!defined_default(oneOverRadii)) {
|
|
565
|
-
throw new DeveloperError_default("oneOverRadii is required.");
|
|
566
|
-
}
|
|
567
|
-
if (!defined_default(oneOverRadiiSquared)) {
|
|
568
|
-
throw new DeveloperError_default("oneOverRadiiSquared is required.");
|
|
569
|
-
}
|
|
570
|
-
if (!defined_default(centerToleranceSquared)) {
|
|
571
|
-
throw new DeveloperError_default("centerToleranceSquared is required.");
|
|
572
|
-
}
|
|
573
|
-
const positionX = cartesian.x;
|
|
574
|
-
const positionY = cartesian.y;
|
|
575
|
-
const positionZ = cartesian.z;
|
|
576
|
-
const oneOverRadiiX = oneOverRadii.x;
|
|
577
|
-
const oneOverRadiiY = oneOverRadii.y;
|
|
578
|
-
const oneOverRadiiZ = oneOverRadii.z;
|
|
579
|
-
const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
|
|
580
|
-
const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
|
|
581
|
-
const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
|
|
582
|
-
const squaredNorm = x2 + y2 + z2;
|
|
583
|
-
const ratio = Math.sqrt(1 / squaredNorm);
|
|
584
|
-
const intersection = Cartesian3_default.multiplyByScalar(
|
|
585
|
-
cartesian,
|
|
586
|
-
ratio,
|
|
587
|
-
scaleToGeodeticSurfaceIntersection
|
|
588
|
-
);
|
|
589
|
-
if (squaredNorm < centerToleranceSquared) {
|
|
590
|
-
return !isFinite(ratio) ? void 0 : Cartesian3_default.clone(intersection, result);
|
|
591
|
-
}
|
|
592
|
-
const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
|
|
593
|
-
const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
|
|
594
|
-
const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
|
|
595
|
-
const gradient = scaleToGeodeticSurfaceGradient;
|
|
596
|
-
gradient.x = intersection.x * oneOverRadiiSquaredX * 2;
|
|
597
|
-
gradient.y = intersection.y * oneOverRadiiSquaredY * 2;
|
|
598
|
-
gradient.z = intersection.z * oneOverRadiiSquaredZ * 2;
|
|
599
|
-
let lambda = (1 - ratio) * Cartesian3_default.magnitude(cartesian) / (0.5 * Cartesian3_default.magnitude(gradient));
|
|
600
|
-
let correction = 0;
|
|
601
|
-
let func;
|
|
602
|
-
let denominator;
|
|
603
|
-
let xMultiplier;
|
|
604
|
-
let yMultiplier;
|
|
605
|
-
let zMultiplier;
|
|
606
|
-
let xMultiplier2;
|
|
607
|
-
let yMultiplier2;
|
|
608
|
-
let zMultiplier2;
|
|
609
|
-
let xMultiplier3;
|
|
610
|
-
let yMultiplier3;
|
|
611
|
-
let zMultiplier3;
|
|
612
|
-
do {
|
|
613
|
-
lambda -= correction;
|
|
614
|
-
xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
|
|
615
|
-
yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
|
|
616
|
-
zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
|
|
617
|
-
xMultiplier2 = xMultiplier * xMultiplier;
|
|
618
|
-
yMultiplier2 = yMultiplier * yMultiplier;
|
|
619
|
-
zMultiplier2 = zMultiplier * zMultiplier;
|
|
620
|
-
xMultiplier3 = xMultiplier2 * xMultiplier;
|
|
621
|
-
yMultiplier3 = yMultiplier2 * yMultiplier;
|
|
622
|
-
zMultiplier3 = zMultiplier2 * zMultiplier;
|
|
623
|
-
func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
|
|
624
|
-
denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
|
|
625
|
-
const derivative = -2 * denominator;
|
|
626
|
-
correction = func / derivative;
|
|
627
|
-
} while (Math.abs(func) > Math_default.EPSILON12);
|
|
628
|
-
if (!defined_default(result)) {
|
|
629
|
-
return new Cartesian3_default(
|
|
630
|
-
positionX * xMultiplier,
|
|
631
|
-
positionY * yMultiplier,
|
|
632
|
-
positionZ * zMultiplier
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
result.x = positionX * xMultiplier;
|
|
636
|
-
result.y = positionY * yMultiplier;
|
|
637
|
-
result.z = positionZ * zMultiplier;
|
|
638
|
-
return result;
|
|
639
|
-
}
|
|
640
|
-
var scaleToGeodeticSurface_default = scaleToGeodeticSurface;
|
|
641
|
-
|
|
642
|
-
// packages/engine/Source/Core/Cartographic.js
|
|
643
|
-
function Cartographic(longitude, latitude, height) {
|
|
644
|
-
this.longitude = defaultValue_default(longitude, 0);
|
|
645
|
-
this.latitude = defaultValue_default(latitude, 0);
|
|
646
|
-
this.height = defaultValue_default(height, 0);
|
|
647
|
-
}
|
|
648
|
-
Cartographic.fromRadians = function(longitude, latitude, height, result) {
|
|
649
|
-
Check_default.typeOf.number("longitude", longitude);
|
|
650
|
-
Check_default.typeOf.number("latitude", latitude);
|
|
651
|
-
height = defaultValue_default(height, 0);
|
|
652
|
-
if (!defined_default(result)) {
|
|
653
|
-
return new Cartographic(longitude, latitude, height);
|
|
654
|
-
}
|
|
655
|
-
result.longitude = longitude;
|
|
656
|
-
result.latitude = latitude;
|
|
657
|
-
result.height = height;
|
|
658
|
-
return result;
|
|
659
|
-
};
|
|
660
|
-
Cartographic.fromDegrees = function(longitude, latitude, height, result) {
|
|
661
|
-
Check_default.typeOf.number("longitude", longitude);
|
|
662
|
-
Check_default.typeOf.number("latitude", latitude);
|
|
663
|
-
longitude = Math_default.toRadians(longitude);
|
|
664
|
-
latitude = Math_default.toRadians(latitude);
|
|
665
|
-
return Cartographic.fromRadians(longitude, latitude, height, result);
|
|
666
|
-
};
|
|
667
|
-
var cartesianToCartographicN = new Cartesian3_default();
|
|
668
|
-
var cartesianToCartographicP = new Cartesian3_default();
|
|
669
|
-
var cartesianToCartographicH = new Cartesian3_default();
|
|
670
|
-
var wgs84OneOverRadii = new Cartesian3_default(
|
|
671
|
-
1 / 6378137,
|
|
672
|
-
1 / 6378137,
|
|
673
|
-
1 / 6356752314245179e-9
|
|
674
|
-
);
|
|
675
|
-
var wgs84OneOverRadiiSquared = new Cartesian3_default(
|
|
676
|
-
1 / (6378137 * 6378137),
|
|
677
|
-
1 / (6378137 * 6378137),
|
|
678
|
-
1 / (6356752314245179e-9 * 6356752314245179e-9)
|
|
679
|
-
);
|
|
680
|
-
var wgs84CenterToleranceSquared = Math_default.EPSILON1;
|
|
681
|
-
Cartographic.fromCartesian = function(cartesian, ellipsoid, result) {
|
|
682
|
-
const oneOverRadii = defined_default(ellipsoid) ? ellipsoid.oneOverRadii : wgs84OneOverRadii;
|
|
683
|
-
const oneOverRadiiSquared = defined_default(ellipsoid) ? ellipsoid.oneOverRadiiSquared : wgs84OneOverRadiiSquared;
|
|
684
|
-
const centerToleranceSquared = defined_default(ellipsoid) ? ellipsoid._centerToleranceSquared : wgs84CenterToleranceSquared;
|
|
685
|
-
const p = scaleToGeodeticSurface_default(
|
|
686
|
-
cartesian,
|
|
687
|
-
oneOverRadii,
|
|
688
|
-
oneOverRadiiSquared,
|
|
689
|
-
centerToleranceSquared,
|
|
690
|
-
cartesianToCartographicP
|
|
691
|
-
);
|
|
692
|
-
if (!defined_default(p)) {
|
|
693
|
-
return void 0;
|
|
694
|
-
}
|
|
695
|
-
let n = Cartesian3_default.multiplyComponents(
|
|
696
|
-
p,
|
|
697
|
-
oneOverRadiiSquared,
|
|
698
|
-
cartesianToCartographicN
|
|
699
|
-
);
|
|
700
|
-
n = Cartesian3_default.normalize(n, n);
|
|
701
|
-
const h = Cartesian3_default.subtract(cartesian, p, cartesianToCartographicH);
|
|
702
|
-
const longitude = Math.atan2(n.y, n.x);
|
|
703
|
-
const latitude = Math.asin(n.z);
|
|
704
|
-
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian)) * Cartesian3_default.magnitude(h);
|
|
705
|
-
if (!defined_default(result)) {
|
|
706
|
-
return new Cartographic(longitude, latitude, height);
|
|
707
|
-
}
|
|
708
|
-
result.longitude = longitude;
|
|
709
|
-
result.latitude = latitude;
|
|
710
|
-
result.height = height;
|
|
711
|
-
return result;
|
|
712
|
-
};
|
|
713
|
-
Cartographic.toCartesian = function(cartographic, ellipsoid, result) {
|
|
714
|
-
Check_default.defined("cartographic", cartographic);
|
|
715
|
-
return Cartesian3_default.fromRadians(
|
|
716
|
-
cartographic.longitude,
|
|
717
|
-
cartographic.latitude,
|
|
718
|
-
cartographic.height,
|
|
719
|
-
ellipsoid,
|
|
720
|
-
result
|
|
721
|
-
);
|
|
722
|
-
};
|
|
723
|
-
Cartographic.clone = function(cartographic, result) {
|
|
724
|
-
if (!defined_default(cartographic)) {
|
|
725
|
-
return void 0;
|
|
726
|
-
}
|
|
727
|
-
if (!defined_default(result)) {
|
|
728
|
-
return new Cartographic(
|
|
729
|
-
cartographic.longitude,
|
|
730
|
-
cartographic.latitude,
|
|
731
|
-
cartographic.height
|
|
732
|
-
);
|
|
733
|
-
}
|
|
734
|
-
result.longitude = cartographic.longitude;
|
|
735
|
-
result.latitude = cartographic.latitude;
|
|
736
|
-
result.height = cartographic.height;
|
|
737
|
-
return result;
|
|
738
|
-
};
|
|
739
|
-
Cartographic.equals = function(left, right) {
|
|
740
|
-
return left === right || defined_default(left) && defined_default(right) && left.longitude === right.longitude && left.latitude === right.latitude && left.height === right.height;
|
|
741
|
-
};
|
|
742
|
-
Cartographic.equalsEpsilon = function(left, right, epsilon) {
|
|
743
|
-
epsilon = defaultValue_default(epsilon, 0);
|
|
744
|
-
return left === right || defined_default(left) && defined_default(right) && Math.abs(left.longitude - right.longitude) <= epsilon && Math.abs(left.latitude - right.latitude) <= epsilon && Math.abs(left.height - right.height) <= epsilon;
|
|
745
|
-
};
|
|
746
|
-
Cartographic.ZERO = Object.freeze(new Cartographic(0, 0, 0));
|
|
747
|
-
Cartographic.prototype.clone = function(result) {
|
|
748
|
-
return Cartographic.clone(this, result);
|
|
749
|
-
};
|
|
750
|
-
Cartographic.prototype.equals = function(right) {
|
|
751
|
-
return Cartographic.equals(this, right);
|
|
752
|
-
};
|
|
753
|
-
Cartographic.prototype.equalsEpsilon = function(right, epsilon) {
|
|
754
|
-
return Cartographic.equalsEpsilon(this, right, epsilon);
|
|
755
|
-
};
|
|
756
|
-
Cartographic.prototype.toString = function() {
|
|
757
|
-
return `(${this.longitude}, ${this.latitude}, ${this.height})`;
|
|
758
|
-
};
|
|
759
|
-
var Cartographic_default = Cartographic;
|
|
760
|
-
|
|
761
|
-
// packages/engine/Source/Core/Cartesian2.js
|
|
762
|
-
function Cartesian2(x, y) {
|
|
763
|
-
this.x = defaultValue_default(x, 0);
|
|
764
|
-
this.y = defaultValue_default(y, 0);
|
|
765
|
-
}
|
|
766
|
-
Cartesian2.fromElements = function(x, y, result) {
|
|
767
|
-
if (!defined_default(result)) {
|
|
768
|
-
return new Cartesian2(x, y);
|
|
769
|
-
}
|
|
770
|
-
result.x = x;
|
|
771
|
-
result.y = y;
|
|
772
|
-
return result;
|
|
773
|
-
};
|
|
774
|
-
Cartesian2.clone = function(cartesian, result) {
|
|
775
|
-
if (!defined_default(cartesian)) {
|
|
776
|
-
return void 0;
|
|
777
|
-
}
|
|
778
|
-
if (!defined_default(result)) {
|
|
779
|
-
return new Cartesian2(cartesian.x, cartesian.y);
|
|
780
|
-
}
|
|
781
|
-
result.x = cartesian.x;
|
|
782
|
-
result.y = cartesian.y;
|
|
783
|
-
return result;
|
|
784
|
-
};
|
|
785
|
-
Cartesian2.fromCartesian3 = Cartesian2.clone;
|
|
786
|
-
Cartesian2.fromCartesian4 = Cartesian2.clone;
|
|
787
|
-
Cartesian2.packedLength = 2;
|
|
788
|
-
Cartesian2.pack = function(value, array, startingIndex) {
|
|
789
|
-
Check_default.typeOf.object("value", value);
|
|
790
|
-
Check_default.defined("array", array);
|
|
791
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
792
|
-
array[startingIndex++] = value.x;
|
|
793
|
-
array[startingIndex] = value.y;
|
|
794
|
-
return array;
|
|
795
|
-
};
|
|
796
|
-
Cartesian2.unpack = function(array, startingIndex, result) {
|
|
797
|
-
Check_default.defined("array", array);
|
|
798
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
799
|
-
if (!defined_default(result)) {
|
|
800
|
-
result = new Cartesian2();
|
|
801
|
-
}
|
|
802
|
-
result.x = array[startingIndex++];
|
|
803
|
-
result.y = array[startingIndex];
|
|
804
|
-
return result;
|
|
805
|
-
};
|
|
806
|
-
Cartesian2.packArray = function(array, result) {
|
|
807
|
-
Check_default.defined("array", array);
|
|
808
|
-
const length = array.length;
|
|
809
|
-
const resultLength = length * 2;
|
|
810
|
-
if (!defined_default(result)) {
|
|
811
|
-
result = new Array(resultLength);
|
|
812
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
813
|
-
throw new DeveloperError_default(
|
|
814
|
-
"If result is a typed array, it must have exactly array.length * 2 elements"
|
|
815
|
-
);
|
|
816
|
-
} else if (result.length !== resultLength) {
|
|
817
|
-
result.length = resultLength;
|
|
818
|
-
}
|
|
819
|
-
for (let i = 0; i < length; ++i) {
|
|
820
|
-
Cartesian2.pack(array[i], result, i * 2);
|
|
821
|
-
}
|
|
822
|
-
return result;
|
|
823
|
-
};
|
|
824
|
-
Cartesian2.unpackArray = function(array, result) {
|
|
825
|
-
Check_default.defined("array", array);
|
|
826
|
-
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
|
|
827
|
-
if (array.length % 2 !== 0) {
|
|
828
|
-
throw new DeveloperError_default("array length must be a multiple of 2.");
|
|
829
|
-
}
|
|
830
|
-
const length = array.length;
|
|
831
|
-
if (!defined_default(result)) {
|
|
832
|
-
result = new Array(length / 2);
|
|
833
|
-
} else {
|
|
834
|
-
result.length = length / 2;
|
|
835
|
-
}
|
|
836
|
-
for (let i = 0; i < length; i += 2) {
|
|
837
|
-
const index = i / 2;
|
|
838
|
-
result[index] = Cartesian2.unpack(array, i, result[index]);
|
|
839
|
-
}
|
|
840
|
-
return result;
|
|
841
|
-
};
|
|
842
|
-
Cartesian2.fromArray = Cartesian2.unpack;
|
|
843
|
-
Cartesian2.maximumComponent = function(cartesian) {
|
|
844
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
845
|
-
return Math.max(cartesian.x, cartesian.y);
|
|
846
|
-
};
|
|
847
|
-
Cartesian2.minimumComponent = function(cartesian) {
|
|
848
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
849
|
-
return Math.min(cartesian.x, cartesian.y);
|
|
850
|
-
};
|
|
851
|
-
Cartesian2.minimumByComponent = function(first, second, result) {
|
|
852
|
-
Check_default.typeOf.object("first", first);
|
|
853
|
-
Check_default.typeOf.object("second", second);
|
|
854
|
-
Check_default.typeOf.object("result", result);
|
|
855
|
-
result.x = Math.min(first.x, second.x);
|
|
856
|
-
result.y = Math.min(first.y, second.y);
|
|
857
|
-
return result;
|
|
858
|
-
};
|
|
859
|
-
Cartesian2.maximumByComponent = function(first, second, result) {
|
|
860
|
-
Check_default.typeOf.object("first", first);
|
|
861
|
-
Check_default.typeOf.object("second", second);
|
|
862
|
-
Check_default.typeOf.object("result", result);
|
|
863
|
-
result.x = Math.max(first.x, second.x);
|
|
864
|
-
result.y = Math.max(first.y, second.y);
|
|
865
|
-
return result;
|
|
866
|
-
};
|
|
867
|
-
Cartesian2.clamp = function(value, min, max, result) {
|
|
868
|
-
Check_default.typeOf.object("value", value);
|
|
869
|
-
Check_default.typeOf.object("min", min);
|
|
870
|
-
Check_default.typeOf.object("max", max);
|
|
871
|
-
Check_default.typeOf.object("result", result);
|
|
872
|
-
const x = Math_default.clamp(value.x, min.x, max.x);
|
|
873
|
-
const y = Math_default.clamp(value.y, min.y, max.y);
|
|
874
|
-
result.x = x;
|
|
875
|
-
result.y = y;
|
|
876
|
-
return result;
|
|
877
|
-
};
|
|
878
|
-
Cartesian2.magnitudeSquared = function(cartesian) {
|
|
879
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
880
|
-
return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
|
|
881
|
-
};
|
|
882
|
-
Cartesian2.magnitude = function(cartesian) {
|
|
883
|
-
return Math.sqrt(Cartesian2.magnitudeSquared(cartesian));
|
|
884
|
-
};
|
|
885
|
-
var distanceScratch2 = new Cartesian2();
|
|
886
|
-
Cartesian2.distance = function(left, right) {
|
|
887
|
-
Check_default.typeOf.object("left", left);
|
|
888
|
-
Check_default.typeOf.object("right", right);
|
|
889
|
-
Cartesian2.subtract(left, right, distanceScratch2);
|
|
890
|
-
return Cartesian2.magnitude(distanceScratch2);
|
|
891
|
-
};
|
|
892
|
-
Cartesian2.distanceSquared = function(left, right) {
|
|
893
|
-
Check_default.typeOf.object("left", left);
|
|
894
|
-
Check_default.typeOf.object("right", right);
|
|
895
|
-
Cartesian2.subtract(left, right, distanceScratch2);
|
|
896
|
-
return Cartesian2.magnitudeSquared(distanceScratch2);
|
|
897
|
-
};
|
|
898
|
-
Cartesian2.normalize = function(cartesian, result) {
|
|
899
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
900
|
-
Check_default.typeOf.object("result", result);
|
|
901
|
-
const magnitude = Cartesian2.magnitude(cartesian);
|
|
902
|
-
result.x = cartesian.x / magnitude;
|
|
903
|
-
result.y = cartesian.y / magnitude;
|
|
904
|
-
if (isNaN(result.x) || isNaN(result.y)) {
|
|
905
|
-
throw new DeveloperError_default("normalized result is not a number");
|
|
906
|
-
}
|
|
907
|
-
return result;
|
|
908
|
-
};
|
|
909
|
-
Cartesian2.dot = function(left, right) {
|
|
910
|
-
Check_default.typeOf.object("left", left);
|
|
911
|
-
Check_default.typeOf.object("right", right);
|
|
912
|
-
return left.x * right.x + left.y * right.y;
|
|
913
|
-
};
|
|
914
|
-
Cartesian2.cross = function(left, right) {
|
|
915
|
-
Check_default.typeOf.object("left", left);
|
|
916
|
-
Check_default.typeOf.object("right", right);
|
|
917
|
-
return left.x * right.y - left.y * right.x;
|
|
918
|
-
};
|
|
919
|
-
Cartesian2.multiplyComponents = function(left, right, result) {
|
|
920
|
-
Check_default.typeOf.object("left", left);
|
|
921
|
-
Check_default.typeOf.object("right", right);
|
|
922
|
-
Check_default.typeOf.object("result", result);
|
|
923
|
-
result.x = left.x * right.x;
|
|
924
|
-
result.y = left.y * right.y;
|
|
925
|
-
return result;
|
|
926
|
-
};
|
|
927
|
-
Cartesian2.divideComponents = function(left, right, result) {
|
|
928
|
-
Check_default.typeOf.object("left", left);
|
|
929
|
-
Check_default.typeOf.object("right", right);
|
|
930
|
-
Check_default.typeOf.object("result", result);
|
|
931
|
-
result.x = left.x / right.x;
|
|
932
|
-
result.y = left.y / right.y;
|
|
933
|
-
return result;
|
|
934
|
-
};
|
|
935
|
-
Cartesian2.add = function(left, right, result) {
|
|
936
|
-
Check_default.typeOf.object("left", left);
|
|
937
|
-
Check_default.typeOf.object("right", right);
|
|
938
|
-
Check_default.typeOf.object("result", result);
|
|
939
|
-
result.x = left.x + right.x;
|
|
940
|
-
result.y = left.y + right.y;
|
|
941
|
-
return result;
|
|
942
|
-
};
|
|
943
|
-
Cartesian2.subtract = function(left, right, result) {
|
|
944
|
-
Check_default.typeOf.object("left", left);
|
|
945
|
-
Check_default.typeOf.object("right", right);
|
|
946
|
-
Check_default.typeOf.object("result", result);
|
|
947
|
-
result.x = left.x - right.x;
|
|
948
|
-
result.y = left.y - right.y;
|
|
949
|
-
return result;
|
|
950
|
-
};
|
|
951
|
-
Cartesian2.multiplyByScalar = function(cartesian, scalar, result) {
|
|
952
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
953
|
-
Check_default.typeOf.number("scalar", scalar);
|
|
954
|
-
Check_default.typeOf.object("result", result);
|
|
955
|
-
result.x = cartesian.x * scalar;
|
|
956
|
-
result.y = cartesian.y * scalar;
|
|
957
|
-
return result;
|
|
958
|
-
};
|
|
959
|
-
Cartesian2.divideByScalar = function(cartesian, scalar, result) {
|
|
960
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
961
|
-
Check_default.typeOf.number("scalar", scalar);
|
|
962
|
-
Check_default.typeOf.object("result", result);
|
|
963
|
-
result.x = cartesian.x / scalar;
|
|
964
|
-
result.y = cartesian.y / scalar;
|
|
965
|
-
return result;
|
|
966
|
-
};
|
|
967
|
-
Cartesian2.negate = function(cartesian, result) {
|
|
968
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
969
|
-
Check_default.typeOf.object("result", result);
|
|
970
|
-
result.x = -cartesian.x;
|
|
971
|
-
result.y = -cartesian.y;
|
|
972
|
-
return result;
|
|
973
|
-
};
|
|
974
|
-
Cartesian2.abs = function(cartesian, result) {
|
|
975
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
976
|
-
Check_default.typeOf.object("result", result);
|
|
977
|
-
result.x = Math.abs(cartesian.x);
|
|
978
|
-
result.y = Math.abs(cartesian.y);
|
|
979
|
-
return result;
|
|
980
|
-
};
|
|
981
|
-
var lerpScratch2 = new Cartesian2();
|
|
982
|
-
Cartesian2.lerp = function(start, end, t, result) {
|
|
983
|
-
Check_default.typeOf.object("start", start);
|
|
984
|
-
Check_default.typeOf.object("end", end);
|
|
985
|
-
Check_default.typeOf.number("t", t);
|
|
986
|
-
Check_default.typeOf.object("result", result);
|
|
987
|
-
Cartesian2.multiplyByScalar(end, t, lerpScratch2);
|
|
988
|
-
result = Cartesian2.multiplyByScalar(start, 1 - t, result);
|
|
989
|
-
return Cartesian2.add(lerpScratch2, result, result);
|
|
990
|
-
};
|
|
991
|
-
var angleBetweenScratch3 = new Cartesian2();
|
|
992
|
-
var angleBetweenScratch22 = new Cartesian2();
|
|
993
|
-
Cartesian2.angleBetween = function(left, right) {
|
|
994
|
-
Check_default.typeOf.object("left", left);
|
|
995
|
-
Check_default.typeOf.object("right", right);
|
|
996
|
-
Cartesian2.normalize(left, angleBetweenScratch3);
|
|
997
|
-
Cartesian2.normalize(right, angleBetweenScratch22);
|
|
998
|
-
return Math_default.acosClamped(
|
|
999
|
-
Cartesian2.dot(angleBetweenScratch3, angleBetweenScratch22)
|
|
1000
|
-
);
|
|
1001
|
-
};
|
|
1002
|
-
var mostOrthogonalAxisScratch2 = new Cartesian2();
|
|
1003
|
-
Cartesian2.mostOrthogonalAxis = function(cartesian, result) {
|
|
1004
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
1005
|
-
Check_default.typeOf.object("result", result);
|
|
1006
|
-
const f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch2);
|
|
1007
|
-
Cartesian2.abs(f, f);
|
|
1008
|
-
if (f.x <= f.y) {
|
|
1009
|
-
result = Cartesian2.clone(Cartesian2.UNIT_X, result);
|
|
1010
|
-
} else {
|
|
1011
|
-
result = Cartesian2.clone(Cartesian2.UNIT_Y, result);
|
|
1012
|
-
}
|
|
1013
|
-
return result;
|
|
1014
|
-
};
|
|
1015
|
-
Cartesian2.equals = function(left, right) {
|
|
1016
|
-
return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y;
|
|
1017
|
-
};
|
|
1018
|
-
Cartesian2.equalsArray = function(cartesian, array, offset) {
|
|
1019
|
-
return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
|
|
1020
|
-
};
|
|
1021
|
-
Cartesian2.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
|
|
1022
|
-
return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
|
|
1023
|
-
left.x,
|
|
1024
|
-
right.x,
|
|
1025
|
-
relativeEpsilon,
|
|
1026
|
-
absoluteEpsilon
|
|
1027
|
-
) && Math_default.equalsEpsilon(
|
|
1028
|
-
left.y,
|
|
1029
|
-
right.y,
|
|
1030
|
-
relativeEpsilon,
|
|
1031
|
-
absoluteEpsilon
|
|
1032
|
-
);
|
|
1033
|
-
};
|
|
1034
|
-
Cartesian2.ZERO = Object.freeze(new Cartesian2(0, 0));
|
|
1035
|
-
Cartesian2.ONE = Object.freeze(new Cartesian2(1, 1));
|
|
1036
|
-
Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1, 0));
|
|
1037
|
-
Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0, 1));
|
|
1038
|
-
Cartesian2.prototype.clone = function(result) {
|
|
1039
|
-
return Cartesian2.clone(this, result);
|
|
1040
|
-
};
|
|
1041
|
-
Cartesian2.prototype.equals = function(right) {
|
|
1042
|
-
return Cartesian2.equals(this, right);
|
|
1043
|
-
};
|
|
1044
|
-
Cartesian2.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
|
|
1045
|
-
return Cartesian2.equalsEpsilon(
|
|
1046
|
-
this,
|
|
1047
|
-
right,
|
|
1048
|
-
relativeEpsilon,
|
|
1049
|
-
absoluteEpsilon
|
|
1050
|
-
);
|
|
1051
|
-
};
|
|
1052
|
-
Cartesian2.prototype.toString = function() {
|
|
1053
|
-
return `(${this.x}, ${this.y})`;
|
|
1054
|
-
};
|
|
1055
|
-
var Cartesian2_default = Cartesian2;
|
|
1056
|
-
|
|
1057
|
-
// packages/engine/Source/Core/Ellipsoid.js
|
|
1058
|
-
function initialize(ellipsoid, x, y, z) {
|
|
1059
|
-
x = defaultValue_default(x, 0);
|
|
1060
|
-
y = defaultValue_default(y, 0);
|
|
1061
|
-
z = defaultValue_default(z, 0);
|
|
1062
|
-
Check_default.typeOf.number.greaterThanOrEquals("x", x, 0);
|
|
1063
|
-
Check_default.typeOf.number.greaterThanOrEquals("y", y, 0);
|
|
1064
|
-
Check_default.typeOf.number.greaterThanOrEquals("z", z, 0);
|
|
1065
|
-
ellipsoid._radii = new Cartesian3_default(x, y, z);
|
|
1066
|
-
ellipsoid._radiiSquared = new Cartesian3_default(x * x, y * y, z * z);
|
|
1067
|
-
ellipsoid._radiiToTheFourth = new Cartesian3_default(
|
|
1068
|
-
x * x * x * x,
|
|
1069
|
-
y * y * y * y,
|
|
1070
|
-
z * z * z * z
|
|
1071
|
-
);
|
|
1072
|
-
ellipsoid._oneOverRadii = new Cartesian3_default(
|
|
1073
|
-
x === 0 ? 0 : 1 / x,
|
|
1074
|
-
y === 0 ? 0 : 1 / y,
|
|
1075
|
-
z === 0 ? 0 : 1 / z
|
|
1076
|
-
);
|
|
1077
|
-
ellipsoid._oneOverRadiiSquared = new Cartesian3_default(
|
|
1078
|
-
x === 0 ? 0 : 1 / (x * x),
|
|
1079
|
-
y === 0 ? 0 : 1 / (y * y),
|
|
1080
|
-
z === 0 ? 0 : 1 / (z * z)
|
|
1081
|
-
);
|
|
1082
|
-
ellipsoid._minimumRadius = Math.min(x, y, z);
|
|
1083
|
-
ellipsoid._maximumRadius = Math.max(x, y, z);
|
|
1084
|
-
ellipsoid._centerToleranceSquared = Math_default.EPSILON1;
|
|
1085
|
-
if (ellipsoid._radiiSquared.z !== 0) {
|
|
1086
|
-
ellipsoid._squaredXOverSquaredZ = ellipsoid._radiiSquared.x / ellipsoid._radiiSquared.z;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
function Ellipsoid(x, y, z) {
|
|
1090
|
-
this._radii = void 0;
|
|
1091
|
-
this._radiiSquared = void 0;
|
|
1092
|
-
this._radiiToTheFourth = void 0;
|
|
1093
|
-
this._oneOverRadii = void 0;
|
|
1094
|
-
this._oneOverRadiiSquared = void 0;
|
|
1095
|
-
this._minimumRadius = void 0;
|
|
1096
|
-
this._maximumRadius = void 0;
|
|
1097
|
-
this._centerToleranceSquared = void 0;
|
|
1098
|
-
this._squaredXOverSquaredZ = void 0;
|
|
1099
|
-
initialize(this, x, y, z);
|
|
1100
|
-
}
|
|
1101
|
-
Object.defineProperties(Ellipsoid.prototype, {
|
|
1102
|
-
/**
|
|
1103
|
-
* Gets the radii of the ellipsoid.
|
|
1104
|
-
* @memberof Ellipsoid.prototype
|
|
1105
|
-
* @type {Cartesian3}
|
|
1106
|
-
* @readonly
|
|
1107
|
-
*/
|
|
1108
|
-
radii: {
|
|
1109
|
-
get: function() {
|
|
1110
|
-
return this._radii;
|
|
1111
|
-
}
|
|
1112
|
-
},
|
|
1113
|
-
/**
|
|
1114
|
-
* Gets the squared radii of the ellipsoid.
|
|
1115
|
-
* @memberof Ellipsoid.prototype
|
|
1116
|
-
* @type {Cartesian3}
|
|
1117
|
-
* @readonly
|
|
1118
|
-
*/
|
|
1119
|
-
radiiSquared: {
|
|
1120
|
-
get: function() {
|
|
1121
|
-
return this._radiiSquared;
|
|
1122
|
-
}
|
|
1123
|
-
},
|
|
1124
|
-
/**
|
|
1125
|
-
* Gets the radii of the ellipsoid raise to the fourth power.
|
|
1126
|
-
* @memberof Ellipsoid.prototype
|
|
1127
|
-
* @type {Cartesian3}
|
|
1128
|
-
* @readonly
|
|
1129
|
-
*/
|
|
1130
|
-
radiiToTheFourth: {
|
|
1131
|
-
get: function() {
|
|
1132
|
-
return this._radiiToTheFourth;
|
|
1133
|
-
}
|
|
1134
|
-
},
|
|
1135
|
-
/**
|
|
1136
|
-
* Gets one over the radii of the ellipsoid.
|
|
1137
|
-
* @memberof Ellipsoid.prototype
|
|
1138
|
-
* @type {Cartesian3}
|
|
1139
|
-
* @readonly
|
|
1140
|
-
*/
|
|
1141
|
-
oneOverRadii: {
|
|
1142
|
-
get: function() {
|
|
1143
|
-
return this._oneOverRadii;
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
/**
|
|
1147
|
-
* Gets one over the squared radii of the ellipsoid.
|
|
1148
|
-
* @memberof Ellipsoid.prototype
|
|
1149
|
-
* @type {Cartesian3}
|
|
1150
|
-
* @readonly
|
|
1151
|
-
*/
|
|
1152
|
-
oneOverRadiiSquared: {
|
|
1153
|
-
get: function() {
|
|
1154
|
-
return this._oneOverRadiiSquared;
|
|
1155
|
-
}
|
|
1156
|
-
},
|
|
1157
|
-
/**
|
|
1158
|
-
* Gets the minimum radius of the ellipsoid.
|
|
1159
|
-
* @memberof Ellipsoid.prototype
|
|
1160
|
-
* @type {number}
|
|
1161
|
-
* @readonly
|
|
1162
|
-
*/
|
|
1163
|
-
minimumRadius: {
|
|
1164
|
-
get: function() {
|
|
1165
|
-
return this._minimumRadius;
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
/**
|
|
1169
|
-
* Gets the maximum radius of the ellipsoid.
|
|
1170
|
-
* @memberof Ellipsoid.prototype
|
|
1171
|
-
* @type {number}
|
|
1172
|
-
* @readonly
|
|
1173
|
-
*/
|
|
1174
|
-
maximumRadius: {
|
|
1175
|
-
get: function() {
|
|
1176
|
-
return this._maximumRadius;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
});
|
|
1180
|
-
Ellipsoid.clone = function(ellipsoid, result) {
|
|
1181
|
-
if (!defined_default(ellipsoid)) {
|
|
1182
|
-
return void 0;
|
|
1183
|
-
}
|
|
1184
|
-
const radii = ellipsoid._radii;
|
|
1185
|
-
if (!defined_default(result)) {
|
|
1186
|
-
return new Ellipsoid(radii.x, radii.y, radii.z);
|
|
1187
|
-
}
|
|
1188
|
-
Cartesian3_default.clone(radii, result._radii);
|
|
1189
|
-
Cartesian3_default.clone(ellipsoid._radiiSquared, result._radiiSquared);
|
|
1190
|
-
Cartesian3_default.clone(ellipsoid._radiiToTheFourth, result._radiiToTheFourth);
|
|
1191
|
-
Cartesian3_default.clone(ellipsoid._oneOverRadii, result._oneOverRadii);
|
|
1192
|
-
Cartesian3_default.clone(ellipsoid._oneOverRadiiSquared, result._oneOverRadiiSquared);
|
|
1193
|
-
result._minimumRadius = ellipsoid._minimumRadius;
|
|
1194
|
-
result._maximumRadius = ellipsoid._maximumRadius;
|
|
1195
|
-
result._centerToleranceSquared = ellipsoid._centerToleranceSquared;
|
|
1196
|
-
return result;
|
|
1197
|
-
};
|
|
1198
|
-
Ellipsoid.fromCartesian3 = function(cartesian, result) {
|
|
1199
|
-
if (!defined_default(result)) {
|
|
1200
|
-
result = new Ellipsoid();
|
|
1201
|
-
}
|
|
1202
|
-
if (!defined_default(cartesian)) {
|
|
1203
|
-
return result;
|
|
1204
|
-
}
|
|
1205
|
-
initialize(result, cartesian.x, cartesian.y, cartesian.z);
|
|
1206
|
-
return result;
|
|
1207
|
-
};
|
|
1208
|
-
Ellipsoid.WGS84 = Object.freeze(
|
|
1209
|
-
new Ellipsoid(6378137, 6378137, 6356752314245179e-9)
|
|
1210
|
-
);
|
|
1211
|
-
Ellipsoid.UNIT_SPHERE = Object.freeze(new Ellipsoid(1, 1, 1));
|
|
1212
|
-
Ellipsoid.MOON = Object.freeze(
|
|
1213
|
-
new Ellipsoid(
|
|
1214
|
-
Math_default.LUNAR_RADIUS,
|
|
1215
|
-
Math_default.LUNAR_RADIUS,
|
|
1216
|
-
Math_default.LUNAR_RADIUS
|
|
1217
|
-
)
|
|
1218
|
-
);
|
|
1219
|
-
Ellipsoid.prototype.clone = function(result) {
|
|
1220
|
-
return Ellipsoid.clone(this, result);
|
|
1221
|
-
};
|
|
1222
|
-
Ellipsoid.packedLength = Cartesian3_default.packedLength;
|
|
1223
|
-
Ellipsoid.pack = function(value, array, startingIndex) {
|
|
1224
|
-
Check_default.typeOf.object("value", value);
|
|
1225
|
-
Check_default.defined("array", array);
|
|
1226
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
1227
|
-
Cartesian3_default.pack(value._radii, array, startingIndex);
|
|
1228
|
-
return array;
|
|
1229
|
-
};
|
|
1230
|
-
Ellipsoid.unpack = function(array, startingIndex, result) {
|
|
1231
|
-
Check_default.defined("array", array);
|
|
1232
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
1233
|
-
const radii = Cartesian3_default.unpack(array, startingIndex);
|
|
1234
|
-
return Ellipsoid.fromCartesian3(radii, result);
|
|
1235
|
-
};
|
|
1236
|
-
Ellipsoid.prototype.geocentricSurfaceNormal = Cartesian3_default.normalize;
|
|
1237
|
-
Ellipsoid.prototype.geodeticSurfaceNormalCartographic = function(cartographic, result) {
|
|
1238
|
-
Check_default.typeOf.object("cartographic", cartographic);
|
|
1239
|
-
const longitude = cartographic.longitude;
|
|
1240
|
-
const latitude = cartographic.latitude;
|
|
1241
|
-
const cosLatitude = Math.cos(latitude);
|
|
1242
|
-
const x = cosLatitude * Math.cos(longitude);
|
|
1243
|
-
const y = cosLatitude * Math.sin(longitude);
|
|
1244
|
-
const z = Math.sin(latitude);
|
|
1245
|
-
if (!defined_default(result)) {
|
|
1246
|
-
result = new Cartesian3_default();
|
|
1247
|
-
}
|
|
1248
|
-
result.x = x;
|
|
1249
|
-
result.y = y;
|
|
1250
|
-
result.z = z;
|
|
1251
|
-
return Cartesian3_default.normalize(result, result);
|
|
1252
|
-
};
|
|
1253
|
-
Ellipsoid.prototype.geodeticSurfaceNormal = function(cartesian, result) {
|
|
1254
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
1255
|
-
if (isNaN(cartesian.x) || isNaN(cartesian.y) || isNaN(cartesian.z)) {
|
|
1256
|
-
throw new DeveloperError_default("cartesian has a NaN component");
|
|
1257
|
-
}
|
|
1258
|
-
if (Cartesian3_default.equalsEpsilon(cartesian, Cartesian3_default.ZERO, Math_default.EPSILON14)) {
|
|
1259
|
-
return void 0;
|
|
1260
|
-
}
|
|
1261
|
-
if (!defined_default(result)) {
|
|
1262
|
-
result = new Cartesian3_default();
|
|
1263
|
-
}
|
|
1264
|
-
result = Cartesian3_default.multiplyComponents(
|
|
1265
|
-
cartesian,
|
|
1266
|
-
this._oneOverRadiiSquared,
|
|
1267
|
-
result
|
|
1268
|
-
);
|
|
1269
|
-
return Cartesian3_default.normalize(result, result);
|
|
1270
|
-
};
|
|
1271
|
-
var cartographicToCartesianNormal = new Cartesian3_default();
|
|
1272
|
-
var cartographicToCartesianK = new Cartesian3_default();
|
|
1273
|
-
Ellipsoid.prototype.cartographicToCartesian = function(cartographic, result) {
|
|
1274
|
-
const n = cartographicToCartesianNormal;
|
|
1275
|
-
const k = cartographicToCartesianK;
|
|
1276
|
-
this.geodeticSurfaceNormalCartographic(cartographic, n);
|
|
1277
|
-
Cartesian3_default.multiplyComponents(this._radiiSquared, n, k);
|
|
1278
|
-
const gamma = Math.sqrt(Cartesian3_default.dot(n, k));
|
|
1279
|
-
Cartesian3_default.divideByScalar(k, gamma, k);
|
|
1280
|
-
Cartesian3_default.multiplyByScalar(n, cartographic.height, n);
|
|
1281
|
-
if (!defined_default(result)) {
|
|
1282
|
-
result = new Cartesian3_default();
|
|
1283
|
-
}
|
|
1284
|
-
return Cartesian3_default.add(k, n, result);
|
|
1285
|
-
};
|
|
1286
|
-
Ellipsoid.prototype.cartographicArrayToCartesianArray = function(cartographics, result) {
|
|
1287
|
-
Check_default.defined("cartographics", cartographics);
|
|
1288
|
-
const length = cartographics.length;
|
|
1289
|
-
if (!defined_default(result)) {
|
|
1290
|
-
result = new Array(length);
|
|
1291
|
-
} else {
|
|
1292
|
-
result.length = length;
|
|
1293
|
-
}
|
|
1294
|
-
for (let i = 0; i < length; i++) {
|
|
1295
|
-
result[i] = this.cartographicToCartesian(cartographics[i], result[i]);
|
|
1296
|
-
}
|
|
1297
|
-
return result;
|
|
1298
|
-
};
|
|
1299
|
-
var cartesianToCartographicN2 = new Cartesian3_default();
|
|
1300
|
-
var cartesianToCartographicP2 = new Cartesian3_default();
|
|
1301
|
-
var cartesianToCartographicH2 = new Cartesian3_default();
|
|
1302
|
-
Ellipsoid.prototype.cartesianToCartographic = function(cartesian, result) {
|
|
1303
|
-
const p = this.scaleToGeodeticSurface(cartesian, cartesianToCartographicP2);
|
|
1304
|
-
if (!defined_default(p)) {
|
|
1305
|
-
return void 0;
|
|
1306
|
-
}
|
|
1307
|
-
const n = this.geodeticSurfaceNormal(p, cartesianToCartographicN2);
|
|
1308
|
-
const h = Cartesian3_default.subtract(cartesian, p, cartesianToCartographicH2);
|
|
1309
|
-
const longitude = Math.atan2(n.y, n.x);
|
|
1310
|
-
const latitude = Math.asin(n.z);
|
|
1311
|
-
const height = Math_default.sign(Cartesian3_default.dot(h, cartesian)) * Cartesian3_default.magnitude(h);
|
|
1312
|
-
if (!defined_default(result)) {
|
|
1313
|
-
return new Cartographic_default(longitude, latitude, height);
|
|
1314
|
-
}
|
|
1315
|
-
result.longitude = longitude;
|
|
1316
|
-
result.latitude = latitude;
|
|
1317
|
-
result.height = height;
|
|
1318
|
-
return result;
|
|
1319
|
-
};
|
|
1320
|
-
Ellipsoid.prototype.cartesianArrayToCartographicArray = function(cartesians, result) {
|
|
1321
|
-
Check_default.defined("cartesians", cartesians);
|
|
1322
|
-
const length = cartesians.length;
|
|
1323
|
-
if (!defined_default(result)) {
|
|
1324
|
-
result = new Array(length);
|
|
1325
|
-
} else {
|
|
1326
|
-
result.length = length;
|
|
1327
|
-
}
|
|
1328
|
-
for (let i = 0; i < length; ++i) {
|
|
1329
|
-
result[i] = this.cartesianToCartographic(cartesians[i], result[i]);
|
|
1330
|
-
}
|
|
1331
|
-
return result;
|
|
1332
|
-
};
|
|
1333
|
-
Ellipsoid.prototype.scaleToGeodeticSurface = function(cartesian, result) {
|
|
1334
|
-
return scaleToGeodeticSurface_default(
|
|
1335
|
-
cartesian,
|
|
1336
|
-
this._oneOverRadii,
|
|
1337
|
-
this._oneOverRadiiSquared,
|
|
1338
|
-
this._centerToleranceSquared,
|
|
1339
|
-
result
|
|
1340
|
-
);
|
|
1341
|
-
};
|
|
1342
|
-
Ellipsoid.prototype.scaleToGeocentricSurface = function(cartesian, result) {
|
|
1343
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
1344
|
-
if (!defined_default(result)) {
|
|
1345
|
-
result = new Cartesian3_default();
|
|
1346
|
-
}
|
|
1347
|
-
const positionX = cartesian.x;
|
|
1348
|
-
const positionY = cartesian.y;
|
|
1349
|
-
const positionZ = cartesian.z;
|
|
1350
|
-
const oneOverRadiiSquared = this._oneOverRadiiSquared;
|
|
1351
|
-
const beta = 1 / Math.sqrt(
|
|
1352
|
-
positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z
|
|
1353
|
-
);
|
|
1354
|
-
return Cartesian3_default.multiplyByScalar(cartesian, beta, result);
|
|
1355
|
-
};
|
|
1356
|
-
Ellipsoid.prototype.transformPositionToScaledSpace = function(position, result) {
|
|
1357
|
-
if (!defined_default(result)) {
|
|
1358
|
-
result = new Cartesian3_default();
|
|
1359
|
-
}
|
|
1360
|
-
return Cartesian3_default.multiplyComponents(position, this._oneOverRadii, result);
|
|
1361
|
-
};
|
|
1362
|
-
Ellipsoid.prototype.transformPositionFromScaledSpace = function(position, result) {
|
|
1363
|
-
if (!defined_default(result)) {
|
|
1364
|
-
result = new Cartesian3_default();
|
|
1365
|
-
}
|
|
1366
|
-
return Cartesian3_default.multiplyComponents(position, this._radii, result);
|
|
1367
|
-
};
|
|
1368
|
-
Ellipsoid.prototype.equals = function(right) {
|
|
1369
|
-
return this === right || defined_default(right) && Cartesian3_default.equals(this._radii, right._radii);
|
|
1370
|
-
};
|
|
1371
|
-
Ellipsoid.prototype.toString = function() {
|
|
1372
|
-
return this._radii.toString();
|
|
1373
|
-
};
|
|
1374
|
-
Ellipsoid.prototype.getSurfaceNormalIntersectionWithZAxis = function(position, buffer, result) {
|
|
1375
|
-
Check_default.typeOf.object("position", position);
|
|
1376
|
-
if (!Math_default.equalsEpsilon(
|
|
1377
|
-
this._radii.x,
|
|
1378
|
-
this._radii.y,
|
|
1379
|
-
Math_default.EPSILON15
|
|
1380
|
-
)) {
|
|
1381
|
-
throw new DeveloperError_default(
|
|
1382
|
-
"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
|
|
1383
|
-
);
|
|
1384
|
-
}
|
|
1385
|
-
Check_default.typeOf.number.greaterThan("Ellipsoid.radii.z", this._radii.z, 0);
|
|
1386
|
-
buffer = defaultValue_default(buffer, 0);
|
|
1387
|
-
const squaredXOverSquaredZ = this._squaredXOverSquaredZ;
|
|
1388
|
-
if (!defined_default(result)) {
|
|
1389
|
-
result = new Cartesian3_default();
|
|
1390
|
-
}
|
|
1391
|
-
result.x = 0;
|
|
1392
|
-
result.y = 0;
|
|
1393
|
-
result.z = position.z * (1 - squaredXOverSquaredZ);
|
|
1394
|
-
if (Math.abs(result.z) >= this._radii.z - buffer) {
|
|
1395
|
-
return void 0;
|
|
1396
|
-
}
|
|
1397
|
-
return result;
|
|
1398
|
-
};
|
|
1399
|
-
var scratchEndpoint = new Cartesian3_default();
|
|
1400
|
-
Ellipsoid.prototype.getLocalCurvature = function(surfacePosition, result) {
|
|
1401
|
-
Check_default.typeOf.object("surfacePosition", surfacePosition);
|
|
1402
|
-
if (!defined_default(result)) {
|
|
1403
|
-
result = new Cartesian2_default();
|
|
1404
|
-
}
|
|
1405
|
-
const primeVerticalEndpoint = this.getSurfaceNormalIntersectionWithZAxis(
|
|
1406
|
-
surfacePosition,
|
|
1407
|
-
0,
|
|
1408
|
-
scratchEndpoint
|
|
1409
|
-
);
|
|
1410
|
-
const primeVerticalRadius = Cartesian3_default.distance(
|
|
1411
|
-
surfacePosition,
|
|
1412
|
-
primeVerticalEndpoint
|
|
1413
|
-
);
|
|
1414
|
-
const radiusRatio = this.minimumRadius * primeVerticalRadius / this.maximumRadius ** 2;
|
|
1415
|
-
const meridionalRadius = primeVerticalRadius * radiusRatio ** 2;
|
|
1416
|
-
return Cartesian2_default.fromElements(
|
|
1417
|
-
1 / primeVerticalRadius,
|
|
1418
|
-
1 / meridionalRadius,
|
|
1419
|
-
result
|
|
1420
|
-
);
|
|
1421
|
-
};
|
|
1422
|
-
var abscissas = [
|
|
1423
|
-
0.14887433898163,
|
|
1424
|
-
0.43339539412925,
|
|
1425
|
-
0.67940956829902,
|
|
1426
|
-
0.86506336668898,
|
|
1427
|
-
0.97390652851717,
|
|
1428
|
-
0
|
|
1429
|
-
];
|
|
1430
|
-
var weights = [
|
|
1431
|
-
0.29552422471475,
|
|
1432
|
-
0.26926671930999,
|
|
1433
|
-
0.21908636251598,
|
|
1434
|
-
0.14945134915058,
|
|
1435
|
-
0.066671344308684,
|
|
1436
|
-
0
|
|
1437
|
-
];
|
|
1438
|
-
function gaussLegendreQuadrature(a, b, func) {
|
|
1439
|
-
Check_default.typeOf.number("a", a);
|
|
1440
|
-
Check_default.typeOf.number("b", b);
|
|
1441
|
-
Check_default.typeOf.func("func", func);
|
|
1442
|
-
const xMean = 0.5 * (b + a);
|
|
1443
|
-
const xRange = 0.5 * (b - a);
|
|
1444
|
-
let sum = 0;
|
|
1445
|
-
for (let i = 0; i < 5; i++) {
|
|
1446
|
-
const dx = xRange * abscissas[i];
|
|
1447
|
-
sum += weights[i] * (func(xMean + dx) + func(xMean - dx));
|
|
1448
|
-
}
|
|
1449
|
-
sum *= xRange;
|
|
1450
|
-
return sum;
|
|
1451
|
-
}
|
|
1452
|
-
Ellipsoid.prototype.surfaceArea = function(rectangle) {
|
|
1453
|
-
Check_default.typeOf.object("rectangle", rectangle);
|
|
1454
|
-
const minLongitude = rectangle.west;
|
|
1455
|
-
let maxLongitude = rectangle.east;
|
|
1456
|
-
const minLatitude = rectangle.south;
|
|
1457
|
-
const maxLatitude = rectangle.north;
|
|
1458
|
-
while (maxLongitude < minLongitude) {
|
|
1459
|
-
maxLongitude += Math_default.TWO_PI;
|
|
1460
|
-
}
|
|
1461
|
-
const radiiSquared = this._radiiSquared;
|
|
1462
|
-
const a2 = radiiSquared.x;
|
|
1463
|
-
const b2 = radiiSquared.y;
|
|
1464
|
-
const c2 = radiiSquared.z;
|
|
1465
|
-
const a2b2 = a2 * b2;
|
|
1466
|
-
return gaussLegendreQuadrature(minLatitude, maxLatitude, function(lat) {
|
|
1467
|
-
const sinPhi = Math.cos(lat);
|
|
1468
|
-
const cosPhi = Math.sin(lat);
|
|
1469
|
-
return Math.cos(lat) * gaussLegendreQuadrature(minLongitude, maxLongitude, function(lon) {
|
|
1470
|
-
const cosTheta = Math.cos(lon);
|
|
1471
|
-
const sinTheta = Math.sin(lon);
|
|
1472
|
-
return Math.sqrt(
|
|
1473
|
-
a2b2 * cosPhi * cosPhi + c2 * (b2 * cosTheta * cosTheta + a2 * sinTheta * sinTheta) * sinPhi * sinPhi
|
|
1474
|
-
);
|
|
1475
|
-
});
|
|
1476
|
-
});
|
|
1477
|
-
};
|
|
1478
|
-
var Ellipsoid_default = Ellipsoid;
|
|
1479
|
-
|
|
1480
|
-
// packages/engine/Source/Core/Matrix3.js
|
|
1481
|
-
function Matrix3(column0Row0, column1Row0, column2Row0, column0Row1, column1Row1, column2Row1, column0Row2, column1Row2, column2Row2) {
|
|
1482
|
-
this[0] = defaultValue_default(column0Row0, 0);
|
|
1483
|
-
this[1] = defaultValue_default(column0Row1, 0);
|
|
1484
|
-
this[2] = defaultValue_default(column0Row2, 0);
|
|
1485
|
-
this[3] = defaultValue_default(column1Row0, 0);
|
|
1486
|
-
this[4] = defaultValue_default(column1Row1, 0);
|
|
1487
|
-
this[5] = defaultValue_default(column1Row2, 0);
|
|
1488
|
-
this[6] = defaultValue_default(column2Row0, 0);
|
|
1489
|
-
this[7] = defaultValue_default(column2Row1, 0);
|
|
1490
|
-
this[8] = defaultValue_default(column2Row2, 0);
|
|
1491
|
-
}
|
|
1492
|
-
Matrix3.packedLength = 9;
|
|
1493
|
-
Matrix3.pack = function(value, array, startingIndex) {
|
|
1494
|
-
Check_default.typeOf.object("value", value);
|
|
1495
|
-
Check_default.defined("array", array);
|
|
1496
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
1497
|
-
array[startingIndex++] = value[0];
|
|
1498
|
-
array[startingIndex++] = value[1];
|
|
1499
|
-
array[startingIndex++] = value[2];
|
|
1500
|
-
array[startingIndex++] = value[3];
|
|
1501
|
-
array[startingIndex++] = value[4];
|
|
1502
|
-
array[startingIndex++] = value[5];
|
|
1503
|
-
array[startingIndex++] = value[6];
|
|
1504
|
-
array[startingIndex++] = value[7];
|
|
1505
|
-
array[startingIndex++] = value[8];
|
|
1506
|
-
return array;
|
|
1507
|
-
};
|
|
1508
|
-
Matrix3.unpack = function(array, startingIndex, result) {
|
|
1509
|
-
Check_default.defined("array", array);
|
|
1510
|
-
startingIndex = defaultValue_default(startingIndex, 0);
|
|
1511
|
-
if (!defined_default(result)) {
|
|
1512
|
-
result = new Matrix3();
|
|
1513
|
-
}
|
|
1514
|
-
result[0] = array[startingIndex++];
|
|
1515
|
-
result[1] = array[startingIndex++];
|
|
1516
|
-
result[2] = array[startingIndex++];
|
|
1517
|
-
result[3] = array[startingIndex++];
|
|
1518
|
-
result[4] = array[startingIndex++];
|
|
1519
|
-
result[5] = array[startingIndex++];
|
|
1520
|
-
result[6] = array[startingIndex++];
|
|
1521
|
-
result[7] = array[startingIndex++];
|
|
1522
|
-
result[8] = array[startingIndex++];
|
|
1523
|
-
return result;
|
|
1524
|
-
};
|
|
1525
|
-
Matrix3.packArray = function(array, result) {
|
|
1526
|
-
Check_default.defined("array", array);
|
|
1527
|
-
const length = array.length;
|
|
1528
|
-
const resultLength = length * 9;
|
|
1529
|
-
if (!defined_default(result)) {
|
|
1530
|
-
result = new Array(resultLength);
|
|
1531
|
-
} else if (!Array.isArray(result) && result.length !== resultLength) {
|
|
1532
|
-
throw new DeveloperError_default(
|
|
1533
|
-
"If result is a typed array, it must have exactly array.length * 9 elements"
|
|
1534
|
-
);
|
|
1535
|
-
} else if (result.length !== resultLength) {
|
|
1536
|
-
result.length = resultLength;
|
|
1537
|
-
}
|
|
1538
|
-
for (let i = 0; i < length; ++i) {
|
|
1539
|
-
Matrix3.pack(array[i], result, i * 9);
|
|
1540
|
-
}
|
|
1541
|
-
return result;
|
|
1542
|
-
};
|
|
1543
|
-
Matrix3.unpackArray = function(array, result) {
|
|
1544
|
-
Check_default.defined("array", array);
|
|
1545
|
-
Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 9);
|
|
1546
|
-
if (array.length % 9 !== 0) {
|
|
1547
|
-
throw new DeveloperError_default("array length must be a multiple of 9.");
|
|
1548
|
-
}
|
|
1549
|
-
const length = array.length;
|
|
1550
|
-
if (!defined_default(result)) {
|
|
1551
|
-
result = new Array(length / 9);
|
|
1552
|
-
} else {
|
|
1553
|
-
result.length = length / 9;
|
|
1554
|
-
}
|
|
1555
|
-
for (let i = 0; i < length; i += 9) {
|
|
1556
|
-
const index = i / 9;
|
|
1557
|
-
result[index] = Matrix3.unpack(array, i, result[index]);
|
|
1558
|
-
}
|
|
1559
|
-
return result;
|
|
1560
|
-
};
|
|
1561
|
-
Matrix3.clone = function(matrix, result) {
|
|
1562
|
-
if (!defined_default(matrix)) {
|
|
1563
|
-
return void 0;
|
|
1564
|
-
}
|
|
1565
|
-
if (!defined_default(result)) {
|
|
1566
|
-
return new Matrix3(
|
|
1567
|
-
matrix[0],
|
|
1568
|
-
matrix[3],
|
|
1569
|
-
matrix[6],
|
|
1570
|
-
matrix[1],
|
|
1571
|
-
matrix[4],
|
|
1572
|
-
matrix[7],
|
|
1573
|
-
matrix[2],
|
|
1574
|
-
matrix[5],
|
|
1575
|
-
matrix[8]
|
|
1576
|
-
);
|
|
1577
|
-
}
|
|
1578
|
-
result[0] = matrix[0];
|
|
1579
|
-
result[1] = matrix[1];
|
|
1580
|
-
result[2] = matrix[2];
|
|
1581
|
-
result[3] = matrix[3];
|
|
1582
|
-
result[4] = matrix[4];
|
|
1583
|
-
result[5] = matrix[5];
|
|
1584
|
-
result[6] = matrix[6];
|
|
1585
|
-
result[7] = matrix[7];
|
|
1586
|
-
result[8] = matrix[8];
|
|
1587
|
-
return result;
|
|
1588
|
-
};
|
|
1589
|
-
Matrix3.fromArray = Matrix3.unpack;
|
|
1590
|
-
Matrix3.fromColumnMajorArray = function(values, result) {
|
|
1591
|
-
Check_default.defined("values", values);
|
|
1592
|
-
return Matrix3.clone(values, result);
|
|
1593
|
-
};
|
|
1594
|
-
Matrix3.fromRowMajorArray = function(values, result) {
|
|
1595
|
-
Check_default.defined("values", values);
|
|
1596
|
-
if (!defined_default(result)) {
|
|
1597
|
-
return new Matrix3(
|
|
1598
|
-
values[0],
|
|
1599
|
-
values[1],
|
|
1600
|
-
values[2],
|
|
1601
|
-
values[3],
|
|
1602
|
-
values[4],
|
|
1603
|
-
values[5],
|
|
1604
|
-
values[6],
|
|
1605
|
-
values[7],
|
|
1606
|
-
values[8]
|
|
1607
|
-
);
|
|
1608
|
-
}
|
|
1609
|
-
result[0] = values[0];
|
|
1610
|
-
result[1] = values[3];
|
|
1611
|
-
result[2] = values[6];
|
|
1612
|
-
result[3] = values[1];
|
|
1613
|
-
result[4] = values[4];
|
|
1614
|
-
result[5] = values[7];
|
|
1615
|
-
result[6] = values[2];
|
|
1616
|
-
result[7] = values[5];
|
|
1617
|
-
result[8] = values[8];
|
|
1618
|
-
return result;
|
|
1619
|
-
};
|
|
1620
|
-
Matrix3.fromQuaternion = function(quaternion, result) {
|
|
1621
|
-
Check_default.typeOf.object("quaternion", quaternion);
|
|
1622
|
-
const x2 = quaternion.x * quaternion.x;
|
|
1623
|
-
const xy = quaternion.x * quaternion.y;
|
|
1624
|
-
const xz = quaternion.x * quaternion.z;
|
|
1625
|
-
const xw = quaternion.x * quaternion.w;
|
|
1626
|
-
const y2 = quaternion.y * quaternion.y;
|
|
1627
|
-
const yz = quaternion.y * quaternion.z;
|
|
1628
|
-
const yw = quaternion.y * quaternion.w;
|
|
1629
|
-
const z2 = quaternion.z * quaternion.z;
|
|
1630
|
-
const zw = quaternion.z * quaternion.w;
|
|
1631
|
-
const w2 = quaternion.w * quaternion.w;
|
|
1632
|
-
const m00 = x2 - y2 - z2 + w2;
|
|
1633
|
-
const m01 = 2 * (xy - zw);
|
|
1634
|
-
const m02 = 2 * (xz + yw);
|
|
1635
|
-
const m10 = 2 * (xy + zw);
|
|
1636
|
-
const m11 = -x2 + y2 - z2 + w2;
|
|
1637
|
-
const m12 = 2 * (yz - xw);
|
|
1638
|
-
const m20 = 2 * (xz - yw);
|
|
1639
|
-
const m21 = 2 * (yz + xw);
|
|
1640
|
-
const m22 = -x2 - y2 + z2 + w2;
|
|
1641
|
-
if (!defined_default(result)) {
|
|
1642
|
-
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
1643
|
-
}
|
|
1644
|
-
result[0] = m00;
|
|
1645
|
-
result[1] = m10;
|
|
1646
|
-
result[2] = m20;
|
|
1647
|
-
result[3] = m01;
|
|
1648
|
-
result[4] = m11;
|
|
1649
|
-
result[5] = m21;
|
|
1650
|
-
result[6] = m02;
|
|
1651
|
-
result[7] = m12;
|
|
1652
|
-
result[8] = m22;
|
|
1653
|
-
return result;
|
|
1654
|
-
};
|
|
1655
|
-
Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
|
|
1656
|
-
Check_default.typeOf.object("headingPitchRoll", headingPitchRoll);
|
|
1657
|
-
const cosTheta = Math.cos(-headingPitchRoll.pitch);
|
|
1658
|
-
const cosPsi = Math.cos(-headingPitchRoll.heading);
|
|
1659
|
-
const cosPhi = Math.cos(headingPitchRoll.roll);
|
|
1660
|
-
const sinTheta = Math.sin(-headingPitchRoll.pitch);
|
|
1661
|
-
const sinPsi = Math.sin(-headingPitchRoll.heading);
|
|
1662
|
-
const sinPhi = Math.sin(headingPitchRoll.roll);
|
|
1663
|
-
const m00 = cosTheta * cosPsi;
|
|
1664
|
-
const m01 = -cosPhi * sinPsi + sinPhi * sinTheta * cosPsi;
|
|
1665
|
-
const m02 = sinPhi * sinPsi + cosPhi * sinTheta * cosPsi;
|
|
1666
|
-
const m10 = cosTheta * sinPsi;
|
|
1667
|
-
const m11 = cosPhi * cosPsi + sinPhi * sinTheta * sinPsi;
|
|
1668
|
-
const m12 = -sinPhi * cosPsi + cosPhi * sinTheta * sinPsi;
|
|
1669
|
-
const m20 = -sinTheta;
|
|
1670
|
-
const m21 = sinPhi * cosTheta;
|
|
1671
|
-
const m22 = cosPhi * cosTheta;
|
|
1672
|
-
if (!defined_default(result)) {
|
|
1673
|
-
return new Matrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
1674
|
-
}
|
|
1675
|
-
result[0] = m00;
|
|
1676
|
-
result[1] = m10;
|
|
1677
|
-
result[2] = m20;
|
|
1678
|
-
result[3] = m01;
|
|
1679
|
-
result[4] = m11;
|
|
1680
|
-
result[5] = m21;
|
|
1681
|
-
result[6] = m02;
|
|
1682
|
-
result[7] = m12;
|
|
1683
|
-
result[8] = m22;
|
|
1684
|
-
return result;
|
|
1685
|
-
};
|
|
1686
|
-
Matrix3.fromScale = function(scale, result) {
|
|
1687
|
-
Check_default.typeOf.object("scale", scale);
|
|
1688
|
-
if (!defined_default(result)) {
|
|
1689
|
-
return new Matrix3(scale.x, 0, 0, 0, scale.y, 0, 0, 0, scale.z);
|
|
1690
|
-
}
|
|
1691
|
-
result[0] = scale.x;
|
|
1692
|
-
result[1] = 0;
|
|
1693
|
-
result[2] = 0;
|
|
1694
|
-
result[3] = 0;
|
|
1695
|
-
result[4] = scale.y;
|
|
1696
|
-
result[5] = 0;
|
|
1697
|
-
result[6] = 0;
|
|
1698
|
-
result[7] = 0;
|
|
1699
|
-
result[8] = scale.z;
|
|
1700
|
-
return result;
|
|
1701
|
-
};
|
|
1702
|
-
Matrix3.fromUniformScale = function(scale, result) {
|
|
1703
|
-
Check_default.typeOf.number("scale", scale);
|
|
1704
|
-
if (!defined_default(result)) {
|
|
1705
|
-
return new Matrix3(scale, 0, 0, 0, scale, 0, 0, 0, scale);
|
|
1706
|
-
}
|
|
1707
|
-
result[0] = scale;
|
|
1708
|
-
result[1] = 0;
|
|
1709
|
-
result[2] = 0;
|
|
1710
|
-
result[3] = 0;
|
|
1711
|
-
result[4] = scale;
|
|
1712
|
-
result[5] = 0;
|
|
1713
|
-
result[6] = 0;
|
|
1714
|
-
result[7] = 0;
|
|
1715
|
-
result[8] = scale;
|
|
1716
|
-
return result;
|
|
1717
|
-
};
|
|
1718
|
-
Matrix3.fromCrossProduct = function(vector, result) {
|
|
1719
|
-
Check_default.typeOf.object("vector", vector);
|
|
1720
|
-
if (!defined_default(result)) {
|
|
1721
|
-
return new Matrix3(
|
|
1722
|
-
0,
|
|
1723
|
-
-vector.z,
|
|
1724
|
-
vector.y,
|
|
1725
|
-
vector.z,
|
|
1726
|
-
0,
|
|
1727
|
-
-vector.x,
|
|
1728
|
-
-vector.y,
|
|
1729
|
-
vector.x,
|
|
1730
|
-
0
|
|
1731
|
-
);
|
|
1732
|
-
}
|
|
1733
|
-
result[0] = 0;
|
|
1734
|
-
result[1] = vector.z;
|
|
1735
|
-
result[2] = -vector.y;
|
|
1736
|
-
result[3] = -vector.z;
|
|
1737
|
-
result[4] = 0;
|
|
1738
|
-
result[5] = vector.x;
|
|
1739
|
-
result[6] = vector.y;
|
|
1740
|
-
result[7] = -vector.x;
|
|
1741
|
-
result[8] = 0;
|
|
1742
|
-
return result;
|
|
1743
|
-
};
|
|
1744
|
-
Matrix3.fromRotationX = function(angle, result) {
|
|
1745
|
-
Check_default.typeOf.number("angle", angle);
|
|
1746
|
-
const cosAngle = Math.cos(angle);
|
|
1747
|
-
const sinAngle = Math.sin(angle);
|
|
1748
|
-
if (!defined_default(result)) {
|
|
1749
|
-
return new Matrix3(
|
|
1750
|
-
1,
|
|
1751
|
-
0,
|
|
1752
|
-
0,
|
|
1753
|
-
0,
|
|
1754
|
-
cosAngle,
|
|
1755
|
-
-sinAngle,
|
|
1756
|
-
0,
|
|
1757
|
-
sinAngle,
|
|
1758
|
-
cosAngle
|
|
1759
|
-
);
|
|
1760
|
-
}
|
|
1761
|
-
result[0] = 1;
|
|
1762
|
-
result[1] = 0;
|
|
1763
|
-
result[2] = 0;
|
|
1764
|
-
result[3] = 0;
|
|
1765
|
-
result[4] = cosAngle;
|
|
1766
|
-
result[5] = sinAngle;
|
|
1767
|
-
result[6] = 0;
|
|
1768
|
-
result[7] = -sinAngle;
|
|
1769
|
-
result[8] = cosAngle;
|
|
1770
|
-
return result;
|
|
1771
|
-
};
|
|
1772
|
-
Matrix3.fromRotationY = function(angle, result) {
|
|
1773
|
-
Check_default.typeOf.number("angle", angle);
|
|
1774
|
-
const cosAngle = Math.cos(angle);
|
|
1775
|
-
const sinAngle = Math.sin(angle);
|
|
1776
|
-
if (!defined_default(result)) {
|
|
1777
|
-
return new Matrix3(
|
|
1778
|
-
cosAngle,
|
|
1779
|
-
0,
|
|
1780
|
-
sinAngle,
|
|
1781
|
-
0,
|
|
1782
|
-
1,
|
|
1783
|
-
0,
|
|
1784
|
-
-sinAngle,
|
|
1785
|
-
0,
|
|
1786
|
-
cosAngle
|
|
1787
|
-
);
|
|
1788
|
-
}
|
|
1789
|
-
result[0] = cosAngle;
|
|
1790
|
-
result[1] = 0;
|
|
1791
|
-
result[2] = -sinAngle;
|
|
1792
|
-
result[3] = 0;
|
|
1793
|
-
result[4] = 1;
|
|
1794
|
-
result[5] = 0;
|
|
1795
|
-
result[6] = sinAngle;
|
|
1796
|
-
result[7] = 0;
|
|
1797
|
-
result[8] = cosAngle;
|
|
1798
|
-
return result;
|
|
1799
|
-
};
|
|
1800
|
-
Matrix3.fromRotationZ = function(angle, result) {
|
|
1801
|
-
Check_default.typeOf.number("angle", angle);
|
|
1802
|
-
const cosAngle = Math.cos(angle);
|
|
1803
|
-
const sinAngle = Math.sin(angle);
|
|
1804
|
-
if (!defined_default(result)) {
|
|
1805
|
-
return new Matrix3(
|
|
1806
|
-
cosAngle,
|
|
1807
|
-
-sinAngle,
|
|
1808
|
-
0,
|
|
1809
|
-
sinAngle,
|
|
1810
|
-
cosAngle,
|
|
1811
|
-
0,
|
|
1812
|
-
0,
|
|
1813
|
-
0,
|
|
1814
|
-
1
|
|
1815
|
-
);
|
|
1816
|
-
}
|
|
1817
|
-
result[0] = cosAngle;
|
|
1818
|
-
result[1] = sinAngle;
|
|
1819
|
-
result[2] = 0;
|
|
1820
|
-
result[3] = -sinAngle;
|
|
1821
|
-
result[4] = cosAngle;
|
|
1822
|
-
result[5] = 0;
|
|
1823
|
-
result[6] = 0;
|
|
1824
|
-
result[7] = 0;
|
|
1825
|
-
result[8] = 1;
|
|
1826
|
-
return result;
|
|
1827
|
-
};
|
|
1828
|
-
Matrix3.toArray = function(matrix, result) {
|
|
1829
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1830
|
-
if (!defined_default(result)) {
|
|
1831
|
-
return [
|
|
1832
|
-
matrix[0],
|
|
1833
|
-
matrix[1],
|
|
1834
|
-
matrix[2],
|
|
1835
|
-
matrix[3],
|
|
1836
|
-
matrix[4],
|
|
1837
|
-
matrix[5],
|
|
1838
|
-
matrix[6],
|
|
1839
|
-
matrix[7],
|
|
1840
|
-
matrix[8]
|
|
1841
|
-
];
|
|
1842
|
-
}
|
|
1843
|
-
result[0] = matrix[0];
|
|
1844
|
-
result[1] = matrix[1];
|
|
1845
|
-
result[2] = matrix[2];
|
|
1846
|
-
result[3] = matrix[3];
|
|
1847
|
-
result[4] = matrix[4];
|
|
1848
|
-
result[5] = matrix[5];
|
|
1849
|
-
result[6] = matrix[6];
|
|
1850
|
-
result[7] = matrix[7];
|
|
1851
|
-
result[8] = matrix[8];
|
|
1852
|
-
return result;
|
|
1853
|
-
};
|
|
1854
|
-
Matrix3.getElementIndex = function(column, row) {
|
|
1855
|
-
Check_default.typeOf.number.greaterThanOrEquals("row", row, 0);
|
|
1856
|
-
Check_default.typeOf.number.lessThanOrEquals("row", row, 2);
|
|
1857
|
-
Check_default.typeOf.number.greaterThanOrEquals("column", column, 0);
|
|
1858
|
-
Check_default.typeOf.number.lessThanOrEquals("column", column, 2);
|
|
1859
|
-
return column * 3 + row;
|
|
1860
|
-
};
|
|
1861
|
-
Matrix3.getColumn = function(matrix, index, result) {
|
|
1862
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1863
|
-
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1864
|
-
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
1865
|
-
Check_default.typeOf.object("result", result);
|
|
1866
|
-
const startIndex = index * 3;
|
|
1867
|
-
const x = matrix[startIndex];
|
|
1868
|
-
const y = matrix[startIndex + 1];
|
|
1869
|
-
const z = matrix[startIndex + 2];
|
|
1870
|
-
result.x = x;
|
|
1871
|
-
result.y = y;
|
|
1872
|
-
result.z = z;
|
|
1873
|
-
return result;
|
|
1874
|
-
};
|
|
1875
|
-
Matrix3.setColumn = function(matrix, index, cartesian, result) {
|
|
1876
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1877
|
-
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1878
|
-
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
1879
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
1880
|
-
Check_default.typeOf.object("result", result);
|
|
1881
|
-
result = Matrix3.clone(matrix, result);
|
|
1882
|
-
const startIndex = index * 3;
|
|
1883
|
-
result[startIndex] = cartesian.x;
|
|
1884
|
-
result[startIndex + 1] = cartesian.y;
|
|
1885
|
-
result[startIndex + 2] = cartesian.z;
|
|
1886
|
-
return result;
|
|
1887
|
-
};
|
|
1888
|
-
Matrix3.getRow = function(matrix, index, result) {
|
|
1889
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1890
|
-
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1891
|
-
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
1892
|
-
Check_default.typeOf.object("result", result);
|
|
1893
|
-
const x = matrix[index];
|
|
1894
|
-
const y = matrix[index + 3];
|
|
1895
|
-
const z = matrix[index + 6];
|
|
1896
|
-
result.x = x;
|
|
1897
|
-
result.y = y;
|
|
1898
|
-
result.z = z;
|
|
1899
|
-
return result;
|
|
1900
|
-
};
|
|
1901
|
-
Matrix3.setRow = function(matrix, index, cartesian, result) {
|
|
1902
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1903
|
-
Check_default.typeOf.number.greaterThanOrEquals("index", index, 0);
|
|
1904
|
-
Check_default.typeOf.number.lessThanOrEquals("index", index, 2);
|
|
1905
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
1906
|
-
Check_default.typeOf.object("result", result);
|
|
1907
|
-
result = Matrix3.clone(matrix, result);
|
|
1908
|
-
result[index] = cartesian.x;
|
|
1909
|
-
result[index + 3] = cartesian.y;
|
|
1910
|
-
result[index + 6] = cartesian.z;
|
|
1911
|
-
return result;
|
|
1912
|
-
};
|
|
1913
|
-
var scaleScratch1 = new Cartesian3_default();
|
|
1914
|
-
Matrix3.setScale = function(matrix, scale, result) {
|
|
1915
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1916
|
-
Check_default.typeOf.object("scale", scale);
|
|
1917
|
-
Check_default.typeOf.object("result", result);
|
|
1918
|
-
const existingScale = Matrix3.getScale(matrix, scaleScratch1);
|
|
1919
|
-
const scaleRatioX = scale.x / existingScale.x;
|
|
1920
|
-
const scaleRatioY = scale.y / existingScale.y;
|
|
1921
|
-
const scaleRatioZ = scale.z / existingScale.z;
|
|
1922
|
-
result[0] = matrix[0] * scaleRatioX;
|
|
1923
|
-
result[1] = matrix[1] * scaleRatioX;
|
|
1924
|
-
result[2] = matrix[2] * scaleRatioX;
|
|
1925
|
-
result[3] = matrix[3] * scaleRatioY;
|
|
1926
|
-
result[4] = matrix[4] * scaleRatioY;
|
|
1927
|
-
result[5] = matrix[5] * scaleRatioY;
|
|
1928
|
-
result[6] = matrix[6] * scaleRatioZ;
|
|
1929
|
-
result[7] = matrix[7] * scaleRatioZ;
|
|
1930
|
-
result[8] = matrix[8] * scaleRatioZ;
|
|
1931
|
-
return result;
|
|
1932
|
-
};
|
|
1933
|
-
var scaleScratch2 = new Cartesian3_default();
|
|
1934
|
-
Matrix3.setUniformScale = function(matrix, scale, result) {
|
|
1935
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1936
|
-
Check_default.typeOf.number("scale", scale);
|
|
1937
|
-
Check_default.typeOf.object("result", result);
|
|
1938
|
-
const existingScale = Matrix3.getScale(matrix, scaleScratch2);
|
|
1939
|
-
const scaleRatioX = scale / existingScale.x;
|
|
1940
|
-
const scaleRatioY = scale / existingScale.y;
|
|
1941
|
-
const scaleRatioZ = scale / existingScale.z;
|
|
1942
|
-
result[0] = matrix[0] * scaleRatioX;
|
|
1943
|
-
result[1] = matrix[1] * scaleRatioX;
|
|
1944
|
-
result[2] = matrix[2] * scaleRatioX;
|
|
1945
|
-
result[3] = matrix[3] * scaleRatioY;
|
|
1946
|
-
result[4] = matrix[4] * scaleRatioY;
|
|
1947
|
-
result[5] = matrix[5] * scaleRatioY;
|
|
1948
|
-
result[6] = matrix[6] * scaleRatioZ;
|
|
1949
|
-
result[7] = matrix[7] * scaleRatioZ;
|
|
1950
|
-
result[8] = matrix[8] * scaleRatioZ;
|
|
1951
|
-
return result;
|
|
1952
|
-
};
|
|
1953
|
-
var scratchColumn = new Cartesian3_default();
|
|
1954
|
-
Matrix3.getScale = function(matrix, result) {
|
|
1955
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1956
|
-
Check_default.typeOf.object("result", result);
|
|
1957
|
-
result.x = Cartesian3_default.magnitude(
|
|
1958
|
-
Cartesian3_default.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn)
|
|
1959
|
-
);
|
|
1960
|
-
result.y = Cartesian3_default.magnitude(
|
|
1961
|
-
Cartesian3_default.fromElements(matrix[3], matrix[4], matrix[5], scratchColumn)
|
|
1962
|
-
);
|
|
1963
|
-
result.z = Cartesian3_default.magnitude(
|
|
1964
|
-
Cartesian3_default.fromElements(matrix[6], matrix[7], matrix[8], scratchColumn)
|
|
1965
|
-
);
|
|
1966
|
-
return result;
|
|
1967
|
-
};
|
|
1968
|
-
var scaleScratch3 = new Cartesian3_default();
|
|
1969
|
-
Matrix3.getMaximumScale = function(matrix) {
|
|
1970
|
-
Matrix3.getScale(matrix, scaleScratch3);
|
|
1971
|
-
return Cartesian3_default.maximumComponent(scaleScratch3);
|
|
1972
|
-
};
|
|
1973
|
-
var scaleScratch4 = new Cartesian3_default();
|
|
1974
|
-
Matrix3.setRotation = function(matrix, rotation, result) {
|
|
1975
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1976
|
-
Check_default.typeOf.object("result", result);
|
|
1977
|
-
const scale = Matrix3.getScale(matrix, scaleScratch4);
|
|
1978
|
-
result[0] = rotation[0] * scale.x;
|
|
1979
|
-
result[1] = rotation[1] * scale.x;
|
|
1980
|
-
result[2] = rotation[2] * scale.x;
|
|
1981
|
-
result[3] = rotation[3] * scale.y;
|
|
1982
|
-
result[4] = rotation[4] * scale.y;
|
|
1983
|
-
result[5] = rotation[5] * scale.y;
|
|
1984
|
-
result[6] = rotation[6] * scale.z;
|
|
1985
|
-
result[7] = rotation[7] * scale.z;
|
|
1986
|
-
result[8] = rotation[8] * scale.z;
|
|
1987
|
-
return result;
|
|
1988
|
-
};
|
|
1989
|
-
var scaleScratch5 = new Cartesian3_default();
|
|
1990
|
-
Matrix3.getRotation = function(matrix, result) {
|
|
1991
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
1992
|
-
Check_default.typeOf.object("result", result);
|
|
1993
|
-
const scale = Matrix3.getScale(matrix, scaleScratch5);
|
|
1994
|
-
result[0] = matrix[0] / scale.x;
|
|
1995
|
-
result[1] = matrix[1] / scale.x;
|
|
1996
|
-
result[2] = matrix[2] / scale.x;
|
|
1997
|
-
result[3] = matrix[3] / scale.y;
|
|
1998
|
-
result[4] = matrix[4] / scale.y;
|
|
1999
|
-
result[5] = matrix[5] / scale.y;
|
|
2000
|
-
result[6] = matrix[6] / scale.z;
|
|
2001
|
-
result[7] = matrix[7] / scale.z;
|
|
2002
|
-
result[8] = matrix[8] / scale.z;
|
|
2003
|
-
return result;
|
|
2004
|
-
};
|
|
2005
|
-
Matrix3.multiply = function(left, right, result) {
|
|
2006
|
-
Check_default.typeOf.object("left", left);
|
|
2007
|
-
Check_default.typeOf.object("right", right);
|
|
2008
|
-
Check_default.typeOf.object("result", result);
|
|
2009
|
-
const column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
|
|
2010
|
-
const column0Row1 = left[1] * right[0] + left[4] * right[1] + left[7] * right[2];
|
|
2011
|
-
const column0Row2 = left[2] * right[0] + left[5] * right[1] + left[8] * right[2];
|
|
2012
|
-
const column1Row0 = left[0] * right[3] + left[3] * right[4] + left[6] * right[5];
|
|
2013
|
-
const column1Row1 = left[1] * right[3] + left[4] * right[4] + left[7] * right[5];
|
|
2014
|
-
const column1Row2 = left[2] * right[3] + left[5] * right[4] + left[8] * right[5];
|
|
2015
|
-
const column2Row0 = left[0] * right[6] + left[3] * right[7] + left[6] * right[8];
|
|
2016
|
-
const column2Row1 = left[1] * right[6] + left[4] * right[7] + left[7] * right[8];
|
|
2017
|
-
const column2Row2 = left[2] * right[6] + left[5] * right[7] + left[8] * right[8];
|
|
2018
|
-
result[0] = column0Row0;
|
|
2019
|
-
result[1] = column0Row1;
|
|
2020
|
-
result[2] = column0Row2;
|
|
2021
|
-
result[3] = column1Row0;
|
|
2022
|
-
result[4] = column1Row1;
|
|
2023
|
-
result[5] = column1Row2;
|
|
2024
|
-
result[6] = column2Row0;
|
|
2025
|
-
result[7] = column2Row1;
|
|
2026
|
-
result[8] = column2Row2;
|
|
2027
|
-
return result;
|
|
2028
|
-
};
|
|
2029
|
-
Matrix3.add = function(left, right, result) {
|
|
2030
|
-
Check_default.typeOf.object("left", left);
|
|
2031
|
-
Check_default.typeOf.object("right", right);
|
|
2032
|
-
Check_default.typeOf.object("result", result);
|
|
2033
|
-
result[0] = left[0] + right[0];
|
|
2034
|
-
result[1] = left[1] + right[1];
|
|
2035
|
-
result[2] = left[2] + right[2];
|
|
2036
|
-
result[3] = left[3] + right[3];
|
|
2037
|
-
result[4] = left[4] + right[4];
|
|
2038
|
-
result[5] = left[5] + right[5];
|
|
2039
|
-
result[6] = left[6] + right[6];
|
|
2040
|
-
result[7] = left[7] + right[7];
|
|
2041
|
-
result[8] = left[8] + right[8];
|
|
2042
|
-
return result;
|
|
2043
|
-
};
|
|
2044
|
-
Matrix3.subtract = function(left, right, result) {
|
|
2045
|
-
Check_default.typeOf.object("left", left);
|
|
2046
|
-
Check_default.typeOf.object("right", right);
|
|
2047
|
-
Check_default.typeOf.object("result", result);
|
|
2048
|
-
result[0] = left[0] - right[0];
|
|
2049
|
-
result[1] = left[1] - right[1];
|
|
2050
|
-
result[2] = left[2] - right[2];
|
|
2051
|
-
result[3] = left[3] - right[3];
|
|
2052
|
-
result[4] = left[4] - right[4];
|
|
2053
|
-
result[5] = left[5] - right[5];
|
|
2054
|
-
result[6] = left[6] - right[6];
|
|
2055
|
-
result[7] = left[7] - right[7];
|
|
2056
|
-
result[8] = left[8] - right[8];
|
|
2057
|
-
return result;
|
|
2058
|
-
};
|
|
2059
|
-
Matrix3.multiplyByVector = function(matrix, cartesian, result) {
|
|
2060
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2061
|
-
Check_default.typeOf.object("cartesian", cartesian);
|
|
2062
|
-
Check_default.typeOf.object("result", result);
|
|
2063
|
-
const vX = cartesian.x;
|
|
2064
|
-
const vY = cartesian.y;
|
|
2065
|
-
const vZ = cartesian.z;
|
|
2066
|
-
const x = matrix[0] * vX + matrix[3] * vY + matrix[6] * vZ;
|
|
2067
|
-
const y = matrix[1] * vX + matrix[4] * vY + matrix[7] * vZ;
|
|
2068
|
-
const z = matrix[2] * vX + matrix[5] * vY + matrix[8] * vZ;
|
|
2069
|
-
result.x = x;
|
|
2070
|
-
result.y = y;
|
|
2071
|
-
result.z = z;
|
|
2072
|
-
return result;
|
|
2073
|
-
};
|
|
2074
|
-
Matrix3.multiplyByScalar = function(matrix, scalar, result) {
|
|
2075
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2076
|
-
Check_default.typeOf.number("scalar", scalar);
|
|
2077
|
-
Check_default.typeOf.object("result", result);
|
|
2078
|
-
result[0] = matrix[0] * scalar;
|
|
2079
|
-
result[1] = matrix[1] * scalar;
|
|
2080
|
-
result[2] = matrix[2] * scalar;
|
|
2081
|
-
result[3] = matrix[3] * scalar;
|
|
2082
|
-
result[4] = matrix[4] * scalar;
|
|
2083
|
-
result[5] = matrix[5] * scalar;
|
|
2084
|
-
result[6] = matrix[6] * scalar;
|
|
2085
|
-
result[7] = matrix[7] * scalar;
|
|
2086
|
-
result[8] = matrix[8] * scalar;
|
|
2087
|
-
return result;
|
|
2088
|
-
};
|
|
2089
|
-
Matrix3.multiplyByScale = function(matrix, scale, result) {
|
|
2090
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2091
|
-
Check_default.typeOf.object("scale", scale);
|
|
2092
|
-
Check_default.typeOf.object("result", result);
|
|
2093
|
-
result[0] = matrix[0] * scale.x;
|
|
2094
|
-
result[1] = matrix[1] * scale.x;
|
|
2095
|
-
result[2] = matrix[2] * scale.x;
|
|
2096
|
-
result[3] = matrix[3] * scale.y;
|
|
2097
|
-
result[4] = matrix[4] * scale.y;
|
|
2098
|
-
result[5] = matrix[5] * scale.y;
|
|
2099
|
-
result[6] = matrix[6] * scale.z;
|
|
2100
|
-
result[7] = matrix[7] * scale.z;
|
|
2101
|
-
result[8] = matrix[8] * scale.z;
|
|
2102
|
-
return result;
|
|
2103
|
-
};
|
|
2104
|
-
Matrix3.multiplyByUniformScale = function(matrix, scale, result) {
|
|
2105
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2106
|
-
Check_default.typeOf.number("scale", scale);
|
|
2107
|
-
Check_default.typeOf.object("result", result);
|
|
2108
|
-
result[0] = matrix[0] * scale;
|
|
2109
|
-
result[1] = matrix[1] * scale;
|
|
2110
|
-
result[2] = matrix[2] * scale;
|
|
2111
|
-
result[3] = matrix[3] * scale;
|
|
2112
|
-
result[4] = matrix[4] * scale;
|
|
2113
|
-
result[5] = matrix[5] * scale;
|
|
2114
|
-
result[6] = matrix[6] * scale;
|
|
2115
|
-
result[7] = matrix[7] * scale;
|
|
2116
|
-
result[8] = matrix[8] * scale;
|
|
2117
|
-
return result;
|
|
2118
|
-
};
|
|
2119
|
-
Matrix3.negate = function(matrix, result) {
|
|
2120
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2121
|
-
Check_default.typeOf.object("result", result);
|
|
2122
|
-
result[0] = -matrix[0];
|
|
2123
|
-
result[1] = -matrix[1];
|
|
2124
|
-
result[2] = -matrix[2];
|
|
2125
|
-
result[3] = -matrix[3];
|
|
2126
|
-
result[4] = -matrix[4];
|
|
2127
|
-
result[5] = -matrix[5];
|
|
2128
|
-
result[6] = -matrix[6];
|
|
2129
|
-
result[7] = -matrix[7];
|
|
2130
|
-
result[8] = -matrix[8];
|
|
2131
|
-
return result;
|
|
2132
|
-
};
|
|
2133
|
-
Matrix3.transpose = function(matrix, result) {
|
|
2134
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2135
|
-
Check_default.typeOf.object("result", result);
|
|
2136
|
-
const column0Row0 = matrix[0];
|
|
2137
|
-
const column0Row1 = matrix[3];
|
|
2138
|
-
const column0Row2 = matrix[6];
|
|
2139
|
-
const column1Row0 = matrix[1];
|
|
2140
|
-
const column1Row1 = matrix[4];
|
|
2141
|
-
const column1Row2 = matrix[7];
|
|
2142
|
-
const column2Row0 = matrix[2];
|
|
2143
|
-
const column2Row1 = matrix[5];
|
|
2144
|
-
const column2Row2 = matrix[8];
|
|
2145
|
-
result[0] = column0Row0;
|
|
2146
|
-
result[1] = column0Row1;
|
|
2147
|
-
result[2] = column0Row2;
|
|
2148
|
-
result[3] = column1Row0;
|
|
2149
|
-
result[4] = column1Row1;
|
|
2150
|
-
result[5] = column1Row2;
|
|
2151
|
-
result[6] = column2Row0;
|
|
2152
|
-
result[7] = column2Row1;
|
|
2153
|
-
result[8] = column2Row2;
|
|
2154
|
-
return result;
|
|
2155
|
-
};
|
|
2156
|
-
function computeFrobeniusNorm(matrix) {
|
|
2157
|
-
let norm = 0;
|
|
2158
|
-
for (let i = 0; i < 9; ++i) {
|
|
2159
|
-
const temp = matrix[i];
|
|
2160
|
-
norm += temp * temp;
|
|
2161
|
-
}
|
|
2162
|
-
return Math.sqrt(norm);
|
|
2163
|
-
}
|
|
2164
|
-
var rowVal = [1, 0, 0];
|
|
2165
|
-
var colVal = [2, 2, 1];
|
|
2166
|
-
function offDiagonalFrobeniusNorm(matrix) {
|
|
2167
|
-
let norm = 0;
|
|
2168
|
-
for (let i = 0; i < 3; ++i) {
|
|
2169
|
-
const temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
|
|
2170
|
-
norm += 2 * temp * temp;
|
|
2171
|
-
}
|
|
2172
|
-
return Math.sqrt(norm);
|
|
2173
|
-
}
|
|
2174
|
-
function shurDecomposition(matrix, result) {
|
|
2175
|
-
const tolerance = Math_default.EPSILON15;
|
|
2176
|
-
let maxDiagonal = 0;
|
|
2177
|
-
let rotAxis = 1;
|
|
2178
|
-
for (let i = 0; i < 3; ++i) {
|
|
2179
|
-
const temp = Math.abs(
|
|
2180
|
-
matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]
|
|
2181
|
-
);
|
|
2182
|
-
if (temp > maxDiagonal) {
|
|
2183
|
-
rotAxis = i;
|
|
2184
|
-
maxDiagonal = temp;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
let c = 1;
|
|
2188
|
-
let s = 0;
|
|
2189
|
-
const p = rowVal[rotAxis];
|
|
2190
|
-
const q = colVal[rotAxis];
|
|
2191
|
-
if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
|
|
2192
|
-
const qq = matrix[Matrix3.getElementIndex(q, q)];
|
|
2193
|
-
const pp = matrix[Matrix3.getElementIndex(p, p)];
|
|
2194
|
-
const qp = matrix[Matrix3.getElementIndex(q, p)];
|
|
2195
|
-
const tau = (qq - pp) / 2 / qp;
|
|
2196
|
-
let t;
|
|
2197
|
-
if (tau < 0) {
|
|
2198
|
-
t = -1 / (-tau + Math.sqrt(1 + tau * tau));
|
|
2199
|
-
} else {
|
|
2200
|
-
t = 1 / (tau + Math.sqrt(1 + tau * tau));
|
|
2201
|
-
}
|
|
2202
|
-
c = 1 / Math.sqrt(1 + t * t);
|
|
2203
|
-
s = t * c;
|
|
2204
|
-
}
|
|
2205
|
-
result = Matrix3.clone(Matrix3.IDENTITY, result);
|
|
2206
|
-
result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
|
|
2207
|
-
result[Matrix3.getElementIndex(q, p)] = s;
|
|
2208
|
-
result[Matrix3.getElementIndex(p, q)] = -s;
|
|
2209
|
-
return result;
|
|
2210
|
-
}
|
|
2211
|
-
var jMatrix = new Matrix3();
|
|
2212
|
-
var jMatrixTranspose = new Matrix3();
|
|
2213
|
-
Matrix3.computeEigenDecomposition = function(matrix, result) {
|
|
2214
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2215
|
-
const tolerance = Math_default.EPSILON20;
|
|
2216
|
-
const maxSweeps = 10;
|
|
2217
|
-
let count = 0;
|
|
2218
|
-
let sweep = 0;
|
|
2219
|
-
if (!defined_default(result)) {
|
|
2220
|
-
result = {};
|
|
2221
|
-
}
|
|
2222
|
-
const unitaryMatrix = result.unitary = Matrix3.clone(
|
|
2223
|
-
Matrix3.IDENTITY,
|
|
2224
|
-
result.unitary
|
|
2225
|
-
);
|
|
2226
|
-
const diagMatrix = result.diagonal = Matrix3.clone(matrix, result.diagonal);
|
|
2227
|
-
const epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
|
|
2228
|
-
while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
|
|
2229
|
-
shurDecomposition(diagMatrix, jMatrix);
|
|
2230
|
-
Matrix3.transpose(jMatrix, jMatrixTranspose);
|
|
2231
|
-
Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
|
|
2232
|
-
Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
|
|
2233
|
-
Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
|
|
2234
|
-
if (++count > 2) {
|
|
2235
|
-
++sweep;
|
|
2236
|
-
count = 0;
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
return result;
|
|
2240
|
-
};
|
|
2241
|
-
Matrix3.abs = function(matrix, result) {
|
|
2242
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2243
|
-
Check_default.typeOf.object("result", result);
|
|
2244
|
-
result[0] = Math.abs(matrix[0]);
|
|
2245
|
-
result[1] = Math.abs(matrix[1]);
|
|
2246
|
-
result[2] = Math.abs(matrix[2]);
|
|
2247
|
-
result[3] = Math.abs(matrix[3]);
|
|
2248
|
-
result[4] = Math.abs(matrix[4]);
|
|
2249
|
-
result[5] = Math.abs(matrix[5]);
|
|
2250
|
-
result[6] = Math.abs(matrix[6]);
|
|
2251
|
-
result[7] = Math.abs(matrix[7]);
|
|
2252
|
-
result[8] = Math.abs(matrix[8]);
|
|
2253
|
-
return result;
|
|
2254
|
-
};
|
|
2255
|
-
Matrix3.determinant = function(matrix) {
|
|
2256
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2257
|
-
const m11 = matrix[0];
|
|
2258
|
-
const m21 = matrix[3];
|
|
2259
|
-
const m31 = matrix[6];
|
|
2260
|
-
const m12 = matrix[1];
|
|
2261
|
-
const m22 = matrix[4];
|
|
2262
|
-
const m32 = matrix[7];
|
|
2263
|
-
const m13 = matrix[2];
|
|
2264
|
-
const m23 = matrix[5];
|
|
2265
|
-
const m33 = matrix[8];
|
|
2266
|
-
return m11 * (m22 * m33 - m23 * m32) + m12 * (m23 * m31 - m21 * m33) + m13 * (m21 * m32 - m22 * m31);
|
|
2267
|
-
};
|
|
2268
|
-
Matrix3.inverse = function(matrix, result) {
|
|
2269
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2270
|
-
Check_default.typeOf.object("result", result);
|
|
2271
|
-
const m11 = matrix[0];
|
|
2272
|
-
const m21 = matrix[1];
|
|
2273
|
-
const m31 = matrix[2];
|
|
2274
|
-
const m12 = matrix[3];
|
|
2275
|
-
const m22 = matrix[4];
|
|
2276
|
-
const m32 = matrix[5];
|
|
2277
|
-
const m13 = matrix[6];
|
|
2278
|
-
const m23 = matrix[7];
|
|
2279
|
-
const m33 = matrix[8];
|
|
2280
|
-
const determinant = Matrix3.determinant(matrix);
|
|
2281
|
-
if (Math.abs(determinant) <= Math_default.EPSILON15) {
|
|
2282
|
-
throw new DeveloperError_default("matrix is not invertible");
|
|
2283
|
-
}
|
|
2284
|
-
result[0] = m22 * m33 - m23 * m32;
|
|
2285
|
-
result[1] = m23 * m31 - m21 * m33;
|
|
2286
|
-
result[2] = m21 * m32 - m22 * m31;
|
|
2287
|
-
result[3] = m13 * m32 - m12 * m33;
|
|
2288
|
-
result[4] = m11 * m33 - m13 * m31;
|
|
2289
|
-
result[5] = m12 * m31 - m11 * m32;
|
|
2290
|
-
result[6] = m12 * m23 - m13 * m22;
|
|
2291
|
-
result[7] = m13 * m21 - m11 * m23;
|
|
2292
|
-
result[8] = m11 * m22 - m12 * m21;
|
|
2293
|
-
const scale = 1 / determinant;
|
|
2294
|
-
return Matrix3.multiplyByScalar(result, scale, result);
|
|
2295
|
-
};
|
|
2296
|
-
var scratchTransposeMatrix = new Matrix3();
|
|
2297
|
-
Matrix3.inverseTranspose = function(matrix, result) {
|
|
2298
|
-
Check_default.typeOf.object("matrix", matrix);
|
|
2299
|
-
Check_default.typeOf.object("result", result);
|
|
2300
|
-
return Matrix3.inverse(
|
|
2301
|
-
Matrix3.transpose(matrix, scratchTransposeMatrix),
|
|
2302
|
-
result
|
|
2303
|
-
);
|
|
2304
|
-
};
|
|
2305
|
-
Matrix3.equals = function(left, right) {
|
|
2306
|
-
return left === right || defined_default(left) && defined_default(right) && left[0] === right[0] && left[1] === right[1] && left[2] === right[2] && left[3] === right[3] && left[4] === right[4] && left[5] === right[5] && left[6] === right[6] && left[7] === right[7] && left[8] === right[8];
|
|
2307
|
-
};
|
|
2308
|
-
Matrix3.equalsEpsilon = function(left, right, epsilon) {
|
|
2309
|
-
epsilon = defaultValue_default(epsilon, 0);
|
|
2310
|
-
return left === right || defined_default(left) && defined_default(right) && Math.abs(left[0] - right[0]) <= epsilon && Math.abs(left[1] - right[1]) <= epsilon && Math.abs(left[2] - right[2]) <= epsilon && Math.abs(left[3] - right[3]) <= epsilon && Math.abs(left[4] - right[4]) <= epsilon && Math.abs(left[5] - right[5]) <= epsilon && Math.abs(left[6] - right[6]) <= epsilon && Math.abs(left[7] - right[7]) <= epsilon && Math.abs(left[8] - right[8]) <= epsilon;
|
|
2311
|
-
};
|
|
2312
|
-
Matrix3.IDENTITY = Object.freeze(
|
|
2313
|
-
new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1)
|
|
2314
|
-
);
|
|
2315
|
-
Matrix3.ZERO = Object.freeze(
|
|
2316
|
-
new Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)
|
|
2317
|
-
);
|
|
2318
|
-
Matrix3.COLUMN0ROW0 = 0;
|
|
2319
|
-
Matrix3.COLUMN0ROW1 = 1;
|
|
2320
|
-
Matrix3.COLUMN0ROW2 = 2;
|
|
2321
|
-
Matrix3.COLUMN1ROW0 = 3;
|
|
2322
|
-
Matrix3.COLUMN1ROW1 = 4;
|
|
2323
|
-
Matrix3.COLUMN1ROW2 = 5;
|
|
2324
|
-
Matrix3.COLUMN2ROW0 = 6;
|
|
2325
|
-
Matrix3.COLUMN2ROW1 = 7;
|
|
2326
|
-
Matrix3.COLUMN2ROW2 = 8;
|
|
2327
|
-
Object.defineProperties(Matrix3.prototype, {
|
|
2328
|
-
/**
|
|
2329
|
-
* Gets the number of items in the collection.
|
|
2330
|
-
* @memberof Matrix3.prototype
|
|
2331
|
-
*
|
|
2332
|
-
* @type {number}
|
|
2333
|
-
*/
|
|
2334
|
-
length: {
|
|
2335
|
-
get: function() {
|
|
2336
|
-
return Matrix3.packedLength;
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
});
|
|
2340
|
-
Matrix3.prototype.clone = function(result) {
|
|
2341
|
-
return Matrix3.clone(this, result);
|
|
2342
|
-
};
|
|
2343
|
-
Matrix3.prototype.equals = function(right) {
|
|
2344
|
-
return Matrix3.equals(this, right);
|
|
2345
|
-
};
|
|
2346
|
-
Matrix3.equalsArray = function(matrix, array, offset) {
|
|
2347
|
-
return matrix[0] === array[offset] && matrix[1] === array[offset + 1] && matrix[2] === array[offset + 2] && matrix[3] === array[offset + 3] && matrix[4] === array[offset + 4] && matrix[5] === array[offset + 5] && matrix[6] === array[offset + 6] && matrix[7] === array[offset + 7] && matrix[8] === array[offset + 8];
|
|
2348
|
-
};
|
|
2349
|
-
Matrix3.prototype.equalsEpsilon = function(right, epsilon) {
|
|
2350
|
-
return Matrix3.equalsEpsilon(this, right, epsilon);
|
|
2351
|
-
};
|
|
2352
|
-
Matrix3.prototype.toString = function() {
|
|
2353
|
-
return `(${this[0]}, ${this[3]}, ${this[6]})
|
|
2354
|
-
(${this[1]}, ${this[4]}, ${this[7]})
|
|
2355
|
-
(${this[2]}, ${this[5]}, ${this[8]})`;
|
|
2356
|
-
};
|
|
2357
|
-
var Matrix3_default = Matrix3;
|
|
2358
|
-
|
|
2359
|
-
export {
|
|
2360
|
-
Cartesian3_default,
|
|
2361
|
-
Cartographic_default,
|
|
2362
|
-
Cartesian2_default,
|
|
2363
|
-
Ellipsoid_default,
|
|
2364
|
-
Matrix3_default
|
|
2365
|
-
};
|