Projection onto line in x
555525
def prox_xline(x, step):
    """"""
    if not np.isscalar(x):
        x= x[0]
    if x > 0.5:
        return np.array([0.5])
    else:
        return np.array([x])
6926
def move(self, x, y):
        
        if self.brush_on:
            for lx, ly in line(self.pos_x, self.pos_y, x, y):
                self.set(lx, ly)

        self.pos_x = x
        self.pos_y = y
155643
def mapFromChart( self, x, y ):
        
        grid      = self.gridRect()
        hruler    = self.horizontalRuler()
        vruler    = self.verticalRuler()
        
        xperc     = hruler.percentAt(x)
        yperc     = vruler.percentAt(y)
        
        xoffset   = grid.width() * xperc
        yoffset   = grid.height() * yperc
        
        xpos      = grid.left() + xoffset
        ypos      = grid.bottom() - yoffset
        
        return QPointF(xpos, ypos)
173359
public void lineTo(double x, double y, double z) {
		ensureSlots(true, 3);
		this.types[this.numTypesProperty.get()] = PathElementType.LINE_TO;
		this.numTypesProperty.set(this.numTypesProperty.get()+1);

		this.coordsProperty[this.numCoordsProperty.get()].set(x);
		this.numCoordsProperty.set(this.numCoordsProperty.get()+1);

		this.coordsProperty[this.numCoordsProperty.get()].set(y);
		this.numCoordsProperty.set(this.numCoordsProperty.get()+1);

		this.coordsProperty[this.numCoordsProperty.get()].set(z);
		this.numCoordsProperty.set(this.numCoordsProperty.get()+1);

		this.isEmptyProperty = null;
		this.graphicalBounds = null;
		this.logicalBounds = null;
	}
805651
def _projection(self, a, b, c):
        
        ab = b - a
        ac = c - a
        return a + ((ab*ac).sum() / (ac*ac).sum()) * ac
461100
def rectangle(self, x0, y0, x1, y1):
        """"""
        x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
        self.polyline([[x0, y0], [x1, y0], [x1, y1], [x0, y1], [x0, y0]])
639524
function translateLine (options, line) {
  const { x, y } = Object.assign({ x: 0, y: 0 }, options || {})
  let segments = line.segments
  let segment = null
  let point = null
  for (let i = 0, il = segments.length; i < il; i++) {
    segment = segments[i]
    for (let j = 0, jl = segment.length; j < jl; j++) {
      point = segment[j]
      segment[j] = [point[0] + x, point[1] + y]
    }
  }
  return line
}
468123
def line(self, lines):
        """"""
        shapeType = POLYLINE
        self._shapeparts(parts=lines, shapeType=shapeType)
1214382
def _line_shift(x:Tensor, mask:bool=False):
    ""
    bs,nh,n,p = x.size()
    x_pad = torch.cat([x.new_zeros(bs,nh,n,1), x], dim=3)
    x_shift = x_pad.view(bs,nh,p + 1,n)[:,:,1:].view_as(x)
    if mask: x_shift.mul_(torch.tril(x.new_ones(n,p), p-n)[None,None,])
    return x_shift
1114508
function scanLine(x0, x1, y) {
      var z = c0.zoom,
          z0 = 2 - tileLevel,
          z1 = 4 + tileLevel;

      for (var x = x0; x < x1; x++) {
        var t = cache.load({column: x, row: y, zoom: z}, projection);
        if (!t.ready && !(t.key in newLocks)) {
          t.proxyRefs = {};
          var c, full, proxy;

          // downsample high-resolution tiles
          for (var dz = 1; dz <= z0; dz++) {
            full = true;
            for (var dy = 0, k = 1 << dz; dy <= k; dy++) {
              for (var dx = 0; dx <= k; dx++) {
                proxy = cache.peek(c = {
                  column: (x << dz) + dx,
                  row: (y << dz) + dy,
                  zoom: z + dz
                });
                if (proxy && proxy.ready) {
                  newLocks[proxy.key] = cache.load(c);
                  proxy.proxyCount++;
                  t.proxyRefs[proxy.key] = proxy;
                } else {
                  full = false;
                }
              }
            }
            if (full) break;
          }

          // upsample low-resolution tiles
          if (!full) {
            for (var dz = 1; dz <= z1; dz++) {
              proxy = cache.peek(c = {
                column: x >> dz,
                row: y >> dz,
                zoom: z - dz
              });
              if (proxy && proxy.ready) {
                newLocks[proxy.key] = cache.load(c);
                proxy.proxyCount++;
                t.proxyRefs[proxy.key] = proxy;
                break;
              }
            }
          }
        }
        newLocks[t.key] = t;
      }
    }
