cesium 0.21 → 0.21.1

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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/Assets/Textures/moonSmall.jpg +0 -0
  3. data/app/assets/javascripts/Cesium.js +10 -1
  4. data/app/assets/javascripts/Core/Cartesian2.js +28 -0
  5. data/app/assets/javascripts/Core/Cartesian3.js +28 -0
  6. data/app/assets/javascripts/Core/Cartesian4.js +28 -0
  7. data/app/assets/javascripts/Core/CatmullRomSpline.js +3 -3
  8. data/app/assets/javascripts/Core/Clock.js +7 -7
  9. data/app/assets/javascripts/Core/Color.js +1 -1
  10. data/app/assets/javascripts/Core/ComponentDatatype.js +11 -7
  11. data/app/assets/javascripts/Core/CorridorGeometryLibrary.js +23 -29
  12. data/app/assets/javascripts/Core/Ellipsoid.js +6 -0
  13. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +5 -4
  14. data/app/assets/javascripts/Core/Event.js +2 -1
  15. data/app/assets/javascripts/Core/ExtentGeometry.js +1 -1
  16. data/app/assets/javascripts/Core/ExtentOutlineGeometry.js +1 -1
  17. data/app/assets/javascripts/Core/GeometryAttributes.js +1 -1
  18. data/app/assets/javascripts/Core/GeometryInstance.js +2 -2
  19. data/app/assets/javascripts/Core/GeometryPipeline.js +10 -7
  20. data/app/assets/javascripts/Core/HermiteSpline.js +1 -1
  21. data/app/assets/javascripts/Core/Iau2000Orientation.js +132 -0
  22. data/app/assets/javascripts/Core/IauOrientationAxes.js +98 -0
  23. data/app/assets/javascripts/Core/IauOrientationParameters.js +48 -0
  24. data/app/assets/javascripts/Core/IntersectionTests.js +5 -5
  25. data/app/assets/javascripts/Core/JulianDate.js +27 -5
  26. data/app/assets/javascripts/Core/Math.js +9 -0
  27. data/app/assets/javascripts/Core/Matrix2.js +1 -142
  28. data/app/assets/javascripts/Core/Matrix3.js +168 -153
  29. data/app/assets/javascripts/Core/Matrix4.js +0 -249
  30. data/app/assets/javascripts/Core/NearFarScalar.js +13 -0
  31. data/app/assets/javascripts/Core/PolygonGeometry.js +1 -1
  32. data/app/assets/javascripts/Core/PolygonOutlineGeometry.js +2 -2
  33. data/app/assets/javascripts/Core/PolygonPipeline.js +2 -2
  34. data/app/assets/javascripts/Core/PolylinePipeline.js +7 -3
  35. data/app/assets/javascripts/Core/PolylineVolumeGeometry.js +239 -0
  36. data/app/assets/javascripts/Core/PolylineVolumeGeometryLibrary.js +404 -0
  37. data/app/assets/javascripts/Core/PolylineVolumeOutlineGeometry.js +154 -0
  38. data/app/assets/javascripts/Core/Quaternion.js +37 -10
  39. data/app/assets/javascripts/Core/Shapes.js +26 -2
  40. data/app/assets/javascripts/Core/Simon1994PlanetaryPositions.js +3 -3
  41. data/app/assets/javascripts/Core/TimeInterval.js +28 -17
  42. data/app/assets/javascripts/Core/TimeIntervalCollection.js +30 -0
  43. data/app/assets/javascripts/Core/Transforms.js +5 -5
  44. data/app/assets/javascripts/Core/WallGeometryLibrary.js +2 -2
  45. data/app/assets/javascripts/Core/getFilenameFromUri.js +37 -0
  46. data/app/assets/javascripts/DynamicScene/ColorMaterialProperty.js +2 -2
  47. data/app/assets/javascripts/DynamicScene/CzmlDataSource.js +96 -18
  48. data/app/assets/javascripts/DynamicScene/DataSource.js +8 -0
  49. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +15 -3
  50. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +6 -1
  51. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +1 -1
  52. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +12 -1
  53. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +5 -0
  54. data/app/assets/javascripts/DynamicScene/DynamicObject.js +44 -17
  55. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +3 -3
  56. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +12 -1
  57. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +11 -2
  58. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +10 -30
  59. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +5 -20
  60. data/app/assets/javascripts/DynamicScene/GeoJsonDataSource.js +26 -8
  61. data/app/assets/javascripts/DynamicScene/GridMaterialProperty.js +2 -2
  62. data/app/assets/javascripts/DynamicScene/ImageMaterialProperty.js +2 -2
  63. data/app/assets/javascripts/DynamicScene/PolylineOutlineMaterialProperty.js +66 -0
  64. data/app/assets/javascripts/DynamicScene/PositionProperty.js +3 -3
  65. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +1 -1
  66. data/app/assets/javascripts/DynamicScene/SampledProperty.js +14 -8
  67. data/app/assets/javascripts/Renderer/AutomaticUniforms.js +4 -3
  68. data/app/assets/javascripts/Renderer/Context.js +16 -2
  69. data/app/assets/javascripts/Renderer/UniformState.js +14 -14
  70. data/app/assets/javascripts/Scene/Billboard.js +102 -26
  71. data/app/assets/javascripts/Scene/BillboardCollection.js +69 -16
  72. data/app/assets/javascripts/Scene/Camera.js +7 -7
  73. data/app/assets/javascripts/Scene/CameraController.js +23 -12
  74. data/app/assets/javascripts/Scene/CameraFlightPath.js +11 -11
  75. data/app/assets/javascripts/Scene/CentralBodySurface.js +1 -1
  76. data/app/assets/javascripts/Scene/CustomSensorVolume.js +17 -2
  77. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +79 -24
  78. data/app/assets/javascripts/Scene/ExtentPrimitive.js +17 -1
  79. data/app/assets/javascripts/Scene/Label.js +94 -18
  80. data/app/assets/javascripts/Scene/LabelCollection.js +6 -2
  81. data/app/assets/javascripts/Scene/Moon.js +150 -0
  82. data/app/assets/javascripts/Scene/Polygon.js +18 -1
  83. data/app/assets/javascripts/Scene/Polyline.js +32 -13
  84. data/app/assets/javascripts/Scene/PolylineCollection.js +7 -6
  85. data/app/assets/javascripts/Scene/Primitive.js +2 -2
  86. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +12 -0
  87. data/app/assets/javascripts/Scene/Scene.js +122 -14
  88. data/app/assets/javascripts/Scene/SceneTransforms.js +2 -2
  89. data/app/assets/javascripts/Scene/SceneTransitioner.js +4 -4
  90. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1 -1
  91. data/app/assets/javascripts/Scene/SkyBox.js +53 -48
  92. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +2 -2
  93. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +36 -14
  94. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +27 -9
  95. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.glsl +13 -0
  96. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.js +10 -0
  97. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +24 -0
  98. data/app/assets/javascripts/Shaders/EllipsoidFS.js +21 -1
  99. data/app/assets/javascripts/Widgets/CesiumWidget/CesiumWidget.js +30 -9
  100. data/app/assets/javascripts/Widgets/HomeButton/HomeButtonViewModel.js +6 -5
  101. data/app/assets/javascripts/Widgets/Viewer/Viewer.js +13 -0
  102. data/app/assets/javascripts/Widgets/Viewer/viewerDynamicObjectMixin.js +46 -4
  103. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +16 -8
  104. data/app/assets/javascripts/Workers/createPolylineVolumeGeometry.js +23 -0
  105. data/app/assets/javascripts/Workers/createPolylineVolumeOutlineGeometry.js +23 -0
  106. data/lib/cesium/version.rb +1 -1
  107. metadata +15 -5
  108. data/test/dummy/tmp/pids/server.pid +0 -1
