|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | """Raw transforms between coordinate frames, as NumPy matrices.""" |
3 | 3 |
|
4 | | -from numpy import array |
5 | | - |
6 | | -from .constants import ANGVEL, ASEC2RAD, DAY_S, pi, tau |
| 4 | +from numpy import array, cross |
| 5 | +from .constants import ANGVEL, ASEC2RAD, DAY_S, tau |
7 | 6 | from .data.spice import inertial_frames as _inertial_frames |
8 | | -from .elementslib import osculating_elements_of |
9 | | -from .functions import mxm, mxmxm, rot_x, rot_y, rot_z |
| 7 | +from .functions import length_of, mxm, rot_x, rot_z |
10 | 8 |
|
11 | 9 |
|
12 | 10 | def build_matrix(): |
@@ -172,13 +170,14 @@ def __init__(self, satellite): |
172 | 170 |
|
173 | 171 | def rotation_at(self, t): |
174 | 172 | position = self.satellite.at(t) |
175 | | - elements = osculating_elements_of(position) |
176 | | - i = elements.inclination.radians |
177 | | - u = elements.argument_of_latitude.radians |
178 | | - om = elements.longitude_of_ascending_node.radians |
179 | | - |
180 | | - matrix = mxmxm(rot_x(pi / 2.0), rot_y(pi / 2.0), rot_y(om - pi)) |
181 | | - matrix = mxmxm(matrix, rot_z(pi - i), rot_y(-u)) |
| 173 | + position_vec = position.position.km |
| 174 | + velocity_vec = position.velocity.km_per_s |
| 175 | + z_lvlh = -position_vec / length_of(position_vec) |
| 176 | + L_vec = cross(velocity_vec, z_lvlh) |
| 177 | + y_lvlh = -L_vec / length_of(L_vec) |
| 178 | + x_lvlh = cross(y_lvlh, z_lvlh) |
| 179 | + |
| 180 | + matrix = array([x_lvlh, y_lvlh, z_lvlh]).T |
182 | 181 |
|
183 | 182 | return matrix |
184 | 183 |
|
|
0 commit comments