### .computeNormals()  Computes a new normal for each vertex from the average normal of the neighboring triangles. This means adjacent triangles must share vertices for the resulting normals to be smooth.
761387
function() {
    if (!this.normals) this.addVertexBuffer('normals', 'gl_Normal');
    for (var i = 0; i < this.vertices.length; i++) {
      this.normals[i] = new Vector();
    }
    for (var i = 0; i < this.triangles.length; i++) {
      var t = this.triangles[i];
      var a = Vector.fromArray(this.vertices[t[0]]);
      var b = Vector.fromArray(this.vertices[t[1]]);
      var c = Vector.fromArray(this.vertices[t[2]]);
      var normal = b.subtract(a).cross(c.subtract(a)).unit();
      this.normals[t[0]] = this.normals[t[0]].add(normal);
      this.normals[t[1]] = this.normals[t[1]].add(normal);
      this.normals[t[2]] = this.normals[t[2]].add(normal);
    }
    for (var i = 0; i < this.vertices.length; i++) {
      this.normals[i] = this.normals[i].unit().toArray();
    }
    this.compile();
    return this;
  }
1332125
def normalization(self):
        
        norm_r = self.normalization_range()        
        return quad(self, norm_r[0]*self._j_ref, norm_r[1]*self._j_ref)[0]
491915
public static void vNormalize(float[] v) {
        float d = (float) (1.0f / Math.sqrt(sqr(v[0]) + sqr(v[1]) + sqr(v[2])));
        if (d != 0) {
            v[0] *= d;
            v[1] *= d;
            v[2] *= d;
        }
    }
413527
def cosbetas(self):
        
        coords = self.coords_for_computations
        norms = self.normals_for_computations

        # TODO: ditch the list comprehension... I know I figured out how to do
        # this (ie along an axis) with np.dot somewhere else
        # cosbetas = np.array([np.dot(c,n) / (np.linalg.norm(c)*np.linalg.norm(n)) for c,n in zip(coords, norms)])

        cosbetas = libphoebe.scalproj_cosangle(
          np.ascontiguousarray(coords),
          np.ascontiguousarray(norms)
        )

        return ComputedColumn(self, cosbetas)
537914
@Override
	public void compute(double x, double y, Point2D_F64 out) {
		narrowToNorm.compute(x,y, norm);

		// Convert from 2D homogenous to 3D
		unit.set( norm.x , norm.y , 1.0);

		// Rotate then make it a unit vector
		GeometryMath_F64.mult(rotateWideToNarrow,unit,unit);
		double n = unit.norm();
		unit.x /= n;
		unit.y /= n;
		unit.z /= n;

		unitToWide.compute(unit.x,unit.y,unit.z,out);
	}
1105868
void dtNormalize2D(float[] v) {
        float d = (float) Math.sqrt(v[0] * v[0] + v[2] * v[2]);
        if (d == 0)
            return;
        d = 1.0f / d;
        v[0] *= d;
        v[2] *= d;
    }
829944
public Plane fromPointNormal (IVector3 pt, IVector3 normal) {
        return set(normal, -normal.dot(pt));
    }
972962
function computeNodeValues(nodes) {
    zrUtil.each(nodes, function (node) {
        var value1 = sum(node.outEdges, getEdgeValue);
        var value2 = sum(node.inEdges, getEdgeValue);
        var value = Math.max(value1, value2);
        node.setLayout({value: value}, true);
    });
}
821869
def _calculate_normals(rr, tris):
    """"""
    # ensure highest precision for our summation/vectorization "trick"
    rr = rr.astype(np.float64)
    # first, compute triangle normals
    r1 = rr[tris[:, 0], :]
    r2 = rr[tris[:, 1], :]
    r3 = rr[tris[:, 2], :]
    tri_nn = _fast_cross_3d((r2 - r1), (r3 - r1))

    #   Triangle normals and areas
    size = np.sqrt(np.sum(tri_nn * tri_nn, axis=1))
    size[size == 0] = 1.0  # prevent ugly divide-by-zero
    tri_nn /= size[:, np.newaxis]

    npts = len(rr)

    # the following code replaces this, but is faster (vectorized):
    #
    # for p, verts in enumerate(tris):
    #     nn[verts, :] += tri_nn[p, :]
    #
    nn = np.zeros((npts, 3))
    for verts in tris.T:  # note this only loops 3x (number of verts per tri)
        for idx in range(3):  # x, y, z
            nn[:, idx] += np.bincount(verts.astype(np.int32),
                                      tri_nn[:, idx], minlength=npts)
    size = np.sqrt(np.sum(nn * nn, axis=1))
    size[size == 0] = 1.0  # prevent ugly divide-by-zero
    nn /= size[:, np.newaxis]
    return nn
323968
public /*@ pure @*/ int getNormalizationBias() {
        if (nWords == 0) {
            throw new IllegalArgumentException("Zero value cannot be normalized");
        }
        int zeros = Integer.numberOfLeadingZeros(data[nWords - 1]);
        return (zeros < 4) ? 28 + zeros : zeros - 4;
    }
624267
def qnormal(mu, sigma, q, random_state):
    '''
    
    '''
    return np.round(normal(mu, sigma, random_state) / q) * q
314727
def TruncatedNormal(shape, dtype, seed):
    
    if seed:
        np.random.seed(seed)
    n = reduce(mul, shape)
    r = np.empty(n, dtype=dtype_map[dtype])
    idxs = np.ones(n, dtype=np.bool)
    while n:
        r[idxs] = np.random.normal(size=n)
        idxs = np.abs(r) > 2
        n = np.sum(idxs)
    return r.reshape(shape),
39414
@Override
	public void compute(int x, int y, Point2D_F64 out ) {
		// grab precomputed normalized image coordinate at canonical location
		Point3D_F64 v = vectors[y*outWidth+x];
		// move to requested orientation
		GeometryMath_F64.mult(R,v,n); // TODO make faster by not using an array based matrix

		// compute pixel coordinate
		tools.normToEquiFV(n.x,n.y,n.z,out);
	}
138937
def normalize(v):
    ''''''
    if 0 == np.linalg.norm(v):
        return v
    return v / np.linalg.norm(v)
872784
private void normalize(final Element vertex) {
        double nx = vertex.getDouble("nx");
        double ny = vertex.getDouble("ny");
        double nz = vertex.getDouble("nz");
        double n = Math.sqrt(nx * nx + ny * ny + nz * nz);
        if (n < EPSILON) {
            vertex.setDouble("nx", 0);
            vertex.setDouble("ny", 0);
            vertex.setDouble("nz", 0);
        }
        vertex.setDouble("nx", nx / n);
        vertex.setDouble("ny", ny / n);
        vertex.setDouble("nz", nz / n);
    }
950702
public Matrix3d normal(Matrix3d dest) {
        if ((properties & PROPERTY_ORTHONORMAL) != 0)
            return normalOrthonormal(dest);
        return normalGeneric(dest);
    }
551274
function getNormalizeRotations(start, end) {
  // normalize both rotations
  var normStart = normalizeRotation(start)
  var normEnd = normalizeRotation(end)
  // find the shortest arc for each rotation
  Object.keys(start).forEach(function(axis) {
    if (normEnd[axis] - normStart[axis] > 180) normEnd[axis] -= 360
  })
  return { start: normStart, end: normEnd }
}