3lips/event/data/Ellipsoid.py
2024-02-29 15:28:03 +00:00

49 lines
1.3 KiB
Python

"""
@file Ellipsoid.py
@author 30hours
"""
import math
class Ellipsoid:
"""
@class Ellipsoid
@brief A class to store ellipsoid parameters for bistatic radar.
@details Stores foci, midpoint, pitch, yaw and distance.
"""
def __init__(self, f1, f2, name):
"""
@brief Constructor for the Ellipsoid class.
@param f1 (list): [x, y, z] of foci 1 in ECEF.
@param f2 (list): [x, y, z] of foci 2 in ECEF.
@param name (str): Name to associate with shape.
"""
self.f1 = f1
self.f2 = f2
self.name = name
# dependent members
self.midpoint = [(f1[0]+f2[0])/2,
(f1[1]+f2[1])/2, (f1[2]+f2[2])/2]
vector = (f2[0]-f1[0], f2[1]-f1[1], f2[2]-f1[2])
self.yaw = math.atan2(vector[1], vector[0])
self.pitch = math.atan2(vector[2],
math.sqrt(vector[0]**2 + vector[1]**2))
self.distance = math.sqrt(
(f2[0] - f1[0])**2 +
(f2[1] - f1[1])**2 +
(f2[2] - f1[2])**2)
# rotate to normal plane on WGS-84
length = math.sqrt(
self.midpoint[0]**2 +
self.midpoint[1]**2 +
self.midpoint[2]**2
)
vector = [x / length for x in self.midpoint]
self.pitch_plane = math.asin(-vector[1])
self.yaw_plane = math.atan2(-vector[0], -vector[2])