Geometric Utilities (lib601.util)¶
-
class
lib601.util.Pose(x, y, theta)¶ Represent the x, y, theta pose of an object in 2D space
-
diff(pose)¶ Parameters: pose – an instance of lib601.util.PoseReturns: a pose that is the difference between self and pose (in x, y, and theta)
-
distance(pose)¶ Parameters: pose – an instance of lib601.util.PoseReturns: the distance between the x,y part of self and the x,y part of pose.
-
inverse()¶ Return a pose corresponding to the transformation matrix that is the inverse of the transform associated with this pose. If this pose’s transformation maps points from frame X to frame Y, the inverse maps points from frame Y to frame X.
-
is_near(pose, distEps, angleEps)¶ Returns: True if pose is within distEps and angleEps of self
-
point()¶ Return just the x, y parts represented as an instance of
lib601.util.Point
-
transform()¶ Return a transformation matrix that corresponds to rotating by theta and then translating by x,y (in the original coordinate frame).
-
transform_delta(point)¶ Does the rotation by theta of the pose but does not add the x,y offset. This is useful in transforming the difference(delta) between two points.
Parameters: point – an instance of lib601.util.PointReturns: a lib601.util.Point.
-
transform_point(point)¶ Applies the pose.transform to point and returns new point.
Parameters: point – an instance of lib601.util.Point
-
transform_pose(pose)¶ Make self into a transformation matrix and apply it to pose.
Returns: Af new util.pose.
-
xyt_tuple()¶ Returns: a representation of this pose as a tuple of x, y, theta values
-
theta= 0.0¶ rotation in radians
-
x= 0.0¶ x coordinate
-
y= 0.0¶ y coordinate
-
-
class
lib601.util.Point(x, y)¶ Represent a point with its x, y values
-
add(point)¶ Vector addition
-
angle_to(p)¶ Parameters: p – instance of lib601.util.Pointorlib601.util.PoseReturns: angle in radians of vector from self to p
-
distance(point)¶ Parameters: point – instance of lib601.util.PointReturns: Euclidean distance between selfandlib601.util.Point
-
dot(p)¶ Dot product
-
magnitude()¶ Returns: Magnitude of this point, interpreted as a vector in 2-space
-
near(point, dist_eps)¶ Parameters: - point – instance of
lib601.util.Point - dist_eps – positive real number
Returns: true if the distance between
selfandlib601.util.Pointis less than dist_eps- point – instance of
-
scale(s)¶ Vector scaling
-
sub(point)¶ Vector subtraction
-
xy_tuple()¶ Returns: pair of x, y values
-
x= 0.0¶ x coordinate
-
y= 0.0¶ y coordinate
-
-
class
lib601.util.Transform(matrix=None)¶ Rotation and translation represented as 3 x 3 matrix
-
apply_to_point(point)¶ Transform a point into a new point.
-
apply_to_pose(pose)¶ Transform a pose into a new pose.
-
compose(trans)¶ Returns composition of self and trans
-
inverse()¶ Returns transformation matrix that is the inverse of this one
-
pose()¶ Convert to Pose
-
matrix= None¶ matrix representation of transform
-
-
class
lib601.util.Line(p1, p2)¶ Line in 2D space
Initialize with two points that are on the line. Actually, store a normal and an offset from the origin
-
angle_of()¶ Angle between line from (p1 to p2) and x-axis in radians
-
closest_point(p)¶ Return the point on the line that is closest to point p
-
distance_from_line(p)¶ Return (signed) distance of point p from line
-
intersection(other)¶ Return a
lib601.util.Pointwhereselfintersectsother. Returns None if there is no intersection. :param other: autil.Line
-
point_on_line(p, eps)¶ Return true if point p is within eps of the line
-
nx= None¶ x component of normal vector
-
ny= None¶ y component of normal vector
-
off= None¶ offset along normal
-
-
class
lib601.util.LineSeg(p1, p2)¶ Line segment in 2D space
Initialize with two points that are on the line. Store one of the points and the vector between them.
-
closest_point(p)¶ Return the point on the line that is closest to point p
-
dist_to_point(p)¶ Shortest distance between point p and this line
-
intersection(other)¶ Return a
lib601.util.Pointwhereselfintersectsother. ReturnsFalseif there is no intersection. :param other: autil.LineSeg
-
M= None¶ Vector from the stored point to the other point
-
p1= None¶ One point
-
p2= None¶ Other point
-
-
lib601.util.line_indices(xxx_todo_changeme, xxx_todo_changeme1)¶ 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.
-
lib601.util.line_indices_conservative(xxx_todo_changeme2, xxx_todo_changeme3)¶ 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.