In [3]:
from math import pi
import math
from ../
AMP_heading = pi/2 # rotation of AMP (radians from from due north)
M3_swath = [0,120] # minimum and maximum angles for target detection (in degrees)
point1 = [20,100] # range, bearing (degrees)
point2 = [21,105] # range, bearing (degrees)
target_velocity(point1, point2, AMP_heading, M3_swath = [0,120])
Out[3]:
In [2]:
def target_velocity(target, AMP_heading, M3_swath = [0,120])
def velocity_between_two_points(point1, point2, AMP_heading, M3_swath = [0,120]):
"""
Determines magnitude and direction of target trajectory (from point 1 to point 2)
Inputs:
point 1, point 2 = points where target was detected, in list format [range, bearing in degrees]
AMP_heading = heading of AMP, in radians from due north
M3_swath = list containing minimum and maximum angle ( in degrees) for M3 target
detection. Default is 0 --> 120 degrees
Outputs:
vel = [velocity magnitude, velocity direction]
"""
point1_cartesian = transform_NIMS_to_vector(point1, AMP_heading, M3_swath)
point2_cartesian = transform_NIMS_to_vector(point2, AMP_heading, M3_swath)
# subtract 2-1 to get velocity
vel = [point2_cartesian[0] - point1_cartesian[0], point2_cartesian[1] - point1_cartesian[1]]
# calculate magnitude and angle of velocity
vel_angle = math.atan(vel[1]/vel[0])
vel_mag = (vel[0]**2 + vel[1]**2)**1/2
return([vel_mag, vel_angle])
def transform_NIMS_to_vector(point, AMP_heading, M3_swath):
"""
Transform NIMS detection (in format [range, bearing in degrees]) to earth coordinates (East-North)
Returns X-Y coordinates of point after transformation.
"""
# convert target bearing tp radians, and shift such that zero degrees is center of swath
point[1] = (point[1] - (M3_swath[1] - M3_swath[0])/2) * pi/180
# convert bearing to angle from due N by subtracting AMP angle
point[1] = point[1] - AMP_heading
# get vector components for point 1 and 2
point_cartesian = [point[0] * math.cos(point[1]), point[0] * math.sin(point[1])]
return(point_cartesian)
In [ ]: