Return the normal of each facet

        Returns
        ---------
        normals: (len(self.facets), 3) float
          A unit normal vector for each facet
171128
def facets_normal(self):
        
        if len(self.facets) == 0:
            return np.array([])

        area_faces = self.area_faces
        # sum the area of each group of faces represented by facets

        # the face index of the first face in each facet
        index = np.array([i[area_faces[i].argmax()]
                          for i in self.facets])
        # (n,3) float, unit normal vectors of facet plane
        normals = self.face_normals[index]
        # (n,3) float, points on facet plane
        origins = self.vertices[self.faces[:, 0][index]]
        # save origins in cache
        self._cache['facets_origin'] = origins

        return normals
553310
def indexes(self):
        
        if self._indexes is None:
            self._indexes = default_indexes(self._coords, self.dims)
        return Indexes(self._indexes)
131630
def facets_by_vertex(self):
        
        if self._fbv_out is None:
            output = qhalf('Fv', self.halfspaces, self.interior_point)
            facets = []
            for l in output[1:]:
                facets.append([int(i) for i in l.split()[1:]])
            self._fbv_out = facets
        return self._fbv_out
399161
def get_vectors(self, indices=None):
        ''''''
        H_ = self._deflated_solver.H
        (n_, n) = H_.shape
        coeffs = self.coeffs if indices is None else self.coeffs[:, indices]
        return numpy.c_[self._deflated_solver.V[:, :n],
                        self._deflated_solver.projection.U].dot(coeffs)
177961
def normalize(self):
        """"""
        vlength = self.length()

        #Make sure the length isn't 0
        if vlength > 0:
            self.x /= vlength
            self.y /= vlength
            self.z /= vlength
        else:
            return Vector3(0, 0, 0)
993781
public Vector4f normalize3(Vector4f dest) {
        float invLength = 1.0f / (float) Math.sqrt(x * x + y * y + z * z);
        dest.x = x * invLength;
        dest.y = y * invLength;
        dest.z = z * invLength;
        dest.w = w * invLength;
        return dest;
    }
1285
def triangulate_quads(quads):
    
    if len(quads) == 0:
        return quads
    quads = np.asanyarray(quads)
    faces = np.vstack((quads[:, [0, 1, 2]],
                       quads[:, [2, 3, 0]]))
    return faces
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)
1140499
def unit_vector(x):
    """"""
    y = np.array(x, dtype='float')
    return y/norm(y)
834096
def remove_nan_normals(self):
        
        points_of_interest = np.where(np.isfinite(np.linalg.norm(self._data, axis=0)))[0]
        self._data = self._data[:, points_of_interest]
1009087
def vec(self):
        
        return np.r_[self.fx, self.fy, self.cx, self.cy, self.skew, self.height, self.width]
424700
def faces_to_edges(faces, return_index=False):
    
    faces = np.asanyarray(faces)

    # each face has three edges
    edges = faces[:, [0, 1, 1, 2, 2, 0]].reshape((-1, 2))

    if return_index:
        # edges are in order of faces due to reshape
        face_index = np.tile(np.arange(len(faces)),
                             (3, 1)).T.reshape(-1)
        return edges, face_index
    return edges
1308162
def vertex_normals(self, values):
        
        if values is not None:
            values = np.asanyarray(values,
                                   order='C',
                                   dtype=np.float64)
            if values.shape == self.vertices.shape:
                self._cache['vertex_normals'] = values
478673
def get_standard_mesh(self, scaled=True):
        
        # TODO: allow this to take etheta and retreive a mesh at that true anomaly
        theta = 0.0
        protomesh = self._standard_meshes[theta] #.copy() # if theta in self._standard_meshes.keys() else self.mesh.copy()

        if scaled:
            # TODO: be careful about self._scale... we may want self._instantaneous_scale
            return mesh.ScaledProtoMesh.from_proto(protomesh, self._scale)
        else:
            return protomesh.copy()
997839
def normalize(data):
    
    data = data.astype(float)
    data -= data.mean()
    
    return data / data.std()
235492
def _get_normals(v):
    '''
    '''
    not_v = np.array([1, 0, 0])
    if np.all(np.abs(v) == not_v):
        not_v = np.array([0, 1, 0])
    n1 = np.cross(v, not_v)
    n1 /= norm(n1)
    n2 = np.cross(v, n1)
    return n1, n2
30636
function extractFaces(volume) {
  var result = []
  var normals = []

  //For each axis, extract all facets
  for(var d=0; d<3; ++d) {
    var u = (d+1) % 3
    var v = (d+2) % 3

    var normal = [0,0,0]

    var n = volume.shape[d]
    var m = volume.shape[u]
    var l = volume.shape[v]

    var x = ndarray(new Uint8Array(m * l), [m, l])
    
    for(var i=1; i<n-1; ++i) {
      var slice0, slice1, slice2
      if(d === 0) {
        slice0 = volume.pick(i-1)
        slice1 = volume.pick(i)
        slice2 = volume.pick(i+1)
      } else if(d === 1) {
        slice0 = volume.pick(-1, i-1).transpose(1,0)
        slice1 = volume.pick(-1, i).transpose(1,0)
        slice2 = volume.pick(-1, i+1).transpose(1,0)
      } else if(d === 2) {
        slice0 = volume.pick(-1, -1, i-1)
        slice1 = volume.pick(-1, -1, i)
        slice2 = volume.pick(-1, -1, i+1)
      }

      normal[d] = -1
      for(var s=0; s<m; ++s) {
        for(var t=0; t<l; ++t) {
          x.set(s, t, !!slice1.get(s,t) && !slice0.get(s,t))
        }
      }
      var f = contour(x, slice0)
      for(var j=0; j<f.length; ++j) {
        result.push(f[j].map(function(p) {
          var y = [i,i,i]
          y[u] = p[1]
          y[v] = p[0]
          return y
        }))
        normals.push(normal.slice())
      }

      normal[d] = 1
      for(var s=0; s<m; ++s) {
        for(var t=0; t<l; ++t) {
          x.set(s, t, !!slice1.get(s,t) && !slice2.get(s,t))
        }
      }
      var f = contour(x, slice2)
      for(var j=0; j<f.length; ++j) {
        f[j].reverse()
        result.push(f[j].map(function(p) {
          var y = [i+1,i+1,i+1]
          y[u] = p[1]
          y[v] = p[0]
          return y
        }))
        normals.push(normal.slice())
      }
    }
  }

  return [result, normals]
}