790329
def _x_axis(self, draw_axes=True):
        """"""
        if not self._x_labels or not self.show_x_labels:
            return

        axis = self.svg.node(
            self.nodes['plot'],
            class_="axis x web%s" %
            (' always_show' if self.show_x_guides else '')
        )
        format_ = lambda x: '%f %f' % x
        center = self.view((0, 0))
        r = self._rmax

        # Can't simply determine truncation
        truncation = self.truncate_label or 25

        for label, theta in self._x_labels:
            major = label in self._x_labels_major
            if not (self.show_minor_x_labels or major):
                continue
            guides = self.svg.node(axis, class_='guides')
            end = self.view((r, theta))

            self.svg.node(
                guides,
                'path',
                d='M%s L%s' % (format_(center), format_(end)),
                class_='%s%sline' %
                ('axis ' if label == "0" else '', 'major ' if major else '')
            )

            r_txt = (1 - self._box.__class__.margin) * self._box.ymax
            pos_text = self.view((r_txt, theta))
            text = self.svg.node(
                guides,
                'text',
                x=pos_text[0],
                y=pos_text[1],
                class_='major' if major else ''
            )
            text.text = truncate(label, truncation)
            if text.text != label:
                self.svg.node(guides, 'title').text = label
            else:
                self.svg.node(
                    guides,
                    'title',
                ).text = self._x_format(theta)

            angle = -theta + pi / 2
            if cos(angle) < 0:
                angle -= pi
            text.attrib['transform'] = 'rotate(%f %s)' % (
                self.x_label_rotation or deg(angle), format_(pos_text)
            )
282180
function finiteLinesIntersect(x1, y1, x2, y2, x3, y3, x4, y4, infiniteLines) {
  var dx13 = x1 - x3;
  var dx21 = x2 - x1;
  var dx43 = x4 - x3;
  var dy13 = y1 - y3;
  var dy21 = y2 - y1;
  var dy43 = y4 - y3;
  var ua_t = dx43 * dy13 - dy43 * dx13;
  var ub_t = dx21 * dy13 - dy21 * dx13;
  var u_b = dy43 * dx21 - dx43 * dy21;

  if (u_b !== 0) {
    var ua = ua_t / u_b;
    var ub = ub_t / u_b;
    var flptThreshold = 0.001;

    var _min = 0 - flptThreshold;

    var _max = 1 + flptThreshold;

    if (_min <= ua && ua <= _max && _min <= ub && ub <= _max) {
      return [x1 + ua * dx21, y1 + ua * dy21];
    } else {
      if (!infiniteLines) {
        return [];
      } else {
        return [x1 + ua * dx21, y1 + ua * dy21];
      }
    }
  } else {
    if (ua_t === 0 || ub_t === 0) {
      // Parallel, coincident lines. Check if overlap
      // Check endpoint of second line
      if (midOfThree(x1, x2, x4) === x4) {
        return [x4, y4];
      } // Check start point of second line


      if (midOfThree(x1, x2, x3) === x3) {
        return [x3, y3];
      } // Endpoint of first line


      if (midOfThree(x3, x4, x2) === x2) {
        return [x2, y2];
      }

      return [];
    } else {
      // Parallel, non-coincident
      return [];
    }
  }
}
677362
def get_projection(self, axis):
        
        scale = axis.dot(self) / axis.dot(axis)
        return axis * scale
1136354
def _x_axis(self, draw_axes=True):
        """"""
        axis = self.svg.node(self.nodes['plot'], class_="axis y gauge")
        x, y = self.view((0, 0))
        self.svg.node(axis, 'circle', cx=x, cy=y, r=4)
1103894
public void lineTo(double x, double y, double z) {
		ensureSlots(true, 3);
		this.types[this.numTypes++] = PathElementType.LINE_TO;
		this.coords[this.numCoords++] = x;
		this.coords[this.numCoords++] = y;
		this.coords[this.numCoords++] = z;
		this.isEmpty = null;
		this.graphicalBounds = null;
		this.logicalBounds = null;
	}
614103
def projection(self, axis):
        """"""
        axis = self.get_axis_number(axis)
        projected_hist = np.sum(self.histogram, axis=self.other_axes(axis))
        return Hist1d.from_histogram(projected_hist, bin_edges=self.bin_edges[axis])
690788
def formatPoint(point, affine):
    
    # Affine coordinates: (x,y)        
    if affine:
        fmt = "\tx:{}\n\ty:{}"
        coords = [point.x, point.y]

    # Projected coordinates: (x,y,z)
    else:
        fmt = "\tx:{}\n\ty:{}\n\tz:{}"
        coords = [point.x, point.y, point.z]

    coordText = map(hexString, coords)
    return fmt.format(*coordText)