[frames] | no frames]

# Module util

A wide variety of utility procedures and classes.

 Classes Pose Represent the x, y, theta pose of an object in 2D space Point Represent a point with its x, y values Transform Rotation and translation represented as 3 x 3 matrix Line Line in 2D space LineSeg Line segment in 2D space SymbolGenerator Generate new symbols guaranteed to be different from one another Optionally, supply a prefix for mnemonic purposes Call gensym("foo") to get a symbol like 'foo37'
Functions

 valueListToPose(values) Returns: a corresponding util.Pose

 localToGlobal(pose, point) Same as pose.transformPoint(point)

 localPoseToGlobalPose(pose1, pose2) Applies the transform from pose1 to pose2

 inversePose(pose) Same as pose.inverse()

 globalToLocal(pose, point) Applies inverse of pose to point.

 globalPoseToLocalPose(pose1, pose2) Applies inverse of pose1 to pose2.

 globalDeltaToLocal(pose, deltaPoint) Applies inverse of pose to delta using transformDelta.

 sum(items) Defined to work on items other than numbers, which is not true for the built-in sum.

 within(v1, v2, eps) Returns: True if v1 is with eps of v2

 nearAngle(a1, a2, eps) Returns: True if a1 is within eps of a2.

 nearlyEqual(x, y) Like within, but with the tolerance built in

 mm(t1, t2) Multiplies 3 x 3 matrices represented as lists of lists

 fixAnglePlusMinusPi(a) A is an angle in radians; return an equivalent angle between plus and minus pi

 fixAngle02Pi(a) Returns: return an equivalent angle between 0 and 2 pi

 reverseCopy(items) Return a list that is a reversed copy of items

 dotProd(a, b) Return the dot product of two lists of numbers

 argmax(l, f) Returns: the element of l that has the highest score

 argmaxWithVal(l, f) Returns: the element of l that has the highest score and the score

 argmaxIndex(l, f= at 0x11bbdb0>) Returns: the index of l that has the highest score

 argmaxIndices3D(l, f= at 0x11bbe30>)

 randomMultinomial(dist) Returns: random draw from that distribution

 clip(v, vMin, vMax) Returns: If vMin <= v <= vMax, then return v; if v < vMin return vMin; else return vMax

 sign(x) Return 1, 0, or -1 depending on the sign of x

 make2DArray(dim1, dim2, initValue) Return a list of lists representing a 2D array with dimensions dim1 and dim2, filled with initialValue

 make2DArrayFill(dim1, dim2, initFun) Return a list of lists representing a 2D array with dimensions dim1 and dim2, filled by calling initFun(ix, iy) with ix ranging from 0 to dim1 - 1 and iy ranging from 0 to dim2-1.

 make3DArray(dim1, dim2, dim3, initValue) Return a list of lists of lists representing a 3D array with dimensions dim1, dim2, and dim3 filled with initialValue

 mapArray3D(array, f) Map a function over the whole array.

 makeVector(dim, initValue) Return a list of dim copies of initValue

 makeVectorFill(dim, initFun) Return a list resulting from applying initFun to values from 0 to dim-1

 prettyString(struct) Make nicer looking strings for printing, mostly by truncating floats

 prettyPrint(struct)

 gensym(prefix='i') Call this function to get a new symbol

 logGaussian(x, mu, sigma) Log of the value of the gaussian distribution with mean mu and stdev sigma at value x

 gaussian(x, mu, sigma) Value of the gaussian distribution with mean mu and stdev sigma at value x

 lineIndices((i0, j0), (i1, j1)) Takes two cells in the grid (each described by a pair of integer indices), and returns a list of the cells in the grid that are on the line segment between the cells.

 lineIndicesConservative((i0, j0), (i1, j1)) Takes two cells in the grid (each described by a pair of integer indices), and returns a list of the cells in the grid that are on the line segment between the cells.

 findFile(filename) Takes a filename and returns a complete path to the first instance of the file found within the subdirectories of the brain directory.
 Variables __package__ = None
 Function Details

### valueListToPose(values)

Parameters:
• values - a list or tuple of three values: x, y, theta
Returns:
a corresponding util.Pose

### localToGlobal(pose, point)

Same as pose.transformPoint(point)

Parameters:
• point - instance of util.Point

### localPoseToGlobalPose(pose1, pose2)

Applies the transform from pose1 to pose2

Parameters:
• pose1 - instance of util.Pose
• pose2 - instance of util.Pose

### inversePose(pose)

Same as pose.inverse()

Parameters:
• pose - instance of util.Pose

### globalToLocal(pose, point)

Applies inverse of pose to point.

Parameters:
• pose - instance of util.Pose
• point - instance of util.Point

### globalPoseToLocalPose(pose1, pose2)

Applies inverse of pose1 to pose2.

Parameters:
• pose1 - instance of util.Pose
• pose2 - instance of util.Pose

### globalDeltaToLocal(pose, deltaPoint)

Applies inverse of pose to delta using transformDelta.

Parameters:
• pose - instance of util.Pose
• deltaPoint - instance of util.Point

### within(v1, v2, eps)

Parameters:
• v1 - number
• v2 - number
• eps - positive number
Returns:
True if v1 is with eps of v2

### nearAngle(a1, a2, eps)

Parameters:
• a1 - number representing angle; no restriction on range
• a2 - number representing angle; no restriction on range
• eps - positive number
Returns:
True if a1 is within eps of a2. Don't use within for this, because angles wrap around!

### fixAngle02Pi(a)

Parameters:
• a - angle in radians
Returns:
return an equivalent angle between 0 and 2 pi

### argmax(l, f)

Parameters:
• l - List of items
• f - Procedure that maps an item into a numeric score
Returns:
the element of l that has the highest score

### argmaxWithVal(l, f)

Parameters:
• l - List of items
• f - Procedure that maps an item into a numeric score
Returns:
the element of l that has the highest score and the score

### argmaxIndex(l, f=<function <lambda> at 0x11bbdb0>)

Parameters:
• l - List of items
• f - Procedure that maps an item into a numeric score
Returns:
the index of l that has the highest score

### randomMultinomial(dist)

Parameters:
• dist - List of positive numbers summing to 1 representing a multinomial distribution over integers from 0 to len(dist)-1.
Returns:
random draw from that distribution

### clip(v, vMin, vMax)

Parameters:
• v - number
• vMin - number (may be None, if no limit)
• vMax - number greater than vMin (may be None, if no limit)
Returns:
If vMin <= v <= vMax, then return v; if v < vMin return vMin; else return vMax

### mapArray3D(array, f)

Map a function over the whole array. Side effects the array. No return value.

### lineIndicesConservative((i0, j0), (i1, j1))

Takes two cells in the grid (each described by a pair of integer indices), and returns a list of the cells in the grid that are on the line segment between the cells. This is a conservative version.

 Generated by Epydoc 3.0.1 on Tue Apr 26 17:51:16 2011 http://epydoc.sourceforge.net