trafficgen.utils module
Utility functions that are used by several other functions.
- trafficgen.utils.calculate_bearing_between_waypoints(position_prev: Position, position_next: Position) float [source]
Calculate the bearing in rad between two waypoints.
- Params:
position_prev{latitude, longitude}: Previous waypoint [rad]
position_next{latitude, longitude}: Next waypoint [rad]
- Returns:
* bearing
- Return type:
Bearing between waypoints [m]
- trafficgen.utils.calculate_destination_along_track(position_prev: Position, distance: float, bearing: float) Position [source]
Calculate the destination along the track between two waypoints when distance along the track is given.
- Params:
position_prev{latitude, longitude}: Previous waypoint [rad]
distance: Distance to travel [m]
bearing: Bearing from previous waypoint to next waypoint [rad]
- Returns:
* destination{latitude, longitude}
- Return type:
Destination along the track [rad]
- trafficgen.utils.calculate_distance(position_prev: Position, position_next: Position) float [source]
Calculate the distance in meter between two waypoints.
- Params:
position_prev{latitude, longitude}: Previous waypoint [rad]
position_next{latitude, longitude}: Next waypoint [rad]
- Returns:
* distance
- Return type:
Distance between waypoints [m]
- trafficgen.utils.calculate_position_along_track_using_waypoints(waypoints: List[Waypoint], inital_speed: float, vector_time: float) Position [source]
Calculate the position of the ship at a given time based on initial position and delta time, and constant speed and course.
- Params:
position{latitude, longitude}: Initial ship position [rad]
speed: Ship speed [m/s]
course: Ship course [rad]
delta_time: Delta time from now to the time new position is being calculated [sec]
- Returns:
* position{latitude, longitude}
- Return type:
Estimated ship position in delta time minutes [rad]
- trafficgen.utils.calculate_position_at_certain_time(position: Position, lat_lon0: Position, speed: float, course: float, delta_time: float) Position [source]
Calculate the position of the ship at a given time based on initial position and delta time, and constant speed and course.
- Params:
position{latitude, longitude}: Initial ship position [rad]
speed: Ship speed [m/s]
course: Ship course [rad]
delta_time: Delta time from now to the time new position is being calculated [minutes]
- Returns:
* position{latitude, longitude}
- Return type:
Estimated ship position in delta time minutes [rad]
- trafficgen.utils.convert_angle_0_to_2_pi_to_minus_pi_to_pi(angle_2_pi: float) float [source]
Convert an angle given in the region 0 to 2*pi degrees to an angle given in the region -pi to pi degrees.
- Params:
angle_2_pi: Angle given in the region 0 to 2pi radians
- Returns:
* angle_pi
- Return type:
Angle given in the region -pi to pi radians
- trafficgen.utils.convert_angle_minus_pi_to_pi_to_0_to_2_pi(angle_pi: float) float [source]
Convert an angle given in the region -pi to pi degrees to an angle given in the region 0 to 2pi radians.
- Params:
angle_pi: Angle given in the region -pi to pi radians
- Returns:
* angle_2_pi
- Return type:
Angle given in the region 0 to 2pi radians
- trafficgen.utils.deg_2_rad(angle_in_degrees: float) float [source]
Convert angle given in degrees to angle give in radians.
- Params:
angle_in_degrees: Angle given in degrees
- Returns:
* angle given in radians
- Return type:
Angle given in radians
- trafficgen.utils.knot_2_m_pr_s(speed_in_knot: float) float [source]
Convert ship speed in knots to meters pr second.
- Params:
speed_in_knot: Ship speed given in knots
- Returns:
* speed_in_m_pr_s
- Return type:
Ship speed in meters pr second
- trafficgen.utils.m_2_nm(length_in_m: float) float [source]
Convert length given in meters to length given in nautical miles.
- Params:
length_in_m: Length given in meters
- Returns:
* length_in_nm
- Return type:
Length given in nautical miles
- trafficgen.utils.m_pr_s_2_knot(speed_in_m_pr_s: float) float [source]
Convert ship speed in knots to meters pr second.
- Params:
speed_in_m_pr_s: Ship speed given in meters pr second
- Returns:
* speed_in_knot
- Return type:
Ship speed in knots
- trafficgen.utils.min_2_s(time_in_min: float) float [source]
Convert time given in minutes to time given in seconds.
- Params:
time_in_min: Time given in minutes
- Returns:
* time_in_s
- Return type:
Time in seconds