@@ -166,6 +166,15 @@ define(['Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'ThirdParty/
166
166
  */
167
167
  CesiumMath.SOLAR_RADIUS = 6.955e8;
168
168
 
169
+ /**
170
+ * The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on
171
+ * Cartographic Coordinates and Rotational Elements of the Planets and satellites: 2000",
172
+ * Celestial Mechanics 82: 83-110, 2002.
173
+ * @type {Number}
174
+ * @constant
175
+ */
176
+ CesiumMath.LUNAR_RADIUS = 1737400.0;
177
+
169
178
  /**
170
179
  * 64 * 1024
171
180
  * @type {Number}
@@ -179,7 +179,7 @@ define(['Core/Cartesian2', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
179
179
  * // Rotate a point 45 degrees counterclockwise.
180
180
  * var p = new Cartesian2(5, 6);
181
181
  * var m = Matrix2.fromRotation(CesiumMath.toRadians(45.0));
182
- * var rotated = m.multiplyByVector(p);
182
+ * var rotated = Matrix2.multiplyByVector(m, p);
183
183
  */
184
184
  Matrix2.fromRotation = function(angle, result) {
185
185
  if (!defined(angle)) {
@@ -647,147 +647,6 @@ define(['Core/Cartesian2', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
647
647
  return Matrix2.clone(this, result);
648
648
  };
649
649
 
650
- /**
651
- * Creates an Array from this Matrix2 instance.
652
- * @memberof Matrix2
653
- *
654
- * @param {Array} [result] The Array onto which to store the result.
655
- * @returns {Array} The modified Array parameter or a new Array instance if one was not provided.
656
- */
657
- Matrix2.prototype.toArray = function(result) {
658
- return Matrix2.toArray(this, result);
659
- };
660
-
661
- /**
662
- * Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
663
- * @memberof Matrix2
664
- *
665
- * @param {Number} index The zero-based index of the column to retrieve.
666
- * @param {Cartesian2} [result] The object onto which to store the result.
667
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
668
- *
669
- * @exception {DeveloperError} index is required and must be 0 or 1.
670
- *
671
- * @see Cartesian2
672
- */
673
- Matrix2.prototype.getColumn = function(index, result) {
674
- return Matrix2.getColumn(this, index, result);
675
- };
676
-
677
- /**
678
- * Computes a new matrix that replaces the specified column in this matrix with the provided Cartesian2 instance.
679
- * @memberof Matrix2
680
- *
681
- * @param {Number} index The zero-based index of the column to set.
682
- * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified column.
683
- *
684
- * @exception {DeveloperError} cartesian is required.
685
- * @exception {DeveloperError} index is required and must be 0 or 1.
686
- *
687
- * @see Cartesian2
688
- */
689
- Matrix2.prototype.setColumn = function(index, cartesian, result) {
690
- return Matrix2.setColumn(this, index, cartesian, result);
691
- };
692
-
693
- /**
694
- * Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
695
- * @memberof Matrix2
696
- *
697
- * @param {Number} index The zero-based index of the row to retrieve.
698
- * @param {Cartesian2} [result] The object onto which to store the result.
699
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
700
- *
701
- * @exception {DeveloperError} index is required and must be 0 or 1.
702
- *
703
- * @see Cartesian2
704
- */
705
- Matrix2.prototype.getRow = function(index, result) {
706
- return Matrix2.getRow(this, index, result);
707
- };
708
-
709
- /**
710
- * Computes a new matrix that replaces the specified row in this matrix with the provided Cartesian2 instance.
711
- * @memberof Matrix2
712
- *
713
- * @param {Number} index The zero-based index of the row to set.
714
- * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified row.
715
- *
716
- * @exception {DeveloperError} cartesian is required.
717
- * @exception {DeveloperError} index is required and must be 0 or 1.
718
- *
719
- * @see Cartesian2
720
- */
721
- Matrix2.prototype.setRow = function(index, cartesian, result) {
722
- return Matrix2.setRow(this, index, cartesian, result);
723
- };
724
-
725
- /**
726
- * Computes the product of this matrix and the provided matrix.
727
- * @memberof Matrix2
728
- *
729
- * @param {Matrix2} right The right hand side matrix.
730
- * @param {Matrix2} [result] The object onto which to store the result.
731
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
732
- *
733
- * @exception {DeveloperError} right is required.
734
- */
735
- Matrix2.prototype.multiply = function(right, result) {
736
- return Matrix2.multiply(this, right, result);
737
- };
738
-
739
- /**
740
- * Computes the product of this matrix and a column vector.
741
- * @memberof Matrix2
742
- *
743
- * @param {Cartesian2} cartesian The column.
744
- * @param {Cartesian2} [result] The object onto which to store the result.
745
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
746
- *
747
- * @exception {DeveloperError} cartesian is required.
748
- */
749
- Matrix2.prototype.multiplyByVector = function(cartesian, result) {
750
- return Matrix2.multiplyByVector(this, cartesian, result);
751
- };
752
-
753
- /**
754
- * Computes the product of this matrix and a scalar.
755
- * @memberof Matrix2
756
- *
757
- * @param {Number} scalar The number to multiply by.
758
- * @param {Matrix2} [result] The object onto which to store the result.
759
- * @returns {Matrix2} The modified result parameter or a new Cartesian2 instance if one was not provided.
760
- *
761
- * @exception {DeveloperError} scalar is required and must be a number.
762
- */
763
- Matrix2.prototype.multiplyByScalar = function(scalar, result) {
764
- return Matrix2.multiplyByScalar(this, scalar, result);
765
- };
766
- /**
767
- * Creates a negated copy of this matrix.
768
- * @memberof Matrix2
769
- *
770
- * @param {Matrix2} matrix The matrix to negate.
771
- * @param {Matrix2} [result] The object onto which to store the result.
772
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
773
- *
774
- * @exception {DeveloperError} matrix is required.
775
- */
776
- Matrix2.prototype.negate = function(result) {
777
- return Matrix2.negate(this, result);
778
- };
779
-
780
- /**
781
- * Computes the transpose of this matrix.
782
- * @memberof Matrix2
783
- *
784
- * @param {Matrix2} [result] The object onto which to store the result.
785
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
786
- */
787
- Matrix2.prototype.transpose = function(result) {
788
- return Matrix2.transpose(this, result);
789
- };
790
-
791
650
  /**
792
651
  * Compares this matrix to the provided matrix componentwise and returns
793
652
  * <code>true</code> if they are equal, <code>false</code> otherwise.
@@ -1,10 +1,11 @@
1
1
  /*global define*/
2
- define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/freezeObject'], function(
2
+ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperError', 'Core/freezeObject', 'Core/Math'], function(
3
3
  Cartesian3,
4
4
  defaultValue,
5
5
  defined,
6
6
  DeveloperError,
7
- freezeObject) {
7
+ freezeObject,
8
+ CesiumMath) {
8
9
  "use strict";
9
10
 
10
11
  /**
@@ -148,15 +149,15 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
148
149
  var w2 = quaternion.w * quaternion.w;
149
150
 
150
151
  var m00 = x2 - y2 - z2 + w2;
151
- var m01 = 2.0 * (xy + zw);
152
- var m02 = 2.0 * (xz - yw);
152
+ var m01 = 2.0 * (xy - zw);
153
+ var m02 = 2.0 * (xz + yw);
153
154
 
154
- var m10 = 2.0 * (xy - zw);
155
+ var m10 = 2.0 * (xy + zw);
155
156
  var m11 = -x2 + y2 - z2 + w2;
156
- var m12 = 2.0 * (yz + xw);
157
+ var m12 = 2.0 * (yz - xw);
157
158
 
158
- var m20 = 2.0 * (xz + yw);
159
- var m21 = 2.0 * (yz - xw);
159
+ var m20 = 2.0 * (xz - yw);
160
+ var m21 = 2.0 * (yz + xw);
160
161
  var m22 = -x2 - y2 + z2 + w2;
161
162
 
162
163
  if (!defined(result)) {
@@ -270,7 +271,7 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
270
271
  * // Rotate a point 45 degrees counterclockwise around the x-axis.
271
272
  * var p = new Cartesian3(5, 6, 7);
272
273
  * var m = Matrix3.fromRotationX(CesiumMath.toRadians(45.0));
273
- * var rotated = m.multiplyByVector(p);
274
+ * var rotated = Matrix3.multiplyByVector(m, p);
274
275
  */
275
276
  Matrix3.fromRotationX = function(angle, result) {
276
277
  if (!defined(angle)) {
@@ -314,7 +315,7 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
314
315
  * // Rotate a point 45 degrees counterclockwise around the y-axis.
315
316
  * var p = new Cartesian3(5, 6, 7);
316
317
  * var m = Matrix3.fromRotationY(CesiumMath.toRadians(45.0));
317
- * var rotated = m.multiplyByVector(p);
318
+ * var rotated = Matrix3.multiplyByVector(m, p);
318
319
  */
319
320
  Matrix3.fromRotationY = function(angle, result) {
320
321
  if (!defined(angle)) {
@@ -358,7 +359,7 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
358
359
  * // Rotate a point 45 degrees counterclockwise around the z-axis.
359
360
  * var p = new Cartesian3(5, 6, 7);
360
361
  * var m = Matrix3.fromRotationZ(CesiumMath.toRadians(45.0));
361
- * var rotated = m.multiplyByVector(p);
362
+ * var rotated = Matrix3.multiplyByVector(m, p);
362
363
  */
363
364
  Matrix3.fromRotationZ = function(angle, result) {
364
365
  if (!defined(angle)) {
@@ -783,6 +784,161 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
783
784
  return result;
784
785
  };
785
786
 
787
+ function computeFrobeniusNorm(matrix) {
788
+ var norm = 0.0;
789
+ for (var i = 0; i < 9; ++i) {
790
+ var temp = matrix[i];
791
+ norm += temp * temp;
792
+ }
793
+
794
+ return Math.sqrt(norm);
795
+ }
796
+
797
+ var rowVal = [1, 0, 0];
798
+ var colVal = [2, 2, 1];
799
+
800
+ function offDiagonalFrobeniusNorm(matrix) {
801
+ // Computes the "off-diagonal" Frobenius norm.
802
+ // Assumes matrix is symmetric.
803
+
804
+ var norm = 0.0;
805
+ for (var i = 0; i < 3; ++i) {
806
+ var temp = matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])];
807
+ norm += 2.0 * temp * temp;
808
+ }
809
+
810
+ return Math.sqrt(norm);
811
+ }
812
+
813
+ function shurDecomposition(matrix, result) {
814
+ // This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
815
+ // section 8.4.2 The 2by2 Symmetric Schur Decomposition.
816
+ //
817
+ // The routine takes a matrix, which is assumed to be symmetric, and
818
+ // finds the largest off-diagonal term, and then creates
819
+ // a matrix (result) which can be used to help reduce it
820
+
821
+ var tolerance = CesiumMath.EPSILON15;
822
+
823
+ var maxDiagonal = 0.0;
824
+ var rotAxis = 1;
825
+
826
+ // find pivot (rotAxis) based on max diagonal of matrix
827
+ for (var i = 0; i < 3; ++i) {
828
+ var temp = Math.abs(matrix[Matrix3.getElementIndex(colVal[i], rowVal[i])]);
829
+ if (temp > maxDiagonal) {
830
+ rotAxis = i;
831
+ maxDiagonal = temp;
832
+ }
833
+ }
834
+
835
+ var c = 1.0;
836
+ var s = 0.0;
837
+
838
+ var p = rowVal[rotAxis];
839
+ var q = colVal[rotAxis];
840
+
841
+ if (Math.abs(matrix[Matrix3.getElementIndex(q, p)]) > tolerance) {
842
+ var qq = matrix[Matrix3.getElementIndex(q, q)];
843
+ var pp = matrix[Matrix3.getElementIndex(p, p)];
844
+ var qp = matrix[Matrix3.getElementIndex(q, p)];
845
+
846
+ var tau = (qq - pp) / 2.0 / qp;
847
+ var t;
848
+
849
+ if (tau < 0.0) {
850
+ t = -1.0 / (-tau + Math.sqrt(1.0 + tau * tau));
851
+ } else {
852
+ t = 1.0 / (tau + Math.sqrt(1.0 + tau * tau));
853
+ }
854
+
855
+ c = 1.0 / Math.sqrt(1.0 + t * t);
856
+ s = t * c;
857
+ }
858
+
859
+ result = Matrix3.clone(Matrix3.IDENTITY, result);
860
+
861
+ result[Matrix3.getElementIndex(p, p)] = result[Matrix3.getElementIndex(q, q)] = c;
862
+ result[Matrix3.getElementIndex(q, p)] = s;
863
+ result[Matrix3.getElementIndex(p, q)] = -s;
864
+
865
+ return result;
866
+ }
867
+
868
+ var jMatrix = new Matrix3();
869
+ var jMatrixTranspose = new Matrix3();
870
+
871
+ /**
872
+ * Computes the eigenvectors and eigenvalues of a symmetric matrix.
873
+ * <p>
874
+ * Returns a diagonal matrix and unitary matrix such that:
875
+ * <code>matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)</code>
876
+ * </p>
877
+ * <p>
878
+ * The values along the diagonal of the diagonal matrix are the eigenvalues. The columns
879
+ * of the unitary matrix are the corresponding eigenvectors.
880
+ * </p>
881
+ * @memberof Matrix3
882
+ *
883
+ * @param {Matrix3} matrix The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.
884
+ * @param {Object} [result] An object with unitary and diagonal properties which are matrices onto which to store the result.
885
+ * @returns {Object} An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
886
+ *
887
+ * @example
888
+ * var a = //... symetric matrix
889
+ * var result = {
890
+ * unitary : new Matrix3(),
891
+ * diagonal : new Matrix3()
892
+ * };
893
+ * Matrix3.getEigenDecomposition(a, result);
894
+ *
895
+ * var unitaryTranspose = Matrix3.transpose(result.unitary);
896
+ * var b = Matrix.multiply(result.unitary, result.diagonal);
897
+ * Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
898
+ *
899
+ * var lambda = Matrix3.getColumn(result.diagonal, 0).x; // first eigenvalue
900
+ * var v = Matrix3.getColumn(result.unitary, 0); // first eigenvector
901
+ * var c = Cartesian3.multiplyByScalar(v, lambda); // equal to Matrix3.multiplyByVector(a, v)
902
+ */
903
+ Matrix3.getEigenDecomposition = function(matrix, result) {
904
+ if (!defined(matrix)) {
905
+ throw new DeveloperError('matrix is required.');
906
+ }
907
+
908
+ // This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
909
+ // section 8.4.3 The Classical Jacobi Algorithm
910
+
911
+ var tolerance = CesiumMath.EPSILON20;
912
+ var maxSweeps = 10;
913
+
914
+ var count = 0;
915
+ var sweep = 0;
916
+
917
+ if (!defined(result)) {
918
+ result = {};
919
+ }
920
+
921
+ var unitaryMatrix = result.unitary = Matrix3.clone(Matrix3.IDENTITY, result.unitary);
922
+ var diagMatrix = result.diagonal = Matrix3.clone(matrix, result.diagonal);
923
+
924
+ var epsilon = tolerance * computeFrobeniusNorm(diagMatrix);
925
+
926
+ while (sweep < maxSweeps && offDiagonalFrobeniusNorm(diagMatrix) > epsilon) {
927
+ shurDecomposition(diagMatrix, jMatrix);
928
+ Matrix3.transpose(jMatrix, jMatrixTranspose);
929
+ Matrix3.multiply(diagMatrix, jMatrix, diagMatrix);
930
+ Matrix3.multiply(jMatrixTranspose, diagMatrix, diagMatrix);
931
+ Matrix3.multiply(unitaryMatrix, jMatrix, unitaryMatrix);
932
+
933
+ if (++count > 2) {
934
+ ++sweep;
935
+ count = 0;
936
+ }
937
+ }
938
+
939
+ return result;
940
+ };
941
+
786
942
  /**
787
943
  * Compares the provided matrices componentwise and returns
788
944
  * <code>true</code> if they are equal, <code>false</code> otherwise.
@@ -912,147 +1068,6 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
912
1068
  return Matrix3.clone(this, result);
913
1069
  };
914
1070
 
915
- /**
916
- * Creates an Array from this Matrix3 instance.
917
- * @memberof Matrix3
918
- *
919
- * @param {Array} [result] The Array onto which to store the result.
920
- * @returns {Array} The modified Array parameter or a new Array instance if one was not provided.
921
- */
922
- Matrix3.prototype.toArray = function(result) {
923
- return Matrix3.toArray(this, result);
924
- };
925
-
926
- /**
927
- * Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
928
- * @memberof Matrix3
929
- *
930
- * @param {Number} index The zero-based index of the column to retrieve.
931
- * @param {Cartesian3} [result] The object onto which to store the result.
932
- * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
933
- *
934
- * @exception {DeveloperError} index is required and must be 0, 1, or 2.
935
- *
936
- * @see Cartesian3
937
- */
938
- Matrix3.prototype.getColumn = function(index, result) {
939
- return Matrix3.getColumn(this, index, result);
940
- };
941
-
942
- /**
943
- * Computes a new matrix that replaces the specified column in this matrix with the provided Cartesian3 instance.
944
- * @memberof Matrix3
945
- *
946
- * @param {Number} index The zero-based index of the column to set.
947
- * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified column.
948
- *
949
- * @exception {DeveloperError} cartesian is required.
950
- * @exception {DeveloperError} index is required and must be 0, 1, or 2.
951
- *
952
- * @see Cartesian3
953
- */
954
- Matrix3.prototype.setColumn = function(index, cartesian, result) {
955
- return Matrix3.setColumn(this, index, cartesian, result);
956
- };
957
-
958
- /**
959
- * Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
960
- * @memberof Matrix3
961
- *
962
- * @param {Number} index The zero-based index of the row to retrieve.
963
- * @param {Cartesian3} [result] The object onto which to store the result.
964
- * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
965
- *
966
- * @exception {DeveloperError} index is required and must be 0, 1, or 2.
967
- *
968
- * @see Cartesian3
969
- */
970
- Matrix3.prototype.getRow = function(index, result) {
971
- return Matrix3.getRow(this, index, result);
972
- };
973
-
974
- /**
975
- * Computes a new matrix that replaces the specified row in this matrix with the provided Cartesian3 instance.
976
- * @memberof Matrix3
977
- *
978
- * @param {Number} index The zero-based index of the row to set.
979
- * @param {Cartesian3} cartesian The Cartesian whose values will be assigned to the specified row.
980
- *
981
- * @exception {DeveloperError} cartesian is required.
982
- * @exception {DeveloperError} index is required and must be 0, 1, or 2.
983
- *
984
- * @see Cartesian3
985
- */
986
- Matrix3.prototype.setRow = function(index, cartesian, result) {
987
- return Matrix3.setRow(this, index, cartesian, result);
988
- };
989
-
990
- /**
991
- * Computes the product of this matrix and the provided matrix.
992
- * @memberof Matrix3
993
- *
994
- * @param {Matrix3} right The right hand side matrix.
995
- * @param {Matrix3} [result] The object onto which to store the result.
996
- * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
997
- *
998
- * @exception {DeveloperError} right is required.
999
- */
1000
- Matrix3.prototype.multiply = function(right, result) {
1001
- return Matrix3.multiply(this, right, result);
1002
- };
1003
-
1004
- /**
1005
- * Computes the product of this matrix and a column vector.
1006
- * @memberof Matrix3
1007
- *
1008
- * @param {Cartesian3} cartesian The column.
1009
- * @param {Cartesian3} [result] The object onto which to store the result.
1010
- * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
1011
- *
1012
- * @exception {DeveloperError} cartesian is required.
1013
- */
1014
- Matrix3.prototype.multiplyByVector = function(cartesian, result) {
1015
- return Matrix3.multiplyByVector(this, cartesian, result);
1016
- };
1017
-
1018
- /**
1019
- * Computes the product of this matrix and a scalar.
1020
- * @memberof Matrix3
1021
- *
1022
- * @param {Number} scalar The number to multiply by.
1023
- * @param {Matrix3} [result] The object onto which to store the result.
1024
- * @returns {Matrix3} The modified result parameter or a new Cartesian3 instance if one was not provided.
1025
- *
1026
- * @exception {DeveloperError} scalar is required and must be a number.
1027
- */
1028
- Matrix3.prototype.multiplyByScalar = function(scalar, result) {
1029
- return Matrix3.multiplyByScalar(this, scalar, result);
1030
- };
1031
- /**
1032
- * Creates a negated copy of this matrix.
1033
- * @memberof Matrix3
1034
- *
1035
- * @param {Matrix3} matrix The matrix to negate.
1036
- * @param {Matrix3} [result] The object onto which to store the result.
1037
- * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
1038
- *
1039
- * @exception {DeveloperError} matrix is required.
1040
- */
1041
- Matrix3.prototype.negate = function(result) {
1042
- return Matrix3.negate(this, result);
1043
- };
1044
-
1045
- /**
1046
- * Computes the transpose of this matrix.
1047
- * @memberof Matrix3
1048
- *
1049
- * @param {Matrix3} [result] The object onto which to store the result.
1050
- * @returns {Matrix3} The modified result parameter or a new Matrix3 instance if one was not provided.
1051
- */
1052
- Matrix3.prototype.transpose = function(result) {
1053
- return Matrix3.transpose(this, result);
1054
- };
1055
-
1056
1071
  /**
1057
1072
  * Compares this matrix to the provided matrix componentwise and returns
1058
1073
  * <code>true</code> if they are equal, <code>false</code> otherwise.
@@ -1095,4 +1110,4 @@ define(['Core/Cartesian3', 'Core/defaultValue', 'Core/defined', 'Core/DeveloperE
1095
1110
  };
1096
1111
 
1097
1112
  return Matrix3;
1098
- });
1113
+ });