|
4 | 4 | from numpy import ( |
5 | 5 | array, concatenate, identity, multiply, ones_like, repeat, |
6 | 6 | ) |
7 | | -from collections import namedtuple |
8 | 7 | from sgp4.api import SGP4_ERRORS, Satrec |
9 | 8 |
|
10 | 9 | from .constants import AU_KM, DAY_S, T0, tau |
11 | 10 | from .framelib import LVLH |
12 | 11 | from .functions import _T, mxm, mxv, rot_x, rot_y, rot_z |
| 12 | +from .positionlib import Geometric |
13 | 13 | from .searchlib import _find_discrete, find_maxima |
14 | 14 | from .timelib import compute_calendar_date |
15 | 15 | from .vectorlib import VectorFunction |
@@ -284,26 +284,32 @@ def below_horizon_at(t): |
284 | 284 | return ts.tt_jd(jd[i]), v[i] |
285 | 285 |
|
286 | 286 | def _attitude(self, t, roll=0.0, pitch=0.0, yaw=0.0, rotation_order="xyz"): |
287 | | - """Return a unit vector in the attitude direction in local coordinates. |
| 287 | + """Return a unit vector in the attitude direction in ICRF coordinates. |
288 | 288 |
|
289 | | - Rotations are applied to an initial vector pointing along the z-axis. |
290 | | - Rotations should be provided as radians; `roll` is rotation about the |
291 | | - x-axis, `pitch` is about the y-axis, and `yaw` is about the z-axis. |
| 289 | + Rotations are applied relative to the LVLH frame axes, where the |
| 290 | + neutral attitude vector is pointing along the z-axis. Rotation angles |
| 291 | + should be provided as radians; `roll` is rotation about the x-axis, |
| 292 | + `pitch` is about the y-axis, and `yaw` is about the z-axis. |
292 | 293 | """ |
293 | 294 | rotations = { |
294 | | - "x": rot_x(roll) if roll != 0 else _identity, |
295 | | - "y": rot_y(pitch) if pitch != 0 else _identity, |
296 | | - "z": rot_z(yaw) if yaw != 0 else _identity, |
| 295 | + "x": (roll, rot_x), |
| 296 | + "y": (pitch, rot_y), |
| 297 | + "z": (yaw, rot_z), |
297 | 298 | } |
298 | 299 |
|
299 | 300 | lvlh_attitude = array([0, 0, 1]) |
300 | 301 | for axis in rotation_order: |
301 | | - lvlh_attitude = mxv(rotations[axis], lvlh_attitude) |
302 | | - |
303 | | - lvlh_frame = LVLH(self) |
304 | | - direction = mxv(lvlh_frame.rotation_at(t), lvlh_attitude) |
305 | | - Attitude = namedtuple("Attitude", "center, target, t") |
306 | | - attitude = Attitude(self.at(t).position, direction, t) |
| 302 | + angle, rotation = rotations[axis] |
| 303 | + if angle != 0: |
| 304 | + lvlh_attitude = mxv(rotation(angle), lvlh_attitude) |
| 305 | + |
| 306 | + R = LVLH(self).rotation_at(t) |
| 307 | + direction = mxv(R, lvlh_attitude) |
| 308 | + attitude = Geometric( |
| 309 | + position_au=self.at(t).xyz.au, |
| 310 | + velocity_au_per_d=self.at(t).velocity.au_per_d, |
| 311 | + t=t, center=self.at(t), target=direction |
| 312 | + ) |
307 | 313 |
|
308 | 314 | return attitude |
309 | 315 |
|
|
0 commit comments