# Line

Provide functions for the creation and manipulation of Lines.

A Line data structure is simply a numpy.array with 2 vectors:

    start = numpy.array( [ -1.0, 0.0, 0.0 ] )
    end = numpy.array( [ 1.0, 0.0, 0.0 ] )
    line = numpy.array( [ start, end ] )

Both Lines and Line Segments are defined using the same data structure. The only difference is how the data is interpreted.

A line is defined by two points but extends infinitely.

A line segment only exists between two points. It does not extend forever.

The choice to interprete a line as a line or line segment is up to the function being called. Check the function signature of documentation to determine how a line will be interpreted.

pyrr.line.create_from_points(v1, v2, dtype=None)

  Creates a line from 2 vectors.

  The 2 vectors represent the start and end point of the line.

  Parameters:

    - v1 (numpy.array) – Start point.

    - v2 (numpy.array) – End point.

  Return type:

    numpy.array

  Returns:

    A line extending from v1 to v2.

pyrr.line.create_from_ray(ray)

  Converts a ray to a line.

  The line will extend from ‘ray origin -> ray origin + ray direction’.

  Parameters:

    ray (numpy.array) – The ray to convert.

  Return type:

    numpy.array

  Returns:

    A line beginning at the ray start and extending for 1 unit in the direction of the ray.

pyrr.line.create_zeros(dtype=None)

  Creates a line with the start and end at the origin.

  Return type:

    numpy.array

  Returns:

    A line with both start and end points at (0,0,0).

pyrr.line.end(line)

  Extracts the end point of the line.

  Parameters:

    line (numpy.array) – The line to extract the end from.

  Return type:

    numpy.array

  Returns:

    The ending point of the line.

class pyrr.line.index
  end = 1

    The index of the end vector within the line

  start = 0

    The index of the start vector within the line

pyrr.line.start(line)

  Extracts the start point of the line.

  Parameters:

    line (numpy.array) – The line to extract the start from.

  Return type:

    numpy.array

  Returns:

    The starting point of the line.