Python: implemented InverseRotation function. Cleaned up trailing whitespace.

Also added missing check in Python apsis test where
I did not verify that each apsis kind was correct.
This commit is contained in:
Don Cross
2019-12-15 20:23:35 -05:00
parent e1d1aa4b50
commit 8c590e4449
13 changed files with 109 additions and 21 deletions

View File

@@ -780,6 +780,23 @@ This will be less than or equal to zero.
---
<a name="InverseRotation"></a>
### InverseRotation(rotation)
**Calculates the inverse of a rotation matrix.**
Given a rotation matrix that performs some coordinate transform,
this function returns the matrix that reverses that trasnform.
| Type | Parameter | Description |
| --- | --- | --- |
| [`RotationMatrix`](#RotationMatrix) | `rotation` | The rotation matrix to be inverted. |
### Returns: RotationMatrix
The inverse rotation matrix.
---
<a name="LongitudeFromSun"></a>
### LongitudeFromSun(body, time)

View File

@@ -5083,6 +5083,28 @@ def NextLunarApsis(apsis):
raise InternalError()
return next
def InverseRotation(rotation):
"""Calculates the inverse of a rotation matrix.
Given a rotation matrix that performs some coordinate transform,
this function returns the matrix that reverses that trasnform.
Parameters
----------
rotation : RotationMatrix
The rotation matrix to be inverted.
Returns
-------
RotationMatrix
The inverse rotation matrix.
"""
return RotationMatrix([
[rotation.rot[0][0], rotation.rot[1][0], rotation.rot[2][0]],
[rotation.rot[0][1], rotation.rot[1][1], rotation.rot[2][1]],
[rotation.rot[0][2], rotation.rot[1][2], rotation.rot[2][2]]
])
def RotateVector(rotation, vector):
"""Applies a rotation to a vector, yielding a rotated vector.
@@ -5123,8 +5145,8 @@ def Rotation_EQJ_ECL():
A rotation matrix that converts EQJ to ECL.
"""
# ob = mean obliquity of the J2000 ecliptic = 0.40909260059599012 radians.
c = 0.9174821430670688; # cos(ob)
s = 0.3977769691083922; # sin(ob)
c = 0.9174821430670688 # cos(ob)
s = 0.3977769691083922 # sin(ob)
return RotationMatrix([
[ 1, 0, 0],
[ 0, +c, -s],