make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)
336635
def arrow_head(document, x0, y0, x1, y1, arrowshape):
	""
	import math
	 
	dx = x1 - x0
	dy = y1 - y0

	poly = document.createElement('polygon')
	
	d = math.sqrt(dx*dx + dy*dy)
	if d == 0.0: # XXX: equal, no "close enough"
		return poly

	try:
		d1, d2, d3 = list(map(float, arrowshape))
	except ValueError:
		d1, d2, d3 = map(float, arrowshape.split())
	P0 = (x0, y0)
	P1 = (x1, y1)
	
	xa, ya = lerp(P1, P0, d1/d)
	xb, yb = lerp(P1, P0, d2/d)

	t = d3/d
	xc, yc = dx*t, dy*t

	points = [
		x1, y1,
		xb - yc, yb + xc,
		xa, ya,
		xb + yc, yb - xc,
	]
	poly.setAttribute('points', ' '.join(map(str, points)))
	return poly
153893
function diagonal(s, d) {
    if (s.dy == undefined) {
        s.dy = 0;
    }
    if (d.dy == undefined) {
        d.dy = 0;
    }
    let path = `M ${s.x} ${(s.y + s.dy)}
          C ${(s.x + d.x) / 2} ${(s.y + s.dy)},
            ${(s.x + d.x) / 2} ${(d.y + d.dy)},
            ${d.x} ${(d.y + d.dy)}`;
    return path;
}
278387
def matrix2lha(M):
    """"""
    l = []
    ind = np.indices(M.shape).reshape(M.ndim, M.size).T
    for i in ind:
        l.append([j+1 for j in i] + [M[tuple(i)]])
    return l
279208
def point(self, x, y):
        """"""
        shapeType = POINT
        pointShape = Shape(shapeType)
        pointShape.points.append([x, y])
        self.shape(pointShape)
78017
def polyline(self, vertexes, attr=0, row=None):
        ''
        self.polylines.append((vertexes, attr, row))
1073515
def flatten4d3d(x):
  """"""
  xshape = shape_list(x)
  result = tf.reshape(x, [xshape[0], xshape[1] * xshape[2], xshape[3]])
  return result
1339317
function tweenLoading(b) {
            let i;

            b.innerRadius = 0;
            i = d3Interpolate.interpolate({ startAngle: 0, endAngle: 0}, b);

            return function(t) { return shape(i(t)); };
        }
827960
function Tri() {
  Triangle.apply( this, arguments );
  this.target = {vec: null, t: 0};
  this.vertices = ["p0","p1","p2"];
  this.colorId = 1 + (colorToggle % 3);
}
1068598
def color_reducer(c1, c2):
    """"""
    return tuple(v1 + v2 for v1, v2 in itertools.izip(c1, c2))
758068
def right(X, i):
    """"""
    if i > X.d-1:
        return np.ones([1, 1])
    answ = np.ones([1, 1])
    cores = tt.tensor.to_list(X)
    for dim in xrange(X.d-1, i-1, -1):
        answ = np.tensordot(cores[dim], answ, 1)
    answ = reshape(answ, (X.r[i], -1))
    return answ.T
1063345
def tuple_as_vec(xyzw):
        
        vec = Vector4()
        vec[0] = xyzw[0]
        vec[1] = xyzw[1]
        vec[2] = xyzw[2]
        vec[3] = xyzw[3]
        return vec
189750
def dot(v1, v2):
    '''
    '''
    x1, y1, z1 = v1
    x2, y2, z2 = v2
    return x1 * x2 + y1 * y2 + z1 * z2
1075964
def _getshapes_2d(center, max_radius, shape):
    """"""
    index_mean = shape * center
    index_radius = max_radius / 2.0 * np.array(shape)

    # Avoid negative indices
    min_idx = np.maximum(np.floor(index_mean - index_radius), 0).astype(int)
    max_idx = np.ceil(index_mean + index_radius).astype(int)
    idx = [slice(minx, maxx) for minx, maxx in zip(min_idx, max_idx)]
    shapes = [(idx[0], slice(None)),
              (slice(None), idx[1])]
    return tuple(idx), tuple(shapes)
1048977
def cart2spher(x, y, z):
    """"""
    hxy = np.hypot(x, y)
    r = np.hypot(hxy, z)
    theta = np.arctan2(z, hxy)
    phi = np.arctan2(y, x)
    return r, theta, phi
436162
function make( v1, v2, v3 ) {

		var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
		face.centroid.add( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
		that.faces.push( face );

		var azi = azimuth( face.centroid );

		that.faceVertexUvs[ 0 ].push( [
			correctUV( v1.uv, v1, azi ),
			correctUV( v2.uv, v2, azi ),
			correctUV( v3.uv, v3, azi )
		] );

	}
860930
function verticesProjection(vertices, axis) {
          var _vertices$map = vertices.map(function (v) {
            return axis.dot(new _spriteMath.Vector(v));
          }),
              _vertices$map2 = (0, _slicedToArray2.default)(_vertices$map, 4),
              p1 = _vertices$map2[0],
              p2 = _vertices$map2[1],
              p3 = _vertices$map2[2],
              p4 = _vertices$map2[3];

          return [Math.min(p1, p2, p3, p4), Math.max(p1, p2, p3, p4)];
        }
708579
def translate_x(self, d):
        
        mat = numpy.array([
            [1, 0, 0, 0],
            [0, 1, 0, 0],
            [0, 0, 1, 0],
            [d, 0, 0, 1]
        ])
        self.vectors = self.vectors.dot(mat)
        return self