# Path: beyond/frames/local.py
# def to_local(frame, orbit, expanded=True):
#     """Provide the transformation matrix to convert a vector from an inertial frame
#     to a local orbital reference frame of choice
# 
#     Args:
#         frame (str): Name of the local orbital frame ('QSW' or 'TNW')
#         orbit (List[float]) : cartesian coordinates (length 6)
#         expanded (bool) : If ``True`` the returned matrix is 6x6, 3x3 otherwise
#     Return:
#         numpy.ndarray : Transformation matrix
# 
#     >>> delta_tnw = [1, 0, 0]
#     >>> p = [-6142438.668, 3492467.560, -25767.25680]
#     >>> v = [505.8479685, 942.7809215, 7435.922231]
#     >>> pv = p + v
#     >>> mat = to_local("TNW", pv, expanded=False).T
#     >>> delta_inert = mat @ delta_tnw
#     >>> all(delta_inert == v / norm(v))
#     True
#     """
# 
#     if frame.upper() == "QSW":
#         m = to_qsw(orbit)
#     elif frame.upper() == "TNW":
#         m = to_tnw(orbit)
#     else:
#         raise ValueError(f"Unknown local orbital frame : {frame}")
# 
#     if expanded:
#         m = expand(m)
# 
#     return m
# 
# def to_tnw(orbit):
#     """In the TNW Local Orbital Reference Frame, x is oriented along the velocity vector,
#     z along the angular momentum, and y complete the frame.
# 
#     Args:
#         orbit (list): Array of length 6
#     Return:
#         numpy.ndarray: matrix to convert from inertial frame to TNW.
# 
#     >>> delta_tnw = [1, 0, 0]
#     >>> p = [-6142438.668, 3492467.560, -25767.25680]
#     >>> v = [505.8479685, 942.7809215, 7435.922231]
#     >>> pv = p + v
#     >>> mat = to_tnw(pv).T
#     >>> delta_inert = mat @ delta_tnw
#     >>> all(delta_inert == v / norm(v))
#     True
# 
#     .. image:: /_static/tnw.svg
#         :align: center
#         :width: 30%
#     """
# 
#     pos, vel = _split(orbit)
# 
#     t = vel / norm(vel)
#     w = np.cross(pos, vel)
#     w /= norm(w)
#     n = np.cross(w, t)
# 
#     return np.array([t, n, w])


import logging
import numpy as np
from abc import ABCMeta, abstractmethod
from ..frames.local import to_local, to_tnw
        self.frame = frame
        self.comment = comment

        log.debug(f"Man [{self.start}; {self.stop}[")

    def __repr__(self):  # pragma: no cover
        txt = """ContinuousMan =
  start    = {0.start}
  stop     = {0.stop}
  median   = {0.median}
  duration = {0.duration}
"""
        if self.frame:
            txt += "  frame    = {0.frame}\n"
        if self.comment:
            txt += "  comment  = {0.comment}\n"
        txt += "  accel    =\n"
        for i, x in enumerate("xyz"):
            txt += f"    {x} = {self._accel[i]:0.2g} m/s²\n"

        return txt.format(self)

    def check(self, date):
        return self.start <= date < self.stop

    def accel(self, orb):

        orb = orb.copy(form="cartesian")

        if self.frame in ("QSW", "TNW"):

# Path: beyond/frames/local.py
# def to_local(frame, orbit, expanded=True):
#     """Provide the transformation matrix to convert a vector from an inertial frame
#     to a local orbital reference frame of choice
# 
#     Args:
#         frame (str): Name of the local orbital frame ('QSW' or 'TNW')
#         orbit (List[float]) : cartesian coordinates (length 6)
#         expanded (bool) : If ``True`` the returned matrix is 6x6, 3x3 otherwise
#     Return:
#         numpy.ndarray : Transformation matrix
# 
#     >>> delta_tnw = [1, 0, 0]
#     >>> p = [-6142438.668, 3492467.560, -25767.25680]
#     >>> v = [505.8479685, 942.7809215, 7435.922231]
#     >>> pv = p + v
#     >>> mat = to_local("TNW", pv, expanded=False).T
#     >>> delta_inert = mat @ delta_tnw
#     >>> all(delta_inert == v / norm(v))
#     True
#     """
# 
#     if frame.upper() == "QSW":
#         m = to_qsw(orbit)
#     elif frame.upper() == "TNW":
#         m = to_tnw(orbit)
#     else:
#         raise ValueError(f"Unknown local orbital frame : {frame}")
# 
#     if expanded:
#         m = expand(m)
# 
#     return m
# 
# def to_tnw(orbit):
#     """In the TNW Local Orbital Reference Frame, x is oriented along the velocity vector,
#     z along the angular momentum, and y complete the frame.
# 
#     Args:
#         orbit (list): Array of length 6
#     Return:
#         numpy.ndarray: matrix to convert from inertial frame to TNW.
# 
#     >>> delta_tnw = [1, 0, 0]
#     >>> p = [-6142438.668, 3492467.560, -25767.25680]
#     >>> v = [505.8479685, 942.7809215, 7435.922231]
#     >>> pv = p + v
#     >>> mat = to_tnw(pv).T
#     >>> delta_inert = mat @ delta_tnw
#     >>> all(delta_inert == v / norm(v))
#     True
# 
#     .. image:: /_static/tnw.svg
#         :align: center
#         :width: 30%
#     """
# 
#     pos, vel = _split(orbit)
# 
#     t = vel / norm(vel)
#     w = np.cross(pos, vel)
#     w /= norm(w)
#     n = np.cross(w, t)
# 
#     return np.array([t, n, w])


# Path: beyond/orbits/man.py
import logging
import numpy as np
from abc import ABCMeta, abstractmethod
from ..frames.local import to_local, to_tnw

        self.frame = frame
        self.comment = comment

        log.debug(f"Man [{self.start}; {self.stop}[")

    def __repr__(self):  # pragma: no cover
        txt = """ContinuousMan =
  start    = {0.start}
  stop     = {0.stop}
  median   = {0.median}
  duration = {0.duration}
"""
        if self.frame:
            txt += "  frame    = {0.frame}\n"
        if self.comment:
            txt += "  comment  = {0.comment}\n"
        txt += "  accel    =\n"
        for i, x in enumerate("xyz"):
            txt += f"    {x} = {self._accel[i]:0.2g} m/s²\n"

        return txt.format(self)

    def check(self, date):
        return self.start <= date < self.stop

    def accel(self, orb):

        orb = orb.copy(form="cartesian")

        if self.frame in ("QSW", "TNW"):

            mat = to_local(self.frame, orb, expanded=False).T