hexrd.gridutil module

hexrd.gridutil.cellCentroids(crd, con)[source]
hexrd.gridutil.cellConnectivity(m, n, p=1, origin='ul')[source]

p x m x n (layers x rows x cols)

origin can be upper left – ‘ul’ <default> or lower left – ‘ll’

choice will affect handedness (cw or ccw)

hexrd.gridutil.cellIndices(edges, points_1d)[source]

get indices in a 1-d regular grid.

edges are just that:

point: x (2.5)

edges: |1 |2 |3 |4 |5
indices: | 0 | 1 | 2 | 3 |

above the deltas are + and the index for the point is 1

point: x (2.5)

edges: |5 |4 |3 |2 |1
indices: | 0 | 1 | 2 | 3 |

here the deltas are - and the index for the point is 2

  • can handle grids with +/- deltas

  • be careful when using with a cyclical angular array! edges and points must be mapped to the same branch cut, and abs(edges[0] - edges[-1]) = 2*pi

hexrd.gridutil.computeArea(polygon)[source]

must be ORDERED and CONVEX!

hexrd.gridutil.computeIntersection(line1, line2)[source]

compute intersection of two-dimensional line intersection Returns the intersection point as an array of length 2. If the lines are parallel (or equal) the function returns an empty array.

this is an implementation of two lines:

line1 = [ [x1, y1], [x2, y2] ] line2 = [ [x3, y3], [x4, y4] ]

hexrd.gridutil.compute_areas(xy_eval_vtx, conn)[source]
hexrd.gridutil.isinside(point, boundary, ccw=True)[source]

Assumes CCW boundary ordering

hexrd.gridutil.make_tolerance_grid(bin_width, window_width, num_subdivisions, adjust_window=False, one_sided=False)[source]
hexrd.gridutil.sutherlandHodgman(subjectPolygon, clipPolygon)[source]

https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm