Returns the line segment as a vector equal to its end point relative to its endpoint
424789
function() {
                var A = this.start.elements, B = this.end.elements;
                return vector.create([B[0] - A[0], B[1] - A[1], B[2] - A[2]]);
              }
100597
function(obj) {
                if (obj.normal) {
                  // obj is a plane
                  var V = this.line.intersectionWith(obj);
                  if (V === null) { return null; }
                  return this.pointClosestTo(V);
                } else {
                  // obj is a line (segment) or point
                  var P = this.line.pointClosestTo(obj);
                  if (P === null) { return null; }
                  if (this.contains(P)) { return P; }
                  return (this.line.positionOf(P) < 0 ? this.start : this.end).dup();
                }
              }
618009
public Vector getMidpoint(Vector other) {
        double x = (this.x + other.x) / 2;
        double y = (this.y + other.y) / 2;
        double z = (this.z + other.z) / 2;
        return new Vector(x, y, z);
    }
970185
public static Point nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY) {
        double xDiff = endX - startX;
        double yDiff = endY - startY;
        double length2 = xDiff * xDiff + yDiff * yDiff;
        if (length2 == 0) return new Point(startX, startY);
        double t = ((pointX - startX) * (endX - startX) + (pointY - startY) * (endY - startY)) / length2;
        if (t < 0) return new Point(startX, startY);
        if (t > 1) return new Point(endX, endY);
        return new Point(startX + t * (endX - startX), startY + t * (endY - startY));
    }
937889
def distancePointToLine(point, line_start, line_end, perpendicular=False):
    """"""
    p1 = line_start
    p2 = line_end
    offset = lineOffsetWithMinimumDistanceToPoint(
        point, line_start, line_end, perpendicular)
    if offset == INVALID_DISTANCE:
        return INVALID_DISTANCE
    if offset == 0:
        return distance(point, p1)
    u = offset / distance(line_start, line_end)
    intersection = (p1[0] + u * (p2[0] - p1[0]), p1[1] + u * (p2[1] - p1[1]))
    return distance(point, intersection)
107834
def find_segment(self, ea):
        
        for seg in self.seglist:
            if seg.startea <= ea < seg.endea:
                return seg
342247
function(length, opt) {

            var segments = this.segments;
            var numSegments = segments.length;
            if (numSegments === 0) return null; // if segments is an empty array

            if (length === 0) return this.start.clone();

            var fromStart = true;
            if (length < 0) {
                fromStart = false; // negative lengths mean start calculation from end point
                length = -length; // absolute value
            }

            opt = opt || {};
            var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
            var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;
            // not using localOpt

            var lastVisibleSegment;
            var l = 0; // length so far
            for (var i = (fromStart ? 0 : (numSegments - 1)); (fromStart ? (i < numSegments) : (i >= 0)); (fromStart ? (i++) : (i--))) {

                var segment = segments[i];
                var subdivisions = segmentSubdivisions[i];
                var d = segment.length({ precision: precision, subdivisions: subdivisions });

                if (segment.isVisible) {
                    if (length <= (l + d)) {
                        return segment.pointAtLength(((fromStart ? 1 : -1) * (length - l)), { precision: precision, subdivisions: subdivisions });
                    }

                    lastVisibleSegment = segment;
                }

                l += d;
            }

            // if length requested is higher than the length of the path, return last visible segment endpoint
            if (lastVisibleSegment) return (fromStart ? lastVisibleSegment.end : lastVisibleSegment.start);

            // if no visible segment, return last segment end point (no matter if fromStart or no)
            var lastSegment = segments[numSegments - 1];
            return lastSegment.end.clone();
        }
437661
def EndVector(self, vectorNumElems):
        """"""

        self.assertNested()
        ## @cond FLATBUFFERS_INTERNAL
        self.nested = False
        ## @endcond
        # we already made space for this, so write without PrependUint32
        self.PlaceUOffsetT(vectorNumElems)
        return self.Offset()
944943
public void getClosestPoint(Vector2f point, Vector2f result) {
		loc.set(point);
		loc.sub(start);

		float projDistance = vec.dot(loc);

		projDistance /= vec.lengthSquared();

		if (projDistance < 0) {
			result.set(start);
			return;
		}
		if (projDistance > 1) {
			result.set(end);
			return;
		}

		result.x = start.getX() + projDistance * vec.getX();
		result.y = start.getY() + projDistance * vec.getY();
	}
