# Lines¶

A collection of classes representing lines and linear objects.

Yes, there are two implementations of line segments, `LineSegment`

and `Segment`

; these will be merged in future.

class`wasabi.geom.lines.`

`Line`

(direction,distance)¶Two-dimensional vector (directed) line implementation.

Lines are defined in terms of a perpendicular vector and the distance from the origin.

The representation of the line allows it to partition space into an ‘outside’ and an inside.

`altitude`

(point)¶Return the (signed) distance to a point.

Parameters:

- point : Vector
The point to measure the distance to.

`distance_to`

(point)¶Return the (signed) distance to a point.

Parameters:

- point : Vector
The point to measure the distance to.

classmethod`from_points`

(first,second)¶Create a Line object from two (distinct) points.

Parameters:

- first, second : Vector
The vectors used to construct the line.

`is_inside`

(point)¶Determine if the given point is left of the line.

Parameters:

- point : Vector
The point to locate.

`is_on_left`

(point)¶Determine if the given point is left of the line.

Parameters:

- point : Vector
The point to locate.

`is_on_right`

(point)¶Determine if the given point is right of the line.

Parameters:

- point : Vector
The point to locate.

`mirror`

(point)¶Reflect a point in the line.

Parameters:

- point : Vector
The point to reflect in the line.

`offset`

¶The projection of the origin onto the line.

`parallel`

(point)¶Return a line parallel to this one through the given point.

Parameters:

- point : Vector
The point through which to trace a line.

`perpendicular`

(point)¶Return a line perpendicular to this one through the given point. The orientation of the line is consistent with

`Vector.perpendicular`

.

Parameters:

- point : Vector
The point through which to trace a line.

`project`

(point)¶Compute the projection of a point onto the line.

Parameters:

- point : Vector
The point to project onto the line.

`reflect`

(point)¶Reflect a point in the line.

Parameters:

- point : Vector
The point to reflect in the line.

class`wasabi.geom.lines.`

`LineSegment`

(line,min_dist,max_dist)¶Two-dimensional vector (directed) line segment implementation.

Line segments are defined in terms of a line and the minimum and maximum distances from the base of the altitude to that line from the origin. The distances are signed, strictly they are multiples of a vector parallel to the line.

`distance_to`

(point)¶Return the shortest distance to a given point.

Parameters:

- point : Vector
The point to measure the distance to.

`end`

¶One endpoint of the line segment (corresponding to ‘max_dist’).

classmethod`from_points`

(first,second)¶Create a LineSegment object from two (distinct) points.

Parameters:

- first, second : Vector
The vectors used to construct the line.

`length`

¶The length of the line segment.

`mid`

¶The midpoint of the line segment.

`project`

(point)¶Compute the projection of a point onto the line segment.

Parameters:

- point : Vector
The point to minimise the distance to.

`start`

¶One endpoint of the line segment (corresponding to ‘min_dist’).

class`wasabi.geom.lines.`

`Segment`

(p1,p2)¶A 2D line segment between two points p1 and p2.

A segment has an implied direction for some operations - p1 is the start and p2 is the end.

`intersects`

(other)¶Determine if this segment intersects a convex polygon.

Returns None if there is no intersection, or a scalar which is how far along the segment the intersection starts. If the scalar is positive then the intersection is partway from p1 to p2. If the scalar is negative then p1 is inside the shape, by the corresponding distance (in the direction of the object)

`length`

¶The length of the segment.

`scale_to`

(dist)¶Scale the segment to be of length dist.

This returns a new segment of length dist that shares p1 and the direction vector.

`truncate`

(dist)¶Scale the segment to be of length dist.

This returns a new segment of length dist that shares p1 and the direction vector.

class`wasabi.geom.lines.`

`Projection`

(min,max)¶A wrapper for the extent of a projection onto a line.

class`wasabi.geom.lines.`

`PolyLine`

(vertices=[])¶A set of points connected into line