Creates lists of x and y values to plot the arrows Gets length of each barb then calculates the length of each side of the arrow. Gets angle of barb and applies angle to each side of the arrowhead. Next uses arrow_scale to scale the length of arrowhead and c
(self)
| 194 | return barb_x, barb_y |
| 195 | |
| 196 | def get_quiver_arrows(self): |
| 197 | """ |
| 198 | Creates lists of x and y values to plot the arrows |
| 199 | |
| 200 | Gets length of each barb then calculates the length of each side of |
| 201 | the arrow. Gets angle of barb and applies angle to each side of the |
| 202 | arrowhead. Next uses arrow_scale to scale the length of arrowhead and |
| 203 | creates x and y values for arrowhead point1 and point2. Finally x and y |
| 204 | values for point1, endpoint and point2s for each arrowhead are |
| 205 | separated by a None and zipped to create lists of x and y values for |
| 206 | the arrows. |
| 207 | |
| 208 | :rtype: (list, list) arrow_x, arrow_y: list of point1, endpoint, point2 |
| 209 | x_values separated by a None to create the arrowhead and list of |
| 210 | point1, endpoint, point2 y_values separated by a None to create |
| 211 | the barb of the arrow. |
| 212 | """ |
| 213 | dif_x = [i - j for i, j in zip(self.end_x, self.x)] |
| 214 | dif_y = [i - j for i, j in zip(self.end_y, self.y)] |
| 215 | |
| 216 | # Get barb lengths(default arrow length = 30% barb length) |
| 217 | barb_len = [None] * len(self.x) |
| 218 | for index in range(len(barb_len)): |
| 219 | barb_len[index] = math.hypot(dif_x[index] / self.scaleratio, dif_y[index]) |
| 220 | |
| 221 | # Make arrow lengths |
| 222 | arrow_len = [None] * len(self.x) |
| 223 | arrow_len = [i * self.arrow_scale for i in barb_len] |
| 224 | |
| 225 | # Get barb angles |
| 226 | barb_ang = [None] * len(self.x) |
| 227 | for index in range(len(barb_ang)): |
| 228 | barb_ang[index] = math.atan2(dif_y[index], dif_x[index] / self.scaleratio) |
| 229 | |
| 230 | # Set angles to create arrow |
| 231 | ang1 = [i + self.angle for i in barb_ang] |
| 232 | ang2 = [i - self.angle for i in barb_ang] |
| 233 | |
| 234 | cos_ang1 = [None] * len(ang1) |
| 235 | for index in range(len(ang1)): |
| 236 | cos_ang1[index] = math.cos(ang1[index]) |
| 237 | seg1_x = [i * j for i, j in zip(arrow_len, cos_ang1)] |
| 238 | |
| 239 | sin_ang1 = [None] * len(ang1) |
| 240 | for index in range(len(ang1)): |
| 241 | sin_ang1[index] = math.sin(ang1[index]) |
| 242 | seg1_y = [i * j for i, j in zip(arrow_len, sin_ang1)] |
| 243 | |
| 244 | cos_ang2 = [None] * len(ang2) |
| 245 | for index in range(len(ang2)): |
| 246 | cos_ang2[index] = math.cos(ang2[index]) |
| 247 | seg2_x = [i * j for i, j in zip(arrow_len, cos_ang2)] |
| 248 | |
| 249 | sin_ang2 = [None] * len(ang2) |
| 250 | for index in range(len(ang2)): |
| 251 | sin_ang2[index] = math.sin(ang2[index]) |
| 252 | seg2_y = [i * j for i, j in zip(arrow_len, sin_ang2)] |
| 253 |
no outgoing calls
no test coverage detected