Bitbybit Docs
    Preparing search index...

    Class Line

    Straight lines between two points, held as plain objects of the form { start, end }, and the segment form [start, end] of the same thing. The methods here build lines, measure and transform them, convert between the two forms, place points along them and find where two lines cross. Lengths are in model units.

    Index

    Constructors

    convert

    • Turns a line object into its segment form, the pair [start, end].

      Example: { start: [0,0,0], end: [10,5,0] } -> [[0,0,0], [10,5,0]]

      Parameters

      Returns Segment3

      The segment

    • Turns each line object into its segment form, the pair [start, end].

      Example: three lines -> three segments, in the same order

      Parameters

      Returns Segment3[]

      One segment per line

    • Turns a segment, the pair [start, end], into a line object.

      Example: [[0,0,0], [10,5,0]] -> { start: [0,0,0], end: [10,5,0] }

      Parameters

      Returns Line3

      The line

    • Turns each segment, a pair [start, end], into a line object.

      Example: three segments -> three lines, in the same order

      Parameters

      Returns Line3[]

      One line per segment

    create

    • Builds a line object from a start and an end point.

      Example: start [0,0,0], end [10,5,0] -> { start: [0,0,0], end: [10,5,0] }

      Parameters

      Returns Line3

      The line object

      const line = bitbybit.line.create({ start: [0, 0, 0], end: [10, 5, 0] });
      
    • Builds a segment, the pair-of-points form of a line, from a start and an end point.

      Example: start [0,0,0], end [10,5,0] -> [[0,0,0], [10,5,0]]

      Parameters

      Returns Segment3

      The segment as [start, end]

      const segment = bitbybit.line.createSegment({ start: [0, 0, 0], end: [10, 5, 0] });
      
    • Joins each point to the next with a line, so a list of points becomes a chain of lines.

      Example: [[0,0,0], [5,0,0], [5,5,0]] -> two lines, [0,0,0] to [5,0,0] and [5,0,0] to [5,5,0]

      Parameters

      Returns Line3[]

      One line per pair of neighboring points

      const chain = bitbybit.line.linesBetweenPoints({ points: [[0, 0, 0], [5, 0, 0], [5, 5, 0]] });
      
    • Pairs each start point with the end point at the same position and joins them with a line.

      A pair whose two points coincide makes no line and is left out. Example: starts [[0,0,0], [5,0,0]] and ends [[0,5,0], [5,5,0]] -> two lines

      Parameters

      Returns Line3[]

      One line per pair, skipping pairs of length 0

      const rungs = bitbybit.line.linesBetweenStartAndEndPoints({
      startPoints: [[0, 0, 0], [5, 0, 0]],
      endPoints: [[0, 5, 0], [5, 5, 0]],
      });

    get

    • Measures the straight distance from the start of a line to its end.

      Example: { start: [0,0,0], end: [3,4,0] } -> 5

      Parameters

      Returns number

      The length in model units

    • Measures how far a point lies from a line, to the nearest point between its start and end.

      A point beside the line is measured square to it, and one past either end to that end. A line whose ends meet is measured to that one point.

      Parameters

      Returns number

      Distance in model units

      const beside = bitbybit.line.distanceToPoint({ line: { start: [0, 0, 0], end: [10, 0, 0] }, point: [4, 3, 0] });
      const pastTheEnd = bitbybit.line.distanceToPoint({ line: { start: [0, 0, 0], end: [10, 0, 0] }, point: [13, 4, 0] });
    • Finds the point a fraction of the way along a line: 0 gives the start, 1 the end, 0.5 the middle.

      A fraction outside 0 to 1 continues past the ends. Example: { start: [0,0,0], end: [10,0,0] } at 0.5 -> [5,0,0]

      Parameters

      Returns Bit.Inputs.Base.Point3

      The point on the line