mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user