The 6x6 state transformations of a two-body rotating frame (as defined by the
toolkit's two_body_rotating_frame), and their exact time derivatives.
The frame's axes are , (), , where is the secondary body's state w.r.t. the primary body. With the matrix whose rows are the axes, and (as in the toolkit) , :
(Both frames are assumed to have the same origin.) The time derivatives of
and are computed exactly from the time derivatives of
and (rdot, vdot). Note that is
the toolkit's definition, which is not exactly (it neglects the
rotation of ); the derivatives here are of the transformation as
it is actually defined.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in), | dimension(6) | :: | rv |
state of the secondary w.r.t. the primary [km, km/s] |
|
| real(kind=wp), | intent(in), | dimension(3) | :: | rdot |
time derivative of |
|
| real(kind=wp), | intent(in), | dimension(3) | :: | vdot |
time derivative of |
|
| real(kind=wp), | intent(out), | optional, | dimension(6,6) | :: | m |
inertial to rotating |
| real(kind=wp), | intent(out), | optional, | dimension(6,6) | :: | mdot |
dM/dt [1/s] |
| real(kind=wp), | intent(out), | optional, | dimension(6,6) | :: | n |
rotating to inertial |
| real(kind=wp), | intent(out), | optional, | dimension(6,6) | :: | ndot |
dN/dt [1/s] |
pure subroutine two_body_rotating_frame_matrices(rv,rdot,vdot,m,mdot,n,ndot) implicit none real(wp),dimension(6),intent(in) :: rv !! state of the secondary w.r.t. the primary [km, km/s] real(wp),dimension(3),intent(in) :: rdot !! time derivative of `rv(1:3)` [km/s] real(wp),dimension(3),intent(in) :: vdot !! time derivative of `rv(4:6)` [km/s^2] real(wp),dimension(6,6),intent(out),optional :: m !! inertial to rotating real(wp),dimension(6,6),intent(out),optional :: mdot !! dM/dt [1/s] real(wp),dimension(6,6),intent(out),optional :: n !! rotating to inertial real(wp),dimension(6,6),intent(out),optional :: ndot !! dN/dt [1/s] real(wp),dimension(3) :: r, v, h, hdot, xhat, yhat, zhat, xhatd, yhatd, zhatd, w, wdot real(wp),dimension(3,3) :: c, cd, cf, cfd real(wp) :: rmag, hmag r = rv(1:3) v = rv(4:6) rmag = norm2(r) h = cross(r,v) hmag = norm2(h) hdot = cross(rdot,v) + cross(r,vdot) xhat = r / rmag zhat = h / hmag yhat = cross(zhat,xhat) xhatd = (rdot - xhat*dot_product(xhat,rdot)) / rmag zhatd = (hdot - zhat*dot_product(zhat,hdot)) / hmag yhatd = cross(zhatd,xhat) + cross(zhat,xhatd) c(1,:) = xhat ; c(2,:) = yhat ; c(3,:) = zhat cd(1,:) = xhatd; cd(2,:) = yhatd; cd(3,:) = zhatd ! dC/dt w = h / (rmag*rmag) wdot = hdot/(rmag*rmag) - two*h*dot_product(r,rdot)/rmag**4 cf = -matmul(c, cross_matrix(w)) ! toolkit's "cdot" cfd = -matmul(cd, cross_matrix(w)) - matmul(c, cross_matrix(wdot)) ! d(cf)/dt if (present(m)) then m = zero m(1:3,1:3) = c m(4:6,1:3) = cf m(4:6,4:6) = c end if if (present(mdot)) then mdot = zero mdot(1:3,1:3) = cd mdot(4:6,1:3) = cfd mdot(4:6,4:6) = cd end if if (present(n)) then n = zero n(1:3,1:3) = transpose(c) n(4:6,1:3) = transpose(cf) n(4:6,4:6) = transpose(c) end if if (present(ndot)) then ndot = zero ndot(1:3,1:3) = transpose(cd) ndot(4:6,1:3) = transpose(cfd) ndot(4:6,4:6) = transpose(cd) end if end subroutine two_body_rotating_frame_matrices