| 340 | |
| 341 | # assume 0 < nx < ny, a < 0 |
| 342 | def GetLineEnds(nx, ny, a): |
| 343 | xl = [(a + 0.5 * ny) / nx, (a + 0.5 * nx) / ny] |
| 344 | xr = [(a - 0.5 * ny) / nx, (a - 0.5 * nx) / ny] |
| 345 | |
| 346 | e = [] |
| 347 | if -0.5 <= xl[0] and xl[0] <= 0.5: |
| 348 | e.append([xl[0], -0.5]) |
| 349 | if -0.5 <= xr[0] and xr[0] <= 0.5: |
| 350 | e.append([xr[0], 0.5]) |
| 351 | if len(e) < 2 and -0.5 <= xl[1] and xl[1] <= 0.5: |
| 352 | e.append([-0.5, xl[1]]) |
| 353 | if len(e) < 2 and -0.5 <= xr[1] and xr[1] <= 0.5: |
| 354 | e.append([0.5, xr[1]]) |
| 355 | |
| 356 | if len(e) == 1: # if only one point found, set second to the same |
| 357 | e.append(e[0]) |
| 358 | |
| 359 | return e |
| 360 | |
| 361 | |
| 362 | # xc,yc: cell centers |