arrayTools

Rewritten to elimate the numpy dependency

calcBounds(array)

Return the bounding rectangle of a 2D points array as a tuple: (xMin, yMin, xMax, yMax)

updateBounds()

Return the bounding recangle of rectangle bounds and point (x, y).

pointInRect()

Return True when point (x, y) is inside rect.

pointsInRect(array, rect)

Find out which points or array are inside rect. Returns an array with a boolean for each point.

vectorLength(vector)

Return the length of the given vector.

asInt16(array)

Round and cast to 16 bit integer.

normRect()

Normalize the rectangle so that the following holds: xMin <= xMax and yMin <= yMax

scaleRect()

Scale the rectangle by x, y.

offsetRect()

Offset the rectangle by dx, dy.

insetRect()

Inset the rectangle by dx, dy on all sides.

sectRect()

Return a boolean and a rectangle. If the input rectangles intersect, return True and the intersecting rectangle. Return False and (0, 0, 0, 0) if the input rectangles don’t intersect.

unionRect()

Return the smallest rectangle in which both input rectangles are fully enclosed. In other words, return the total bounding rectangle of both input rectangles.

rectCenter()

Return the center of the rectangle as an (x, y) coordinate.

intRect()

Return the rectangle, rounded off to integer values, but guaranteeing that the resulting rectangle is NOT smaller than the original.

links