planar.Line – Infinite Lines — Planar v0.4 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Planar v0.4 documentation »

# `planar.Line` – Infinite Lines

class `planar.` `Line`(point, direction)

  Infinite directed line.

  Parameters: | point (Vec2) – A point on the line. direction (Vec2) – Direction of the line as a vector, must not be null. Does not need to be unit-length.

  `almost_equals`(other)

    Return True if this line is approximately equal to another line, within precision limits.

  `contains_point`(point)

    Return True if the specified point is on the line.

  `distance_to`(point)

    Return the signed distance from the line to the specified point. The sign indicates which half-plane contains the point. If the distance is negative, the point is in the “left” half plane with respect to the line, if it is positive, the point is in the “right” half plane.

    Parameters: | point (Vec2) – The point to measure the distance to.

  classmethod `from_normal`(normal, offset)

    Create a line given a normal vector perpendicular to it, at the specified distance from the origin.

    Parameters: | normal (Vec2) – A non-null vector perpendicular to the line. Does not need to be unit-length. offset (float) – The signed distance from the line to the origin.

  classmethod `from_points`(points)

    Create a line from two or more collinear points. The direction of the line is derived from the first two distinct points, the order of the remaining points is unimportant.

    Parameters: | points – Iterable of at least 2 distinct points.

  `parallel`(point)

    Return a line parallel to this one that passes through the given point.

    Parameters: | point (Vec2) – A point on the parallel line.

  `perpendicular`(point)

    Return a line perpendicular to this one that passes through the given point. The orientation of this line is consistent with `planar.Vec2.perpendicular()`.

    Parameters: | point (Vec2) – A point on the perpendicular line.

  `point_left`(point)

    Return True if the specified point is in the half plane to the left of the line.

  `point_right`(point)

    Return True if the specified point is in the half plane to the right of the line.

  `project`(point)

    Compute the projection of a point onto the line. This is the closest point on the line to the specified point.

    Parameters: | point (Vec2) – The point to project.

  `reflect`(point)

    Reflect a point across the line.

    Parameters: | point (Vec2) – The point to reflect.

  `direction`

    Direction of the line as a unit vector. You may set this attribute to any non-null vector, however it will be normalized to unit-length.

  `normal`

    Normal unit vector perpendicular to the line. You may set this attribute to any non-null vector, however it will be normalized to unit-length. Modifying this will also affect the direction vector accordingly.

  `offset`

    The signed distance from the origin to the line.

  `points`

    Return two distinct points along the line, such that `line.from_points(line.points)` will construct an equivalent line.

### Navigation

- index
- modules |
- next |
- previous |
- Planar v0.4 documentation »