Skip to content

Commit ac7be10

Browse files
authored
Merge pull request #8934 from easternmotors/master
Exposing Transforms.rotationMatrixFromPositionVelocity
2 parents e951c03 + 9741f4b commit ac7be10

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
##### Additions :tada:
66

77
- Add a `toString` method to the `Resource` class in case an instance gets logged as a string. [#8722](https://github.com/CesiumGS/cesium/issues/8722)
8+
- Exposed `Transforms.rotationMatrixFromPositionVelocity` method from Cesium's private API. [#8927](https://github.com/CesiumGS/cesium/issues/8927)
89

910
##### Fixes :wrench:
1011

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
262262
- [Edvinas Pranka](https://github.com/epranka)
263263
- [James Bromwell](https://github.com/thw0rted)
264264
- [Brandon Nguyen](https://github.com/bn-dignitas)
265+
- [John Remsberg](https://github.com/easternmotors)

Source/Core/Transforms.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,13 @@ var rightScratch = new Cartesian3();
949949
var upScratch = new Cartesian3();
950950

951951
/**
952-
* @private
952+
* Transform a position and velocity to a rotation matrix.
953+
*
954+
* @param {Cartesian3} position The position to transform.
955+
* @param {Cartesian3} velocity The velocity vector to transform.
956+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid whose fixed frame is used in the transformation.
957+
* @param {Matrix3} [result] The object onto which to store the result.
958+
* @returns {Matrix3} The modified result parameter or a new Matrix3 instance if none was provided.
953959
*/
954960
Transforms.rotationMatrixFromPositionVelocity = function (
955961
position,

Specs/Core/TransformsSpec.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,59 @@ describe("Core/Transforms", function () {
17161716
expect(returnedResult).toEqualEpsilon(expected, CesiumMath.EPSILON12);
17171717
});
17181718

1719+
it("rotationMatrixFromPositionVelocity works without a result parameter", function () {
1720+
var matrix = Transforms.rotationMatrixFromPositionVelocity(
1721+
Cartesian3.UNIT_X,
1722+
Cartesian3.UNIT_Y
1723+
);
1724+
var expected = new Matrix3(0, 0, 1, 1, 0, 0, 0, 1, 0);
1725+
expect(matrix).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1726+
1727+
matrix = Transforms.rotationMatrixFromPositionVelocity(
1728+
Cartesian3.UNIT_X,
1729+
Cartesian3.UNIT_Z
1730+
);
1731+
expected = new Matrix3(0, 0, 1, 0, -1, 0, 1, 0, 0);
1732+
expect(matrix).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1733+
1734+
matrix = Transforms.rotationMatrixFromPositionVelocity(
1735+
Cartesian3.UNIT_Y,
1736+
Cartesian3.UNIT_Z
1737+
);
1738+
expected = new Matrix3(0, 1, 0, 0, 0, 1, 1, 0, 0);
1739+
expect(matrix).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1740+
});
1741+
1742+
it("rotationMatrixFromPositionVelocity works with a result parameter", function () {
1743+
var result = new Matrix3();
1744+
Transforms.rotationMatrixFromPositionVelocity(
1745+
Cartesian3.UNIT_X,
1746+
Cartesian3.UNIT_Y,
1747+
Ellipsoid.WGS84,
1748+
result
1749+
);
1750+
var expected = new Matrix3(0, 0, 1, 1, 0, 0, 0, 1, 0);
1751+
expect(result).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1752+
1753+
Transforms.rotationMatrixFromPositionVelocity(
1754+
Cartesian3.UNIT_X,
1755+
Cartesian3.UNIT_Z,
1756+
Ellipsoid.WGS84,
1757+
result
1758+
);
1759+
expected = new Matrix3(0, 0, 1, 0, -1, 0, 1, 0, 0);
1760+
expect(result).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1761+
1762+
Transforms.rotationMatrixFromPositionVelocity(
1763+
Cartesian3.UNIT_Y,
1764+
Cartesian3.UNIT_Z,
1765+
Ellipsoid.WGS84,
1766+
result
1767+
);
1768+
expected = new Matrix3(0, 1, 0, 0, 0, 1, 1, 0, 0);
1769+
expect(result).toEqualEpsilon(expected, CesiumMath.EPSILON14);
1770+
});
1771+
17191772
it("basisTo2D projects translation", function () {
17201773
var ellipsoid = Ellipsoid.WGS84;
17211774
var projection = new GeographicProjection(ellipsoid);

0 commit comments

Comments
 (0)