1320366
def segments (self):
    """"""
    for n in xrange(len(self.vertices) - 1):
      yield Line(self.vertices[n], self.vertices[n + 1])

    yield Line(self.vertices[-1], self.vertices[0])
1103616
def lineSeqmentsDoIntersect(line1, line2):
    
    (x1, y1), (x2, y2) = line1
    (u1, v1), (u2, v2) = line2
    (a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2)
    e, f = u1 - x1, v1 - y1
    denom = float(a * d - b * c)
    if _near(denom, 0):
        # parallel
        return False
    else:
        t = old_div((e * d - b * f), denom)
        s = old_div((a * f - e * c), denom)
        # When 0<=t<=1 and 0<=s<=1 the point of intersection occurs within the
        # line segments
        return 0 <= t <= 1 and 0 <= s <= 1
926913
function lineRectangleIntersection(line, rect) {
  const intersections = [];

  Object.keys(rect).forEach(function(side) {
    const segment = rect[side];
    const intersection = line.intersectLine(segment);

    if (intersection) {
      intersections.push(intersection);
    }
  });

  return intersections;
}
835445
def get_line_segments(line):
    
    line = line.strip()

    tokens = tk.generate_tokens(io.StringIO(line).readline)

    equality_signs = [-1]
    comment_tuple = None, ""
    for i, t in enumerate(tokens):
        if t.type == tk.COMMENT:
            # store string_index and comment string
            comment_tuple = t.start[1], t.string
        if t.type == tk.OP and t.string == "=":
            equality_signs.append(t.start[1])

    if len(equality_signs) > 1:
        # we have at least one assignment
        lhs = line[equality_signs[-2]+1:equality_signs[-1]].strip()
        equality_signs.pop(0)
    else:
        lhs = None

    rhs_start_idx = equality_signs[-1] + 1

    # from the last `=` until the beginning of the comment
    rhs = line[rhs_start_idx:comment_tuple[0]].strip()
    if rhs == "":
        rhs = None
    comment = comment_tuple[1].strip()

    return lhs, rhs, comment
1150752
def get_midpoint(file, file_start, file_end):
    
    filehandle = open(file, 'r')
    mid_point = (file_start + file_end) / 2
    assert mid_point >= file_start
    filehandle.seek(mid_point)
    line = filehandle.readline()
    assert len(line) >= 1
    if len(line) + mid_point < file_end:
        return mid_point + len(line) - 1
    filehandle.seek(file_start)
    line = filehandle.readline()
    assert len(line) >= 1
    assert len(line) + file_start <= file_end
    return len(line) + file_start - 1
821900
def get_r(self):
        """"""

        start_point, end_point = self._get_right_line_coordinates()
        width = self._get_right_line_width()
        color = self._get_right_line_color()

        return CellBorder(start_point, end_point, width, color)
1042029
def get_real_end_line(token):
    
    end_line = token.end_mark.line + 1

    if not isinstance(token, yaml.ScalarToken):
        return end_line

    pos = token.end_mark.pointer - 1
    while (pos >= token.start_mark.pointer - 1 and
           token.end_mark.buffer[pos] in string.whitespace):
        if token.end_mark.buffer[pos] == '\n':
            end_line -= 1
        pos -= 1
    return end_line
357267
function _getSegmentPoints(segment) {
  var points = [];
  switch (segment[0]) {
    case 'M':
      points.push([segment[1], segment[2]]);
      break;
    case 'L':
      points.push([segment[1], segment[2]]);
      break;
    case 'A':
      points.push([segment[6], segment[7]]);
      break;
    case 'Q':
      points.push([segment[3], segment[4]]);
      points.push([segment[1], segment[2]]);
      break;
    case 'T':
      points.push([segment[1], segment[2]]);
      break;
    case 'C':
      points.push([segment[5], segment[6]]);
      points.push([segment[1], segment[2]]);
      points.push([segment[3], segment[4]]);
      break;
    case 'S':
      points.push([segment[3], segment[4]]);
      points.push([segment[1], segment[2]]);
      break;
    case 'H':
      points.push([segment[1], segment[1]]);
      break;
    case 'V':
      points.push([segment[1], segment[1]]);
      break;
    default:

  }
  return points;
}