| 142 | const control_point_2_coord = get_position([100, 40]); |
| 143 | |
| 144 | function get_position_slope(t) { |
| 145 | const t_3_0 = (1 - t) ** 3; |
| 146 | const t_3_1 = 3 * (1 - t) ** 2 * t; |
| 147 | const t_3_2 = 3 * (1 - t) * t ** 2; |
| 148 | const t_3_3 = t ** 3; |
| 149 | const position = [ |
| 150 | t_3_0 * gradient_start_position[0] + t_3_1 * control_point_1_coord[0] + t_3_2 * control_point_2_coord[0] + t_3_3 * flight_end_position[0], |
| 151 | t_3_0 * gradient_start_position[1] + t_3_1 * control_point_1_coord[1] + t_3_2 * control_point_2_coord[1] + t_3_3 * flight_end_position[1] |
| 152 | ] |
| 153 | const t_2_0 = -3 * (1 - t) ** 2; |
| 154 | const t_2_1 = 3 * (1 - 4 * t + 3 * t ** 2); |
| 155 | const t_2_2 = 3 * (2 * t - 3 * t ** 2); |
| 156 | const t_2_3 = 3 * t ** 2; |
| 157 | const direction = Math.atan2( |
| 158 | -(t_2_0 * gradient_start_position[1] + t_2_1 * control_point_1_coord[1] + t_2_2 * control_point_2_coord[1] + t_2_3 * flight_end_position[1]), |
| 159 | -(t_2_0 * gradient_start_position[0] + t_2_1 * control_point_1_coord[0] + t_2_2 * control_point_2_coord[0] + t_2_3 * flight_end_position[0]) |
| 160 | ); |
| 161 | return [position, direction]; |
| 162 | } |
| 163 | |
| 164 | const distance = cubicBezierLength( |
| 165 | gradient_start_position, |