igl logo

libigl

Automatically generated documentation for libigl.

Headers:

.h fileFunctions
active_set.h
  enum SolverStatus
  struct active_set_params;

// Known Bugs: rows of [Aeq;Aieq] **must** be linearly independent. Should be
// using QR decomposition otherwise:
// http://www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
//
// ACTIVE_SET Minimize quadratic energy Z'*A*Z + Z'*B + C with constraints
// that Z(known) = Y, optionally also subject to the constraints Aeq*Z = Beq,
// and further optionally subject to the linear inequality constraints that
// Aieq*Z <= Bieq and constant inequality constraints lx <= x <= ux
//
// Templates:
// Inputs:
// A n by n matrix of quadratic coefficients
// B n by 1 column of linear coefficients
// known list of indices to known rows in Z
// Y list of fixed values corresponding to known rows in Z
// Aeq meq by n list of linear equality constraint coefficients
// Beq meq by 1 list of linear equality constraint constant values
// Aieq mieq by n list of linear equality constraint coefficients
// Bieq mieq by 1 list of linear equality constraint constant values
// lx n by 1 list of lower bounds [] implies -Inf
// ux n by 1 list of upper bounds [] implies Inf
// params struct of additional parameters (see below)
// Outputs:
// Z n by 1 list of solution values
// Returns true on success, false on error
//
// Benchmark: For a harmonic solve on a mesh with 325K facets, matlab 2.2
// secs, igl/min_quad_with_fixed.h 7.1 secs
//
  template <
    typename AT, 
    typename DerivedB,
    typename Derivedknown, 
    typename DerivedY,
    typename AeqT,
    typename DerivedBeq,
    typename AieqT,
    typename DerivedBieq,
    typename Derivedlx,
    typename Derivedux,
    typename DerivedZ
    >
  IGL_INLINE igl::SolverStatus active_set(
    const Eigen::SparseMatrix<AT>& A,
    const Eigen::PlainObjectBase<DerivedB> & B,
    const Eigen::PlainObjectBase<Derivedknown> & known,
    const Eigen::PlainObjectBase<DerivedY> & Y,
    const Eigen::SparseMatrix<AeqT>& Aeq,
    const Eigen::PlainObjectBase<DerivedBeq> & Beq,
    const Eigen::SparseMatrix<AieqT>& Aieq,
    const Eigen::PlainObjectBase<DerivedBieq> & Bieq,
    const Eigen::PlainObjectBase<Derivedlx> & lx,
    const Eigen::PlainObjectBase<Derivedux> & ux,
    const igl::active_set_params & params,
    Eigen::PlainObjectBase<DerivedZ> & Z
    );

// Input parameters for active_set:
// inactive_threshold Threshold on Lagrange multiplier values to determine
// solution_diff_threshold Threshold on the squared norm of the difference
adjacency_list.h // Constructs the graph adjacency list of a given mesh (V,F)
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// F #F by dim list of mesh faces (must be triangles)
// sorted flag that indicates if the list should be sorted counter-clockwise
// Outputs:
// A vector<vector<T> > containing at row i the adjacent vertices of vertex i
//
// Example:
// // Mesh in (V,F)
// vector<vector<double> > A;
// adjacency_list(F,A);
//
// See also: edges, cotmatrix, diag
  template <typename T, typename M>
  IGL_INLINE void adjacency_list(
    const M & F, 
    std::vector<std::vector<T> >& A,
    bool sorted = false);

adjacency_matrix.h // Constructs the graph adjacency matrix of a given mesh (V,F)
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// F #F by dim list of mesh simplices
// Outputs:
// A max(F) by max(F) cotangent matrix, each row i corresponding to V(i,:)
//
// Example:
// // Mesh in (V,F)
// Eigen::SparseMatrix<double> A;
// adjacency_matrix(F,A);
// // sum each row
// SparseVector<double> Asum;
// sum(A,1,Asum);
// // Convert row sums into diagonal of sparse matrix
// SparseMatrix<double> Adiag;
// diag(Asum,Adiag);
// // Build uniform laplacian
// SparseMatrix<double> U;
// U = A-Adiag;
//
// See also: edges, cotmatrix, diag
  template <typename T>
  IGL_INLINE void adjacency_matrix(
    const Eigen::MatrixXi & F, 
    Eigen::SparseMatrix<T>& A);

all_edges.h // ALL_EDGES Determines all "directed edges" of a given set of simplices
//
// Inputs:
// F #F by simplex_size list of "faces"
// Outputs:
// E #E by simplex_size-1 list of edges
//
// Note: this is not the same as igl::edges because this includes every
// directed edge including repeats (meaning interior edges on a surface will
// show up once for each direction and non-manifold edges may appear more than
// once for each direction).
  IGL_INLINE void all_edges(
    const Eigen::MatrixXi & F,
    Eigen::MatrixXi & E);

all_pairs_distances.h // ALL_PAIRS_DISTANCES compute distances between each point i in V and point j
// in U
//
// D = all_pairs_distances(V,U)
//
// Templates:
// Mat matrix class like MatrixXd
// Inputs:
// V #V by dim list of points
// U #U by dim list of points
// squared whether to return squared distances
// Outputs:
// D #V by #U matrix of distances, where D(i,j) gives the distance or
// squareed distance between V(i,:) and U(j,:)
//
  template <typename Mat>
  IGL_INLINE void all_pairs_distances(
    const Mat & V,
    const Mat & U,
    const bool squared, 
    Mat & D);

axis_angle_to_quat.h // Convert axis angle representation of a rotation to a quaternion
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// axis 3d vector
// angle scalar
// Outputs:
// quaternion
  template <typename Q_type>
  IGL_INLINE void axis_angle_to_quat(
    const Q_type *axis, 
    const Q_type angle,
    Q_type *out);

barycenter.h // BARYCENTER
//
// B = barycenter(V,F)
//
// Compute the barycenter of every triangle
//
// Inputs:
// V #V x dim matrix of vertex coordinates
// F #F x simplex_size matrix of indices of triangle corners
// Output:
// BC a #F x dim matrix of 3d vertices
  IGL_INLINE void barycenter(
      const Eigen::MatrixXd & V,
      const Eigen::MatrixXi & F,
      Eigen::MatrixXd & BC);

basename.h // Function like PHP's basename
// Input:
// path string containing input path
// Returns string containing basename (see php's basename)
//
// See also: dirname, pathinfo
  IGL_INLINE std::string basename(const std::string & path);

boundary_conditions.h // Compute boundary conditions for automatic weights computation
// Inputs:
// V #V by dim list of domain vertices
// Ele #Ele by simplex-size list of simplex indices
// C #C by dim list of handle positions
// P #P by 1 list of point handle indices into C
// BE #BE by 2 list of bone edge indices into C
// CE #CE by 2 list of cage edge indices into *P*, unused
// Outputs:
// b #b list of boundary indices (indices into V of vertices which have
// known, fixed values)
// bc #b by #weights list of known/fixed values for boundary vertices (notice
// the #b != #weights in general because #b will include all the
// intermediary samples along each bone, etc.. The ordering of the weights
// corresponds to [P;BE]
// Returns true if boundary conditions make sense
  IGL_INLINE bool boundary_conditions(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & Ele,
    const Eigen::MatrixXd & C,
    const Eigen::VectorXi & P,
    const Eigen::MatrixXi & BE,
    const Eigen::MatrixXi & CE,
    Eigen::VectorXi & b,
    Eigen::MatrixXd & bc);

boundary_faces.h // BOUNDARY_FACES Determine boundary faces (edges) of tetrahedra (triangles)
// stored in T
//
// Templates:
// IntegerT integer-value: e.g. int
// IntegerF integer-value: e.g. int
// Input:
// T tetrahedron (triangle) index list, m by 4 (3), where m is the number of tetrahedra
// Output:
// F list of boundary faces, n by 3 (2), where n is the number of boundary faces
//
//
  template <typename IntegerT, typename IntegerF>
  IGL_INLINE void boundary_faces(
    const std::vector<std::vector<IntegerT> > & T,
    std::vector<std::vector<IntegerF> > & F);

#ifndef IGL_NO_EIGEN

// Templates:
// DerivedT integer-value: i.e. from MatrixXi
// DerivedF integer-value: i.e. from MatrixXi
  template <typename DerivedT, typename DerivedF>
  IGL_INLINE void boundary_faces(
    const Eigen::PlainObjectBase<DerivedT>& T,
    Eigen::PlainObjectBase<DerivedF>& F);

// Same as above but returns F
  template <typename DerivedT, typename Ret>
  Ret boundary_faces(
    const Eigen::PlainObjectBase<DerivedT>& T);
#endif

bounding_box_diagonal.h // Compute the length of the diagonal of a given meshes axis-aligned bounding
// box
//
// Inputs:
// V #V by 3 list of vertex positions
// F #F by 3 list of triangle indices into V
// Returns length of bounding box diagonal
  IGL_INLINE double bounding_box_diagonal( const Eigen::MatrixXd & V);

canonical_quaternions.h
#  define SQRT_2_OVER_2 0.707106781f

// Float versions
// Identity
// X points right, Y points *in* and Z points up
  const float CANONICAL_VIEW_QUAT_F[][4] = 
#  undef SQRT_2_OVER_2

#  define SQRT_2_OVER_2 0.707106781186548f

// Double versions
// Identity
// X points right, Y points *in* and Z points up
  const double CANONICAL_VIEW_QUAT_D[][4] = 
#define NUM_CANONICAL_VIEW_QUAT 24

// NOTE: I want to rather be able to return a Q_type[][] but C++ is not
// making it easy. So instead I've written a per-element accessor
// Return element [i][j] of the corresponding CANONICAL_VIEW_QUAT_* of the
// given templated type
// Inputs:
// i index of quaternion
// j index of coordinate in quaternion i
// Returns values of CANONICAL_VIEW_QUAT_*[i][j]
  template <typename Q_type> 
  IGL_INLINE Q_type CANONICAL_VIEW_QUAT(int i, int j);

// Template specializations for float and double
  template <> 
  IGL_INLINE float CANONICAL_VIEW_QUAT<float>(int i, int j);
  template <> 
  IGL_INLINE double CANONICAL_VIEW_QUAT<double>(int i, int j);

#  undef SQRT_2_OVER_2

cat.h // If you're using Dense matrices you might be better off using the << operator
// This is an attempt to act like matlab's cat function.
// Perform concatenation of a two matrices along a single dimension
// If dim == 1, then C = [A;B]. If dim == 2 then C = [A B]
//
// Template:
// Scalar scalar data type for sparse matrices like double or int
// Mat matrix type for all matrices (e.g. MatrixXd, SparseMatrix)
// MatC matrix type for ouput matrix (e.g. MatrixXd) needs to support
// resize
// Inputs:
// A first input matrix
// B second input matrix
// dim dimension along which to concatenate, 0 or 1
// Outputs:
// C output matrix
//
  template <typename Scalar>
  IGL_INLINE void cat(
      const int dim, 
      const Eigen::SparseMatrix<Scalar> & A, 
      const Eigen::SparseMatrix<Scalar> & B, 
      Eigen::SparseMatrix<Scalar> & C);
  template <typename Derived, class MatC>
  IGL_INLINE void cat(
    const int dim,
    const Eigen::MatrixBase<Derived> & A, 
    const Eigen::MatrixBase<Derived> & B,
    MatC & C);

// Wrapper that returns C
  template <class Mat>
  IGL_INLINE Mat cat(const int dim, const Mat & A, const Mat & B);

// Note: Maybe we can autogenerate a bunch of overloads D = cat(int,A,B,C),
// E = cat(int,A,B,C,D), etc.
// Concatenate a "matrix" of blocks
// C = [A0;A1;A2;...;An] where Ai = [A[i][0] A[i][1] ... A[i][m]];
//
// Inputs:
// A a matrix (vector of row vectors)
// Output:
// C
  template <class Mat>
  IGL_INLINE void cat(const std::vector<std::vector< Mat > > & A, Mat & C);

cocoa_key_to_anttweakbar_key.h // Convert an unsigned char (like that from Cocoa apps) to AntTweakBar key
// code.
// See also: TranslateKey() in TwMgr.cpp in AntTweakBar source
// Inputs:
// key unsigned char key from keyboard
// Returns int of new key code
  IGL_INLINE int cocoa_key_to_anttweakbar_key(int key);

colon.h // Note:
// This should be potentially replaced with eigen's LinSpaced() function
// Colon operator like matlab's colon operator. Enumerats values between low
// and hi with step step.
// Templates:
// L should be a eigen matrix primitive type like int or double
// S should be a eigen matrix primitive type like int or double
// H should be a eigen matrix primitive type like int or double
// T should be a eigen matrix primitive type like int or double
// Inputs:
// low starting value if step is valid then this is *always* the first
// element of I
// step step difference between sequential elements returned in I,
// remember this will be cast to template T at compile time. If low<hi
// then step must be positive. If low>hi then step must be negative.
// Otherwise I will be set to empty.
// hi ending value, if (hi-low)%step is zero then this will be the last
// element in I. If step is positive there will be no elements greater
// than hi, vice versa if hi<low
// Output:
// I list of values from low to hi with step size step
  template <typename L,typename S,typename H,typename T>
  IGL_INLINE void colon(
    const L low, 
    const S step, 
    const H hi, 
    Eigen::Matrix<T,Eigen::Dynamic,1> & I);

// Same as above but step == (T)1
  template <typename L,typename H,typename T>
  IGL_INLINE void colon(
    const L low, 
    const H hi, 
    Eigen::Matrix<T,Eigen::Dynamic,1> & I);

// Return output rather than set in reference
  template <typename T,typename L,typename H>
  IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> colon(
    const L low, 
    const H hi);

concat.h // Concatenates dense matrices
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// A first matrix
// B second matrix
// horiz if true, matrices are concatenated horizontally
// Output:
// O if horiz = false return [A;B] else [A,B]
  template <typename T>
  IGL_INLINE void concat(
                     const T A, 
                     const T B,
                     const bool horiz,                 
                     T& O);

  template <typename T>
  IGL_INLINE T concat(
                  const T A, 
                  const T B,
                  bool horiz = false
                  );

cotangent.h // COTANGENT compute the cotangents of each angle in mesh (V,F)
//
// Templates:
// MatV vertex position matrix, e.g. Eigen::MatrixXd
// MatF face index matrix, e.g. Eigen::MatrixXd
// MatC cotangent weights matrix, e.g. Eigen::MatrixXd
// Inputs:
// V #V by dim list of rest domain positions
// for triangles, columns correspond to edges 23,31,12
// for tets, columns correspond to edges 23,31,12,41,42,43
  template <class MatV, class MatF, class MatC>
  IGL_INLINE void cotangent(const MatV & V, const MatF & F, MatC & C);

cotmatrix.h // Constructs the cotangent stiffness matrix (discrete laplacian) for a given
// mesh (V,F).
//
// Templates:
// DerivedV derived type of eigen matrix for V (e.g. derived from
// MatrixXd)
// DerivedF derived type of eigen matrix for F (e.g. derived from
// MatrixXi)
// Scalar scalar type for eigen sparse matrix (e.g. double)
// Inputs:
// V #V by dim list of mesh vertex positions
// F #F by simplex_size list of mesh faces (must be triangles)
// Outputs:
// L #V by #V cotangent matrix, each row i corresponding to V(i,:)
//
// See also: adjacency_matrix
//
// Known bugs: off by 1e-16 on regular grid. I think its a problem of
// arithmetic order in cotangent.h: C(i,e) = (arithmetic)/dblA/4
  template <typename DerivedV, typename DerivedF, typename Scalar>
  IGL_INLINE void cotmatrix(
    const Eigen::MatrixBase<DerivedV> & V, 
    const Eigen::MatrixBase<DerivedF> & F, 
    Eigen::SparseMatrix<Scalar>& L);

create_index_vbo.h // Inputs:
// F #F by 3 eigen Matrix of face (triangle) indices
// Outputs:
// F_vbo_id buffer id for face indices
//
  IGL_INLINE void create_index_vbo(
    const Eigen::MatrixXi & F,
    GLuint & F_vbo_id);

create_mesh_vbo.h // Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// Outputs:
// V_vbo_id buffer id for vertex positions
// F_vbo_id buffer id for face indices
//
// NOTE: when using glDrawElements VBOs for V and F using MatrixXd and
// MatrixXi will have types GL_DOUBLE and GL_UNSIGNED_INT respectively
//
  IGL_INLINE void create_mesh_vbo(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    GLuint & V_vbo_id,
    GLuint & F_vbo_id);

// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// N #V by 3 eigen Matrix of mesh vertex 3D normals
// Outputs:
// V_vbo_id buffer id for vertex positions
// F_vbo_id buffer id for face indices
// N_vbo_id buffer id for vertex positions
  IGL_INLINE void create_mesh_vbo(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    const Eigen::MatrixXd & N,
    GLuint & V_vbo_id,
    GLuint & F_vbo_id,
    GLuint & N_vbo_id);

create_shader_program.h // Create a shader program with a vertex and fragments shader loading from
// source strings and vertex attributes assigned from a map before linking the
// shaders to the program, making it ready to use with glUseProgram(id)
// Inputs:
// vert_source string containing source code of vertex shader
// frag_source string containing source code of fragment shader
// attrib map containing table of vertex attribute strings add their
// correspondingly ids (generated previously using glBindAttribLocation)
// Outputs:
// id index id of created shader, set to 0 on error
// Returns true on success, false on error
//
// Note: Caller is responsible for making sure that current value of id is not
// leaking a shader (since it will be overwritten)
//
// See also: destroy_shader_program
  IGL_INLINE bool create_shader_program(
    const std::string vert_source,
    const std::string frag_source,
    const std::map<std::string,GLuint> attrib,
    GLuint & id);

create_vector_vbo.h // Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// V m by n eigen Matrix of type T values
// Outputs:
// V_vbo_id buffer id for vectors
//
  template <typename T>
  IGL_INLINE void create_vector_vbo(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & V,
    GLuint & V_vbo_id);

cross.h // Computes out = cross(a,b)
// Inputs:
// a left 3d vector
// b right 3d vector
// Outputs:
// out result 3d vector
  IGL_INLINE void cross(
    const double *a, 
    const double *b,
    double *out);

destroy_shader_program.h // Properly destroy a shader program. Detach and delete each of its shaders
// and delete it
// Inputs:
// id index id of created shader, set to 0 on error
// Returns true on success, false on error
//
// Note: caller is responsible for making sure he doesn't foolishly continue
// to use id as if it still contains a program
//
// See also: create_shader_program
  IGL_INLINE bool destroy_shader_program(const GLuint id);

diag.h // Either extracts the main diagonal of a matrix as a vector OR converts a
// vector into a matrix with vector along the main diagonal. Like matlab's
// diag function
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// X an m by n sparse matrix
// Outputs:
// V a min(m,n) sparse vector
  template <typename T>
  IGL_INLINE void diag(
    const Eigen::SparseMatrix<T>& X, 
    Eigen::SparseVector<T>& V);
  template <typename T,typename DerivedV>
  IGL_INLINE void diag(
    const Eigen::SparseMatrix<T>& X, 
    Eigen::MatrixBase<DerivedV>& V);

// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// V a m sparse vector
// Outputs:
// X a m by m sparse matrix
  template <typename T>
  IGL_INLINE void diag(
    const Eigen::SparseVector<T>& V,
    Eigen::SparseMatrix<T>& X);
  template <typename T, typename DerivedV>
  IGL_INLINE void diag(
    const Eigen::MatrixBase<DerivedV>& V,
    Eigen::SparseMatrix<T>& X);

dirname.h // Function like PHP's dirname
// Input:
// path string containing input path
// Returns string containing dirname (see php's dirname)
//
// See also: basename, pathinfo
  IGL_INLINE std::string dirname(const std::string & path);

dot.h // Computes out = dot(a,b)
// Inputs:
// a left 3d vector
// b right 3d vector
// Returns scalar dot product
  IGL_INLINE double dot(
    const double *a, 
    const double *b);

doublearea.h // DOUBLEAREA computes twice the area for each input triangle
//
// Templates:
// DerivedV derived type of eigen matrix for V (e.g. derived from
// MatrixXd)
// DerivedF derived type of eigen matrix for F (e.g. derived from
// MatrixXi)
// DeriveddblA derived type of eigen matrix for dblA (e.g. derived from
// MatrixXd)
// Inputs:
// V #V by dim list of mesh vertex positions
// F #F by simplex_size list of mesh faces (must be triangles)
// Outputs:
// dblA #F list of triangle double areas
//
// Note: THESE ARE *NOT* SIGNED. In matlab doublearea is signed in 2d
  template <typename DerivedV, typename DerivedF, typename DeriveddblA>
  IGL_INLINE void doublearea( 
    const Eigen::PlainObjectBase<DerivedV> & V, 
    const Eigen::PlainObjectBase<DerivedF> & F, 
    Eigen::PlainObjectBase<DeriveddblA> & dblA);

// Same as above but use instrinsic edge lengths rather than (V,F) mesh
// Templates:
// DerivedV derived type of eigen matrix for V (e.g. derived from
// MatrixXd)
// DerivedF derived type of eigen matrix for F (e.g. derived from
// MatrixXi)
// DeriveddblA derived type of eigen matrix for dblA (e.g. derived from
// MatrixXd)
// Inputs:
// l #F by dim list of edge lengths using
// for triangles, columns correspond to edges 23,31,12
// Outputs:
// dblA #F list of triangle double areas
  template <typename Derivedl, typename DeriveddblA>
  IGL_INLINE void doublearea( 
    const Eigen::PlainObjectBase<Derivedl> & l, 
    Eigen::PlainObjectBase<DeriveddblA> & dblA);

draw_beach_ball.h // Draw a beach ball icon/glyph (from AntTweakBar) at the current origin
// according to the current orientation: ball has radius 0.75 and axis have
// length 1.15
  IGL_INLINE void draw_beach_ball();
  #ifdef IGL_HEADER
  #  include "draw_beach_ball.cpp"
  #endif

draw_mesh.h // Draw OpenGL commands needed to display a mesh with normals
//
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// N #V by 3 eigen Matrix of mesh vertex 3D normals
  IGL_INLINE void draw_mesh(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    const Eigen::MatrixXd & N);

// Draw OpenGL commands needed to display a mesh with normals and per-vertex
// colors
//
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// N #V by 3 eigen Matrix of mesh vertex 3D normals
// C #V by 3 eigen Matrix of mesh vertex RGB colors
  IGL_INLINE void draw_mesh(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    const Eigen::MatrixXd & N,
    const Eigen::MatrixXd & C);

// Draw OpenGL commands needed to display a mesh with normals, per-vertex
// colors and LBS weights
//
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// N #V by 3 eigen Matrix of mesh vertex 3D normals
// C #V by 3 eigen Matrix of mesh vertex RGB colors
// TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
// W #V by #H eigen Matrix of per mesh vertex, per handle weights
// W_index Specifies the index of the "weight" vertex attribute: see
// glBindAttribLocation, if W_index is 0 then weights are ignored
// WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
// WI_index Specifies the index of the "weight" vertex attribute: see
// glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  IGL_INLINE void draw_mesh(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    const Eigen::MatrixXd & N,
    const Eigen::MatrixXd & C,
    const Eigen::MatrixXd & TC,
    const Eigen::MatrixXd & W,
    const GLuint W_index,
    const Eigen::MatrixXi & WI,
    const GLuint WI_index);

// Draw OpenGL commands needed to display a mesh with normals, per-vertex
// colors and LBS weights
//
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// N #V by 3 eigen Matrix of mesh vertex 3D normals
// NF #F by 3 eigen Matrix of face (triangle) normal indices, <0 means no
// normal
// C #V by 3 eigen Matrix of mesh vertex RGB colors
// TC #V by 3 eigen Matrix of mesh vertex UC coorindates between 0 and 1
// TF #F by 3 eigen Matrix of face (triangle) texture indices, <0 means no
// texture
// W #V by #H eigen Matrix of per mesh vertex, per handle weights
// W_index Specifies the index of the "weight" vertex attribute: see
// glBindAttribLocation, if W_index is 0 then weights are ignored
// WI #V by #H eigen Matrix of per mesh vertex, per handle weight ids
// WI_index Specifies the index of the "weight" vertex attribute: see
// glBindAttribLocation, if WI_index is 0 then weight indices are ignored
  IGL_INLINE void draw_mesh(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & F,
    const Eigen::MatrixXd & N,
    const Eigen::MatrixXi & NF,
    const Eigen::MatrixXd & C,
    const Eigen::MatrixXd & TC,
    const Eigen::MatrixXi & TF,
    const Eigen::MatrixXd & W,
    const GLuint W_index,
    const Eigen::MatrixXi & WI,
    const GLuint WI_index);

draw_point.h
#ifdef IGL_HEADER_ONLY
#  include "draw_point.cpp"
#endif

#endif
#endif

edges.h // Constructs a list of unique edges represented in a given mesh (V,F)
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// F #F by 3 list of mesh faces (must be triangles)
// or
// T #T x 4 matrix of indices of tet corners
// Outputs:
// E #E by 2 list of edges in no particular order
//
// See also: adjacency_matrix
  IGL_INLINE void edges( const Eigen::MatrixXi& F, Eigen::MatrixXi& E);

edgetopology.h // Initialize Edges and their topological relations
// Output:
// EV : #Ex2, Stores the edge description as pair of indices to vertices
// FE : #Fx3, Stores the Triangle-Edge relation
// EF : #Ex2: Stores the Edge-Triangle relation
  IGL_INLINE void edgetopology(
    const Eigen::MatrixXd& V, 
    const Eigen::MatrixXi& F, 
    Eigen::MatrixXi& EV, 
    Eigen::MatrixXi& FE, 
    Eigen::MatrixXi& EF);

edge_lengths.h // Constructs a list of lengths of edges opposite each index in a face
// (triangle) list
// Templates:
// DerivedV derived from vertex positions matrix type: i.e. MatrixXd
// DerivedF derived from face indices matrix type: i.e. MatrixXi
// DerivedL derived from edge lengths matrix type: i.e. MatrixXd
// Inputs:
// V eigen matrix #V by 3
// F #F by 3 list of mesh faces (must be triangles)
// Outputs:
// E #E by 2 list of edges in no particular order
//
// See also: adjacency_matrix
  template <typename DerivedV, typename DerivedF, typename DerivedL>
  IGL_INLINE void edge_lengths(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedL>& L);

example_fun.h // This is an example of a function, it takes a templated parameter and
// shovels it into cout
//
// Templates:
// T type that supports
// Input:
// input some input of a Printable type
// Returns true for the sake of returning something
  template <typename Printable>
  IGL_INLINE bool example_fun(const Printable & input);

faces_first.h // FACES_FIRST Reorder vertices so that vertices in face list come before
// vertices that don't appear in the face list. This is especially useful if
// the face list contains only surface faces and you want surface vertices
// listed before internal vertices
//
// [RV,RT,RF,IM] = faces_first(V,T,F);
//
// Templates:
// MatV matrix for vertex positions, e.g. MatrixXd
// MatF matrix for face indices, e.g. MatrixXi
// VecI vector for index map, e.g. VectorXi
// Input:
// V # vertices by 3 vertex positions
// F # faces by 3 list of face indices
// Output:
// RV # vertices by 3 vertex positions, order such that if the jth vertex is
// some face in F, and the kth vertex is not then j comes before k
// RF # faces by 3 list of face indices, reindexed to use RV
// IM #V by 1 list of indices such that: RF = IM(F) and RT = IM(T)
// and RV(IM,:) = V
//
//
// Example:
// // Tet mesh in (V,T,F)
// faces_first(V,F,IM);
// T = T.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
// (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
// &IM)).eval();
  template <typename MatV, typename MatF, typename VecI>
  IGL_INLINE void faces_first(
    const MatV & V, 
    const MatF & F, 
    MatV & RV, 
    MatF & RF, 
    VecI & IM);

// Virtual "in place" wrapper
  template <typename MatV, typename MatF, typename VecI>
  IGL_INLINE void faces_first(
    MatV & V, 
    MatF & F, 
    VecI & IM);

face_occurences.h // Count the occruances of each face (row) in a list of face indices
// (irrespecitive of order)
// Inputs:
// F #F by simplex-size
// Outputs
// C #F list of counts
// Known bug: triangles/tets only (where ignoring order still gives simplex)
  template <typename IntegerF, typename IntegerC>
  IGL_INLINE void face_occurences(
    const std::vector<std::vector<IntegerF> > & F,
    std::vector<IntegerC> & C);

file_contents_as_string.h // Read a files contents as plain text into a given string
// Inputs:
// file_name path to file to be read
// Outputs:
// content output string containing contents of the given file
// Returns true on succes, false on error
  IGL_INLINE bool file_contents_as_string(
    const std::string file_name,
    std::string & content);

file_exists.h // Check if a file or directory exists like PHP's file_exists function:
// http://php.net/manual/en/function.file-exists.php
// Input:
// filename path to file
// Returns true if file exists and is readable and false if file doesn't
// exist or *is not readable*
  IGL_INLINE bool file_exists(const char * filename);

find.h // Find the non-zero entries and there respective indices in a sparse matrix.
// Like matlab's [I,J,V] = find(X)
//
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Input:
// X m by n matrix whose entries are to be found
// Outputs:
// I nnz vector of row indices of non zeros entries in X
// J nnz vector of column indices of non zeros entries in X
// V nnz vector of type T non-zeros entries in X
//
  template <
    typename T, 
    typename DerivedI, 
    typename DerivedJ,
    typename DerivedV>
  IGL_INLINE void find(
    const Eigen::SparseMatrix<T>& X,
    Eigen::MatrixBase<DerivedI> & I,
    Eigen::MatrixBase<DerivedJ> & J,
    Eigen::MatrixBase<DerivedV> & V);

// Find the non-zero entries and there respective indices in a sparse vector.
// Similar to matlab's [I,J,V] = find(X), but instead of [I,J] being
// subscripts into X, since X is a vector we just return I, a list of indices
// into X
//
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Input:
// X vector whose entries are to be found
// Outputs:
// I nnz vector of indices of non zeros entries in X
// V nnz vector of type T non-zeros entries in X
  template <typename T>
  IGL_INLINE void find(
    const Eigen::SparseVector<T>& X,
    Eigen::Matrix<int,Eigen::Dynamic,1> & I,
    Eigen::Matrix<T,Eigen::Dynamic,1> & V);

full.h // This is totally unnecessary. You can just call MatrixXd B = MatrixXd(A);
//
// Convert a sparsematrix into a full one
//
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Input:
// A m by n sparse matrix
// Output:
// B m by n dense/full matrix
  template <typename T,typename DerivedB>
  IGL_INLINE void full(
    const Eigen::SparseMatrix<T> & A,
    Eigen::PlainObjectBase<DerivedB> & B);

// If already full then this will just be a copy by assignment
  template <typename DerivedA,typename DerivedB>
  IGL_INLINE void full(
    const Eigen::PlainObjectBase<DerivedA>& A,
    Eigen::PlainObjectBase<DerivedB>& B);

get_seconds.h // Return the current time in seconds since program start
  IGL_INLINE double get_seconds();

get_seconds_hires.h // Return the current time in seconds using performance counters
  IGL_INLINE double get_seconds_hires();

gl_type_size.h // Return the number of bytes for a given OpenGL type
// Inputs:
// type enum value of opengl type
// Returns size in bytes of type
  IGL_INLINE int gl_type_size(const GLenum type);

grad.h // GRAD
// G = grad(V,F,X)
//
// Compute the numerical gradient at every face of a triangle mesh.
//
// Inputs:
// V #vertices by 3 list of mesh vertex positions
// F #faces by 3 list of mesh face indices
// X # vertices list of scalar function values
// Outputs:
// G #faces by 3 list of gradient values
//
// Gradient of a scalar function defined on piecewise linear elements (mesh)
// is constant on each triangle i,j,k: grad(Xijk) = (Xj-Xi) * (Vi - Vk)^R90 /
// 2A + (Xk-Xi) * (Vj - Vi)^R90 / 2A where Xi is the scalar value at vertex
// i, Vi is the 3D position of vertex i, and A is the area of triangle
// (i,j,k). ^R90 represent a rotation of 90 degrees
//
  template <typename T, typename S>
  IGL_INLINE void grad(
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
    const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &F,
    const Eigen::Matrix<T, Eigen::Dynamic, 1>&X,
    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &G );

gradMat.h // GRAD
// G = grad(V,F)
//
// Compute the numerical gradient operator
//
// Inputs:
// V #vertices by 3 list of mesh vertex positions
// F #faces by 3 list of mesh face indices
// Outputs:
// G #faces*dim by #V Gradient operator
//
  

// Gradient of a scalar function defined on piecewise linear elements (mesh)
// is constant on each triangle i,j,k:
// grad(Xijk) = (Xj-Xi) * (Vi - Vk)^R90 / 2A + (Xk-Xi) * (Vj - Vi)^R90 / 2A
// where Xi is the scalar value at vertex i, Vi is the 3D position of vertex
// i, and A is the area of triangle (i,j,k). ^R90 represent a rotation of
// 90 degrees
//
  template <typename T, typename S>
  IGL_INLINE void gradMat(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
    const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &F,
  Eigen::SparseMatrix<T> &G);

harwell_boeing.h // Convert the matrix to Compressed sparse column (CSC or CCS) format,
// also known as Harwell Boeing format. As described:
// http://netlib.org/linalg/html_templates/node92.html
// or
// http://en.wikipedia.org/wiki/Sparse_matrix
// #Compressed_sparse_column_.28CSC_or_CCS.29
// Templates:
// Scalar type of sparse matrix like double
// Inputs:
// A sparse m by n matrix
// Outputs:
// num_rows number of rows
// V non-zero values, row indices running fastest, size(V) = nnz
// R row indices corresponding to vals, size(R) = nnz
// C index in vals of first entry in each column, size(C) = num_cols+1
//
// All indices and pointers are 0-based
  template <typename Scalar, typename Index>
  IGL_INLINE void harwell_boeing(
    const Eigen::SparseMatrix<Scalar> & A,
    int & num_rows,
    std::vector<Scalar> & V,
    std::vector<Index> & R,
    std::vector<Index> & C);

hsv_to_rgb.h // Convert RGB to HSV
//
// Inputs:
// h hue value (degrees: [0,360])
// s saturation value ([0,1])
// v value value ([0,1])
// Outputs:
// r red value ([0,1])
// g green value ([0,1])
// b blue value ([0,1])
  template <typename T>
  void hsv_to_rgb(const T * hsv, T * rgb);
  template <typename T>
  void hsv_to_rgb( 
    const T & h, const T & s, const T & v, 
    T & r, T & g, T & b);

invert_diag.h // Invert the diagonal entries of a matrix (if the matrix is a diagonal
// matrix then this amounts to inverting the matrix)
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// X an m by n sparse matrix
// Outputs:
// Y an m by n sparse matrix
  template <typename T>
  IGL_INLINE void invert_diag(
    const Eigen::SparseMatrix<T>& X, 
    Eigen::SparseMatrix<T>& Y);

is_border_vertex.h // Determine vertices on open boundary of a (manifold) mesh with triangle
// faces F
//
// Inputs:
// V #V by dim list of vertex positions
// F #F by 3 list of triangle indices
// Returns vector of indices of vertices on open boundary of F
//
// Known Bugs: does not depend on V
//
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE std::vector<bool> is_border_vertex(
   const Eigen::PlainObjectBase<DerivedV> &V,
   const Eigen::PlainObjectBase<DerivedF> &F);

is_dir.h // Act like php's is_dir function
// http://php.net/manual/en/function.is-dir.php
// Tells whether the given filename is a directory.
// Input:
// filename Path to the file. If filename is a relative filename, it will
// be checked relative to the current working directory.
// Returns TRUE if the filename exists and is a directory, FALSE
// otherwise.
  IGL_INLINE bool is_dir(const char * filename);

is_file.h // Act like php's is_file function
// http://php.net/manual/en/function.is-file.php
// Tells whether the given filename is a regular file.
// Input:
// filename Path to the file. If filename is a relative filename, it will
// be checked relative to the current working directory.
// Returns TRUE if the filename exists and is a regular file, FALSE
// otherwise.
  IGL_INLINE bool is_file(const char * filename);

is_manifold.h // check if the mesh is edge-manifold
//
// Not clear whether this returns true or false if the mesh is disc topology
//
// Known Bugs:
// Does not check for non-manifold vertices
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool is_manifold(const Eigen::PlainObjectBase<DerivedV>& V,
                              const Eigen::PlainObjectBase<DerivedF>& F);

is_readable.h // Check if a file is reabable like PHP's is_readable function:
// http://www.php.net/manual/en/function.is-readable.php
// Input:
// filename path to file
// Returns true if file exists and is readable and false if file doesn't
// exist or *is not readable*
//
// Note: Windows version will not check user or group ids
  IGL_INLINE bool is_readable(const char * filename);

is_sparse.h // Determine if a matrix A is sparse
//
// Template:
// T,DerivedA defines scalar type
// Inputs:
// A matrix in question
// Returns true if A is represented with a sparse matrix
  template <typename T>
  IGL_INLINE bool is_sparse(
    const Eigen::SparseMatrix<T> & A);
  template <typename DerivedA>
  IGL_INLINE bool is_sparse(
    const Eigen::PlainObjectBase<DerivedA>& A);

is_symmetric.h // Returns true if the given matrix is symmetric
// Inputs:
// A m by m matrix
// Returns true if the matrix is square and symmetric
  template <typename AT>
  IGL_INLINE bool is_symmetric(const Eigen::SparseMatrix<AT>& A);

// Inputs:
// epsilon threshold on L1 difference between A and A'
  template <typename AT, typename epsilonT>
  IGL_INLINE bool is_symmetric(const Eigen::SparseMatrix<AT>& A, const epsilonT epsilon);
  template <typename DerivedA>
  IGL_INLINE bool is_symmetric(
    const Eigen::PlainObjectBase<DerivedA>& A);

is_writable.h // Check if a file exists *and* is writable like PHP's is_writable function:
// http://www.php.net/manual/en/function.is-writable.php
// Input:
// filename path to file
// Returns true if file exists and is writable and false if file doesn't
// exist or *is not writable*
//
// Note: Windows version will not test group and user id
  IGL_INLINE bool is_writable(const char * filename);

jet.h // JET like MATLAB's jet
//
// Inputs:
// m number of colors
// Outputs:
// J m by list of RGB colors between 0 and 1
//
//#ifndef IGL_NO_EIGEN
// void jet(const int m, Eigen::MatrixXd & J);
//#endif
// Wrapper for directly computing [r,g,b] values for a given factor f between
// 0 and 1
//
// Inputs:
// f factor determining color value as if 0 was min and 1 was max
// Outputs:
// r red value
// g green value
// b blue value
  template <typename T>
  void jet(const T f, T * rgb);
  template <typename T>
  void jet(const T f, T & r, T & g, T & b);

launch_medit.h // Writes the tetmesh in (V,T,F) to a temporary file, opens it with medit
// (forking with a system call) and returns
//
//
// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedT integer-value: i.e. from MatrixXi
// DerivedF integer-value: i.e. from MatrixXi
// Inputs:
// V double matrix of vertex positions #V by 3
// T #T list of tet indices into vertex positions
// F #F list of face indices into vertex positions
// wait whether to wait for medit process to finish before returning
// Returns returned value of system call (probably not useful if wait=false
// because of the fork)
  template <typename DerivedV, typename DerivedT, typename DerivedF>
  IGL_INLINE int launch_medit(
    const Eigen::PlainObjectBase<DerivedV> & V, 
    const Eigen::PlainObjectBase<DerivedT> & T,
    const Eigen::PlainObjectBase<DerivedF> & F,
    const bool wait);

limit_faces.h // LIMIT_FACES limit given faces F to those which contain (only) indices found
// in L.
//
// [LF] = limit_faces(F,L,exclusive);
// [LF,in] = limit_faces(F,L,exclusive);
//
// Templates:
// MatF matrix type of faces, matrixXi
// VecL matrix type of vertex indices, VectorXi
// Inputs:
// F #F by 3 list of face indices
// L #L by 1 list of allowed indices
// exclusive flag specifying whether a face is included only if all its
// indices are in L, default is false
// Outputs:
// LF #LF by 3 list of remaining faces after limiting
// in #F list of whether given face was included
//
  template <typename MatF, typename VecL>
  IGL_INLINE void limit_faces(
    const MatF & F, 
    const VecL & L, 
    const bool exclusive,
    MatF & LF);

list_to_matrix.h // Convert a list (std::vector) of row vectors of the same length to a matrix
// Template:
// T type that can be safely cast to type in Mat via '='
// Mat Matrix type, must implement:
// .resize(m,n)
// .row(i) = Row
// Inputs:
// V a m-long list of vectors of size n
// Outputs:
// M an m by n matrix
// Returns true on success, false on errors
  template <typename T, class Mat>
  IGL_INLINE bool list_to_matrix(
    const std::vector<std::vector<T > > & V,
    Mat & M);

// Vector wrapper
  template <typename T, class Mat>
  IGL_INLINE bool list_to_matrix(const std::vector<T > & V,Mat & M);

load_shader.h // Creates and compiles a shader from a given string
// Inputs:
// src string containing GLSL shader code
// type GLSL type of shader, one of:
// GL_VERTEX_SHADER
// GL_FRAGMENT_SHADER
// GL_GEOMETRY_SHADER
// Returns index id of the newly created shader, 0 on error
  IGL_INLINE GLuint load_shader(const char *src,const GLenum type);

lu_lagrange.h // KNOWN BUGS: This does not seem to be correct for non-empty C
//
// LU_LAGRANGE Compute a LU decomposition for a special type of
// matrix Q that is symmetric but not positive-definite:
// Q = [A'*A C
// C' 0];
// where A'*A, or ATA, is given as a symmetric positive definite matrix and C
// has full column-rank(?)
//
// [J] = lu_lagrange(ATA,C)
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// ATA n by n square, symmetric, positive-definite system matrix, usually
// the quadratic coefficients corresponding to the original unknowns in a
// system
// C n by m rectangular matrix corresponding the quadratic coefficients of
// the original unknowns times the lagrange multipliers enforcing linear
// equality constraints
// Outputs:
// L lower triangular matrix such that Q = L*U
// U upper triangular matrix such that Q = L*U
// Returns true on success, false on error
//
// Note: C should *not* have any empty columns. Typically C is the slice of
// the linear constraints matrix Aeq concerning the unknown variables of a
// quadratic optimization. Generally constraints may deal with unknowns as
// well as knowns. Each linear constraint corresponds to a column of Aeq. As
// long as each constraint concerns at least one unknown then the
// corresponding column in C will have at least one non zero entry. If a
// constraint concerns *no* unknowns, you should double check that this is a
// valid constraint. How can you constrain known values to each other? This
// is either a contradiction to the knowns' values or redundent. In either
// case, it's not this functions responsiblilty to handle empty constraints
// so you will get an error.
//
  template <typename T>
  IGL_INLINE bool lu_lagrange(
    const Eigen::SparseMatrix<T> & ATA,
    const Eigen::SparseMatrix<T> & C,
    Eigen::SparseMatrix<T> & L,
    Eigen::SparseMatrix<T> & U);

marching_cubes.h // marching_cubes( values, points, x_res, y_res, z_res, vertices, faces )
//
// performs marching cubes reconstruction on the grid defined by values, and
// points, and generates vertices and faces
//
// Input:
// xres, yres, zres resolutions of the grid in x,y,z dimensions
// values #number_of_grid_points x 1 array -- the scalar values of an
// implicit function defined on the grid points (<0 in the inside of the
// surface, 0 on the border, >0 outside)
// points #number_of_grid_points x 3 array -- 3-D positions of the grid
// points, ordered in x,y,z order:
// points[index] = the point at (x,y,z) where :
// x = (index % (xres -1),
// y = (index / (xres-1)) %(yres-1),
// z = index / (xres -1) / (yres -1) ).
// where x,y,z index x, y, z dimensions
// i.e. index = x + y*xres + z*xres*yres
// Output:
// vertices #V by 3 list of mesh vertex positions
// faces #F by 3 list of mesh triangle indices
//
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void marching_cubes(
    const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> &values,
    const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 3> &points,
    const unsigned x_res,
    const unsigned y_res,
    const unsigned z_res,
    Eigen::PlainObjectBase<DerivedV> &vertices,
    Eigen::PlainObjectBase<DerivedF> &faces);

massmatrix.h
  enum MassMatrixType
#define NUM_MASSMATRIXTYPE 3

// Constructs the mass (area) matrix for a given mesh (V,F).
//
// Templates:
// DerivedV derived type of eigen matrix for V (e.g. derived from
// MatrixXd)
// DerivedF derived type of eigen matrix for F (e.g. derived from
// MatrixXi)
// Scalar scalar type for eigen sparse matrix (e.g. double)
// Inputs:
// V #V by dim list of mesh vertex positions
// F #F by simplex_size list of mesh faces (must be triangles)
// type one of the following ints:
// IGL_MASSMATRIX_BARYCENTRIC barycentric
// Outputs:
// M #V by #V mass matrix
//
// See also: adjacency_matrix
//
  template <typename DerivedV, typename DerivedF, typename Scalar>
  IGL_INLINE void massmatrix(
    const Eigen::MatrixBase<DerivedV> & V, 
    const Eigen::MatrixBase<DerivedF> & F, 
    const MassMatrixType type,
    Eigen::SparseMatrix<Scalar>& M);

matlab_format.h // This is a routine to print a matrix using format suitable for pasting into
// the matlab IDE
//
// Templates:
// DerivedM e.g. derived from MatrixXd
// Input:
// input some matrix to be formated
// name name of matrix
// Returns Formated matrix
//
// Example:
// // M := [1 2 3;4 5 6];
// cout<<matlab_format(M)<<endl;
// // Prints:
// // [
// // 1 2 3
// // 4 5 6
// // ];
// cout<<matlab_format(M,"M")<<endl;
// // Prints:
// // M = [
// // 1 2 3
// // 4 5 6
// // ];
  template <typename DerivedM>
  IGL_INLINE const Eigen::WithFormat< DerivedM > matlab_format(
    const Eigen::PlainObjectBase<DerivedM> & M,
    const std::string name = "");

// Same but for sparse matrices. Print IJV format into an auxillary variable
// and then print a call to sparse which will construct the sparse matrix
// Example:
// // S := [0 2 3;4 5 0];
// cout<<matlab_format(S,"S")<<endl;
// // Prints:
// // SIJV = [
// // 2 1 4
// // 1 2 2
// // 2 2 5
// // 1 3 3
// // ];
// // S = sparse(SIJV(:,1),SIJV(:,2),SIJV(:,3));
//
  template <typename DerivedS>
  IGL_INLINE const std::string matlab_format(
    const Eigen::SparseMatrix<DerivedS> & S,
    const std::string name = "");

// Return just IOFormat
//
// Example:
// // M := [1 2 3;4 5 6];
// cout<<M.format(matlab_format())<<endl;
// // Prints:
// // [
// // 1 2 3
// // 4 5 6
// // ];
  IGL_INLINE Eigen::IOFormat matlab_format();

matrix_to_list.h // Convert a matrix to a list (std::vector) of row vectors of the same size
// Template:
// Mat Matrix type, must implement:
// .resize(m,n)
// .row(i) = Row
// T type that can be safely cast to type in Mat via '='
// Inputs:
// V a m-long list of vectors of size n
// Outputs:
// M an m by n matrix
//
// See also: list_to_matrix
  template <typename DerivedM>
  IGL_INLINE void matrix_to_list(
    const Eigen::MatrixBase<DerivedM> & M, 
    std::vector<std::vector<typename DerivedM::Scalar > > & V);

// For vector input
  template <typename DerivedM>
  IGL_INLINE void matrix_to_list(
    const Eigen::MatrixBase<DerivedM> & M, 
    std::vector<typename DerivedM::Scalar > & V);

// Return wrapper
  template <typename DerivedM>
  IGL_INLINE std::vector<typename DerivedM::Scalar > matrix_to_list(
      const Eigen::MatrixBase<DerivedM> & M);

mat_max.h // Ideally this becomes a super overloaded function supporting everything
// that matlab's max supports
// Max function for matrices to act like matlab's max function. Specifically
// like [Y,I] = max(X,[],dim);
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// X m by n matrix
// dim dimension along which to take max
// Outputs:
// Y n-long sparse vector (if dim == 1)
// or
// Y m-long sparse vector (if dim == 2)
// I vector the same size as Y containing the indices along dim of maximum
// entries
  template <typename T>
  IGL_INLINE void mat_max(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
    const int dim,
    Eigen::Matrix<T,Eigen::Dynamic,1> & Y,
    Eigen::Matrix<int,Eigen::Dynamic,1> & I);

mat_min.h // Ideally this becomes a super overloaded function supporting everything
// that matlab's min supports
// Min function for matrices to act like matlab's min function. Specifically
// like [Y,I] = min(X,[],dim);
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// X m by n matrix
// dim dimension along which to take min
// Outputs:
// Y n-long sparse vector (if dim == 1)
// or
// Y m-long sparse vector (if dim == 2)
// I vector the same size as Y containing the indices along dim of minimum
// entries
//
// See also: mat_max
  template <typename T>
  IGL_INLINE void mat_min(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
    const int dim,
    Eigen::Matrix<T,Eigen::Dynamic,1> & Y,
    Eigen::Matrix<int,Eigen::Dynamic,1> & I);

// Use Y = X.colwise().minCoeff() instead
//// In-line wrapper
//template <typename T>
//IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> mat_min(
// const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
// const int dim);
mat_to_quat.h // Convert a OpenGL (rotation) matrix to a quaternion
//
// Input:
// m 16-element opengl rotation matrix
// Output:
// q 4-element quaternion (not normalized)
  template <typename Q_type>
  IGL_INLINE void mat4_to_quat(const Q_type * m, Q_type * q);

// TODO: implement for mat3 etc.
max_size.h // Determine max size of lists in a vector
// Template:
// T some list type object that implements .size()
// Inputs:
// V vector of list types T
// Returns max .size() found in V, returns -1 if V is empty
  template <typename T>
  IGL_INLINE int max_size(const std::vector<T> & V);

median.h // Compute the median of an eigen vector
//
// Inputs:
// V #V list of unsorted values
// Outputs:
// m median of those values
// Returns true on success, false on failure
  IGL_INLINE bool median(const Eigen::VectorXd & V, double & m);

min_quad_dense.h // MIN_QUAD_WITH_FIXED Minimize quadratic energy Z'*A*Z + Z'*B + C
// subject to linear constraints Aeq*Z = Beq
//
// Templates:
// T should be a eigen matrix primitive type like float or double
// Inputs:
// A n by n matrix of quadratic coefficients
// B n by 1 column of linear coefficients
// Aeq m by n list of linear equality constraint coefficients
// Beq m by 1 list of linear equality constraint constant values
// use_lu_decomposition use lu rather than SVD
// Outputs:
// S n by (n + m) "solve" matrix, such that S*[B', Beq'] is a solution
// Returns true on success, false on error
  template <typename T>
  IGL_INLINE void min_quad_dense_precompute(
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& A,
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& Aeq,    
    const bool use_lu_decomposition,
    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& S);

min_quad_with_fixed.h
  template <typename T>
  struct min_quad_with_fixed_data;

// Known Bugs: rows of Aeq **must** be linearly independent. Should be using
// QR decomposition otherwise:
// http://www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
//
// MIN_QUAD_WITH_FIXED Minimize quadratic energy Z'*A*Z + Z'*B + C with
// constraints that Z(known) = Y, optionally also subject to the constraints
// Aeq*Z = Beq
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// A n by n matrix of quadratic coefficients
// known list of indices to known rows in Z
// Y list of fixed values corresponding to known rows in Z
// Aeq m by n list of linear equality constraint coefficients
// pd flag specifying whether A(unknown,unknown) is positive definite
// Outputs:
// data factorization struct with all necessary information to solve
// using min_quad_with_fixed_solve
// Returns true on success, false on error
//
// Benchmark: For a harmonic solve on a mesh with 325K facets, matlab 2.2
// secs, igl/min_quad_with_fixed.h 7.1 secs
//
  template <typename T, typename Derivedknown>
  IGL_INLINE bool min_quad_with_fixed_precompute(
    const Eigen::SparseMatrix<T>& A,
    const Eigen::PlainObjectBase<Derivedknown> & known,
    const Eigen::SparseMatrix<T>& Aeq,
    const bool pd,
    min_quad_with_fixed_data<T> & data
    );

// Solves a system previously factored using min_quad_with_fixed_precompute
//
// Template:
// T type of sparse matrix (e.g. double)
// DerivedY type of Y (e.g. derived from VectorXd or MatrixXd)
// DerivedZ type of Z (e.g. derived from VectorXd or MatrixXd)
// Inputs:
// data factorization struct with all necessary precomputation to solve
// B n by 1 column of linear coefficients
// Beq m by 1 list of linear equality constraint constant values
// Outputs:
// Z n by cols solution
// sol #unknowns+#lagrange by cols solution to linear system
// Returns true on success, false on error
  template <
    typename T,
    typename DerivedB, 
    typename DerivedY,
    typename DerivedBeq, 
    typename DerivedZ,
    typename Derivedsol>
  IGL_INLINE bool min_quad_with_fixed_solve(
    const min_quad_with_fixed_data<T> & data,
    const Eigen::PlainObjectBase<DerivedB> & B,
    const Eigen::PlainObjectBase<DerivedY> & Y,
    const Eigen::PlainObjectBase<DerivedBeq> & Beq,
    Eigen::PlainObjectBase<DerivedZ> & Z,
    Eigen::PlainObjectBase<Derivedsol> & sol);

// Wrapper without sol
  template <
    typename T,
    typename DerivedB, 
    typename DerivedY,
    typename DerivedBeq, 
    typename DerivedZ>
  IGL_INLINE bool min_quad_with_fixed_solve(
    const min_quad_with_fixed_data<T> & data,
    const Eigen::PlainObjectBase<DerivedB> & B,
    const Eigen::PlainObjectBase<DerivedY> & Y,
    const Eigen::PlainObjectBase<DerivedBeq> & Beq,
    Eigen::PlainObjectBase<DerivedZ> & Z);

// Size of original system: number of unknowns + number of knowns
  int n;

// Whether A(unknown,unknown) is positive definite
  bool Auu_pd;

// Whether A(unknown,unknown) is symmetric
  bool Auu_sym;

// Indices of known variables
  Eigen::VectorXi known;

// Indices of unknown variables
  Eigen::VectorXi unknown;

// Indices of lagrange variables
  Eigen::VectorXi lagrange;

// Indices of unknown variable followed by Indices of lagrange variables
  Eigen::VectorXi unknown_lagrange;

// Matrix multiplied against Y when constructing right hand side
  Eigen::SparseMatrix<T> preY;
  enum SolverType

// Solvers
  Eigen::SimplicialLLT <Eigen::SparseMatrix<T > > llt;
  Eigen::SimplicialLDLT<Eigen::SparseMatrix<T > > ldlt;
  Eigen::SparseLU<Eigen::SparseMatrix<T, Eigen::ColMajor>, Eigen::COLAMDOrdering<int> >   lu;

// Debug
  Eigen::SparseMatrix<T> NA;
  Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> NB;

min_size.h // Determine min size of lists in a vector
// Template:
// T some list type object that implements .size()
// Inputs:
// V vector of list types T
// Returns min .size() found in V, returns -1 if V is empty
  template <typename T>
  IGL_INLINE int min_size(const std::vector<T> & V);

mode.h // Takes mode of coefficients in a matrix along a given dension
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// X m by n original matrix
// d dension along which to take mode, m or n
// Outputs:
// M vector containing mode along dension d, if d==1 then this will be a
// n-long vector if d==2 then this will be a m-long vector
  template <typename T>
  IGL_INLINE void mode(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
    const int d, 
    Eigen::Matrix<T,Eigen::Dynamic,1> & M);

moveFV.h // moveFV
// Move a scalar field defined on faces to vertices by averaging
//
// Input:
// V,F: mesh
// S: scalar field defined on faces, Fx1
//
// Output:
// SV: scalar field defined on vertices
  template <typename T, typename I>
  IGL_INLINE void moveFV(
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
    const Eigen::Matrix<I, Eigen::Dynamic, Eigen::Dynamic> &F,
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &S,
    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV);

mvc.h // MVC - MEAN VALUE COORDINATES
//
// mvc(V,C,W)
//
// Inputs:
// V #V x dim list of vertex positions (dim = 2 or dim = 3)
// C #C x dim list of polygon vertex positions in counter-clockwise order
// (dim = 2 or dim = 3)
//
// Outputs:
// W weights, #V by #C matrix of weights
//
// Known Bugs: implementation is listed as "Broken"
  IGL_INLINE void mvc(
    const Eigen::MatrixXd &V, 
    const Eigen::MatrixXd &C, 
    Eigen::MatrixXd &W);

normalize_quat.h // Normalize a quaternion
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// q input quaternion
// Outputs:
// out result of normalization, allowed to be same as q
// Returns true on success, false if len(q) < EPS
  template <typename Q_type>
  IGL_INLINE bool normalize_quat(
    const Q_type *q,
    Q_type *out);

normalize_row_lengths.h // Normalize the rows in A so that their lengths are each 1 and place the new
// entries in B
// Inputs:
// A #rows by k input matrix
// Outputs:
// B #rows by k input matrix, can be the same as A
  template <typename DerivedV>
  IGL_INLINE void normalize_row_lengths(
   const Eigen::PlainObjectBase<DerivedV>& A,
   Eigen::PlainObjectBase<DerivedV> & B);

normalize_row_sums.h // Normalize the rows in A so that their sums are each 1 and place the new
// entries in B
// Inputs:
// A #rows by k input matrix
// Outputs:
// B #rows by k input matrix, can be the same as A
  template <typename DerivedA, typename DerivedB>
  IGL_INLINE void normalize_row_sums(
    const Eigen::MatrixBase<DerivedA>& A,
    Eigen::MatrixBase<DerivedB> & B);

on_boundary.h // BOUNDARY_FACES Determine boundary faces of tetrahedra stored in T
//
// Templates:
// IntegerT integer-value: i.e. int
// IntegerF integer-value: i.e. int
// Input:
// T tetrahedron index list, m by 4, where m is the number of tetrahedra
// Output:
// I m long list of bools whether tet is on boundary
// C m by 4 list of bools whether opposite face is on boundary
//
  template <typename IntegerT>
  IGL_INLINE void on_boundary(
    const std::vector<std::vector<IntegerT> > & T,
    std::vector<bool> & I,
    std::vector<std::vector<bool> > & C);

#ifndef IGL_NO_EIGEN

// Templates:
// DerivedT integer-value: i.e. from MatrixXi
// DerivedI bool-value: i.e. from MatrixXi
// DerivedC bool-value: i.e. from MatrixXi
  template <typename DerivedT, typename DerivedI, typename DerivedC>
  IGL_INLINE void on_boundary(
    const Eigen::PlainObjectBase<DerivedT>& T,
    Eigen::PlainObjectBase<DerivedI>& I,
    Eigen::PlainObjectBase<DerivedC>& C);
#endif

orth.h // ORTH Orthogonalization.
// ORTH(A,Q) produces Q as an orthonormal basis for the range of A.
// That is, Q'*Q = I, the columns of Q span the same space as
// the columns of A, and the number of columns of Q is the
// rank of A.
//
//
// The algorithm uses singular value decomposition, SVD, instead of orthogonal
// factorization, QR. This doubles the computation time, but
// provides more reliable and consistent rank determination.
// Closely follows MATLAB implementation in orth.m
//
// Inputs:
// A m by n matrix
// Outputs:
// Q m by n matrix with orthonormal columns spanning same column space as
// A
//
// Known bugs: Implementation listed as "Broken"
  IGL_INLINE void orth(const Eigen::MatrixXd &A, Eigen::MatrixXd &Q);

pathinfo.h //// Decided not to use these
//const int PATHINFO_DIRNAME 01
//const int PATHINFO_BASENAME 02
//const int PATHINFO_EXTENSION 04
//const int PATHINFO_FILENAME 08
// Function like PHP's pathinfo
// returns information about path
// Input:
// path string containing input path
// Outputs:
// dirname string containing dirname (see dirname.h)
// basename string containing basename (see basename.h)
// extension string containing extension (characters after last '.')
// filename string containing extension (characters of basename before last
// '.')
//
// See also: basename, dirname
  IGL_INLINE void pathinfo(
    const std::string & path,
    std::string & dirname,
    std::string & basename,
    std::string & extension,
    std::string & filename);

per_corner_normals.h // Compute vertex normals via vertex position list, face list
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// corner_threshold threshold in degrees on sharp angles
// Output:
// CN #F*3 by 3 eigen Matrix of mesh vertex 3D normals, where the normal
// for corner F(i,j) is at CN(i*3+j,:)
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void per_corner_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const double corner_threshold,
    Eigen::PlainObjectBase<DerivedV> & CN);

// Other Inputs:
// FN #F by 3 eigen Matrix of face normals
  template <
    typename DerivedV, 
    typename DerivedF, 
    typename DerivedFN, 
    typename DerivedCN>
  IGL_INLINE void per_corner_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const Eigen::PlainObjectBase<DerivedFN>& FN,
    const double corner_threshold,
    Eigen::PlainObjectBase<DerivedCN> & CN);

// Other Inputs:
// VF map from vertices to list of incident faces
  template <typename DerivedV, typename DerivedF, typename IndexType>
  IGL_INLINE void per_corner_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const Eigen::PlainObjectBase<DerivedV>& FN,
    const std::vector<std::vector<IndexType> >& VF,
    const double corner_threshold,
    Eigen::PlainObjectBase<DerivedV> & CN);

per_face_normals.h // Compute face normals via vertex position list, face list
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// Output:
// N #F by 3 eigen Matrix of mesh face (triangle) 3D normals
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void per_face_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedV> & N);

per_vertex_attribute_smoothing.h // Smooth vertex attributes using uniform Laplacian
// Inputs:
// Ain #V by #A eigen Matrix of mesh vertex attributes (each vertex has #A attributes)
// F #F by 3 eigne Matrix of face (triangle) indices
// Output:
// Aout #V by #A eigen Matrix of mesh vertex attributes
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void per_vertex_attribute_smoothing(
    const Eigen::PlainObjectBase<DerivedV>& Ain,
    const Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedV> & Aout);

per_vertex_normals.h // Compute vertex normals via vertex position list, face list
// Inputs:
// V #V by 3 eigen Matrix of mesh vertex 3D positions
// F #F by 3 eigne Matrix of face (triangle) indices
// Output:
// N #V by 3 eigen Matrix of mesh vertex 3D normals
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void per_vertex_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedV> & N);

  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void per_vertex_normals(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const Eigen::PlainObjectBase<DerivedV>& FN,
    Eigen::PlainObjectBase<DerivedV> & N);

plot_vector.h // Not clear what these are supposed to be doing. Currently they print
// vectors to standard error...
  template <typename T>
  IGL_INLINE void plot_vector( std::vector<T>& v);
  template <typename T>
  IGL_INLINE void plot_vector( std::vector< std::vector<T> >& v);
  template <typename T>
  IGL_INLINE void plot_vector(std::vector< std::vector< std::vector<T> > >& v);

point_in_circle.h // Determine if 2d point is in a circle
// Inputs:
// qx x-coordinate of query point
// qy y-coordinate of query point
// cx x-coordinate of circle center
// cy y-coordinate of circle center
// r radius of circle
// Returns true if query point is in circle, false otherwise
  IGL_INLINE bool point_in_circle(
    const double qx, 
    const double qy,
    const double cx, 
    const double cy,
    const double r);

project.h // Wrapper for gluProject that uses the current GL_MODELVIEW_MATRIX,
// GL_PROJECTION_MATRIX, and GL_VIEWPORT
// Inputs:
// obj* 3D objects' x, y, and z coordinates respectively
// Outputs:
// win* pointers to screen space x, y, and z coordinates respectively
// Returns return value of gluProject call
  IGL_INLINE int project(
    const double objX,
    const double objY,
    const double objZ,
    double* winX,
    double* winY,
    double* winZ);

project_to_line.h // PROJECT_TO_LINES project points onto vectors, that is find the paramter
// t for a point p such that proj_p = (y-x).*t, additionally compute the
// squared distance from p to the line of the vector, such that
// |p - proj_p|² = sqr_d
//
// [T,sqrD] = project_to_lines(P,S,D)
//
// Templates:
// MatP matrix template for P, implementing .cols(), .rows()
// MatL matrix template for S and D, implementing .size(), .array(), .sum()
// Matt matrix template for t
// MatsqrD matrix template for sqrD
// Inputs:
// P #P by dim list of points to be projected
// S size dim start position of line vector
// D size dim destination position of line vector
// Outputs:
// T #P by 1 list of parameters
// sqrD #P by 1 list of squared distances
//
// Copyright 2011, Alec Jacobson (jacobson@inf.ethz.ch)
//
  template <
    typename MatP, 
    typename MatL, 
    typename Matt, 
    typename MatsqrD>
  IGL_INLINE void project_to_line(
    const MatP & P,
    const MatL & S,
    const MatL & D,
    Matt & t,
    MatsqrD & sqrD);

// Same as above but for a single query point
  template <typename Scalar>
  IGL_INLINE void project_to_line(
    const Scalar px,
    const Scalar py,
    const Scalar pz,
    const Scalar sx,
    const Scalar sy,
    const Scalar sz,
    const Scalar dx,
    const Scalar dy,
    const Scalar dz,
    Scalar & projpx,
    Scalar & projpy,
    Scalar & projpz,
    Scalar & t,
    Scalar & sqrd);

// Same as above but for a single query point
  template <typename Scalar>
  IGL_INLINE void project_to_line(
    const Scalar px,
    const Scalar py,
    const Scalar pz,
    const Scalar sx,
    const Scalar sy,
    const Scalar sz,
    const Scalar dx,
    const Scalar dy,
    const Scalar dz,
    Scalar & t,
    Scalar & sqrd);

quat_conjugate.h // Compute conjugate of given quaternion
// http://en.wikipedia.org/wiki/Quaternion#Conjugation.2C_the_norm.2C_and_reciprocal
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// q1 input quaternion
// Outputs:
// out result of conjugation, allowed to be same as input
  template <typename Q_type>
  IGL_INLINE void quat_conjugate(
    const Q_type *q1, 
    Q_type *out);

quat_mult.h // Computes out = q1 * q2 with quaternion multiplication
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// q1 left quaternion
// q2 right quaternion
// Outputs:
// out result of multiplication
  template <typename Q_type>
  IGL_INLINE void quat_mult(
    const Q_type *q1, 
    const Q_type *q2,
    Q_type *out);

quat_to_axis_angle.h // Convert quat representation of a rotation to axis angle
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// q quaternion
// Outputs:
// axis 3d vector
// angle scalar in radians
  template <typename Q_type>
  IGL_INLINE void quat_to_axis_angle(
    const Q_type *q,
    Q_type *axis, 
    Q_type & angle);

// Wrapper with angle in degrees
  template <typename Q_type>
  IGL_INLINE void quat_to_axis_angle_deg(
    const Q_type *q,
    Q_type *axis, 
    Q_type & angle);

quat_to_mat.h // Convert a quaternion to a 4x4 matrix
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Input:
// quat pointer to four elements of quaternion (x,y,z,w)
// Output:
// mat pointer to 16 elements of matrix
  template <typename Q_type>
  IGL_INLINE void quat_to_mat(const Q_type * quat, Q_type * mat);

read.h // read mesh from an ascii file with automatic detection of file format. supported: obj, off)
// Templates:
// Scalar type for positions and vectors (will be read as double and cast
// to Scalar)
// Index type for indices (will be read as int and cast to Index)
// Inputs:
// Inputs:
// str path to .obj/.off file
// Outputs:
// V eigen double matrix #V by 3
// F eigen int matrix #F by 3
  template <typename Scalar, typename Index>
  IGL_INLINE bool read(
    const std::string str,
    std::vector<std::vector<Scalar> > & V,
    std::vector<std::vector<Index> > & F);
#ifndef IGL_NO_EIGEN
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool read(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedF>& F);
#endif

readDMAT.h // Read a matrix from an ascii dmat file
//
// Inputs:
// file_name path to .dmat file
// Outputs:
// W eigen matrix containing read-in coefficients
// Returns true on success, false on error
//
#ifndef IGL_NO_EIGEN
  template <typename DerivedW>
  IGL_INLINE bool readDMAT(const std::string file_name, 
    Eigen::PlainObjectBase<DerivedW> & W);
#endif

// Wrapper for vector of vectors
  template <typename Scalar>
  IGL_INLINE bool readDMAT(
    const std::string file_name, 
    std::vector<std::vector<Scalar> > & W);

readMESH.h // load a tetrahedral volume mesh from a .mesh file
//
// Templates:
// Scalar type for positions and vectors (will be read as double and cast
// to Scalar)
// Index type for indices (will be read as int and cast to Index)
// Input:
// mesh_file_name path of .mesh file
// Outputs:
// V double matrix of vertex positions #V by 3
// T #T list of tet indices into vertex positions
// F #F list of face indices into vertex positions
//
// Known bugs: Holes and regions are not supported
  template <typename Scalar, typename Index>
  IGL_INLINE bool readMESH(
    const std::string mesh_file_name,
    std::vector<std::vector<Scalar > > & V,
    std::vector<std::vector<Index > > & T,
    std::vector<std::vector<Index > > & F);

// Input:
// mesh_file_name path of .mesh file
// Outputs:
// V eigen double matrix #V by 3
// T eigen int matrix #T by 4
// F eigen int matrix #F by 3
  template <typename DerivedV, typename DerivedF, typename DerivedT>
  IGL_INLINE bool readMESH(
    const std::string mesh_file_name,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedT>& T,
    Eigen::PlainObjectBase<DerivedF>& F);

readNODE.h // load a list of points from a .node file
//
// Templates:
// Scalar type for positions and vectors (will be read as double and cast
// to Scalar)
// Index type for indices (will be read as int and cast to Index)
// Input:
// node_file_name path of .node file
// Outputs:
// V double matrix of vertex positions #V by dim
// I list of indices (first tells whether 0 or 1 indexed)
  template <typename Scalar, typename Index>
  IGL_INLINE bool readNODE(
    const std::string node_file_name,
    std::vector<std::vector<Scalar > > & V,
    std::vector<std::vector<Index > > & I);

// Input:
// node_file_name path of .node file
// Outputs:
// V eigen double matrix #V by dim
  template <typename DerivedV, typename DerivedI>
  IGL_INLINE bool readNODE(
    const std::string node_file_name,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedI>& I);

readOBJ.h // Read a mesh from an ascii obj file, filling in vertex positions, normals
// and texture coordinates. Mesh may have faces of any number of degree
//
// Templates:
// Scalar type for positions and vectors (will be read as double and cast
// to Scalar)
// Index type for indices (will be read as int and cast to Index)
// Inputs:
// str path to .obj file
// Outputs:
// V double matrix of vertex positions #V by 3
// F #F list of face indices into vertex positions
// TC double matrix of texture coordinats #TC by 2
// FTC #F list of face indices into vertex texture coordinates
// N double matrix of corner normals #N by 3
// FN #F list of face indices into vertex normals
// Returns true on success, false on errors
  template <typename Scalar, typename Index>
  IGL_INLINE bool readOBJ(
    const std::string obj_file_name, 
    std::vector<std::vector<Scalar > > & V,
    std::vector<std::vector<Scalar > > & TC,
    std::vector<std::vector<Scalar > > & N,
    std::vector<std::vector<Index > > & F,
    std::vector<std::vector<Index > > & FTC,
    std::vector<std::vector<Index > > & FN);

#ifndef IGL_NO_EIGEN

//! Read a mesh from an ascii obj file
// Inputs:
// str path to .obj file
// Outputs:
// V eigen matrix #V by 3
// F eigen matrix #F by 3
//
// KNOWN BUG: This only knows how to read *triangle* meshes. It will probably
// crash or give garbage on anything else.
//
// KNOWN BUG: This only knows how to face lines without normal or texture
// indices. It will probably crash or give garbage on anything else.
//
// KNOWN BUG: The order of the attributes is different than the vector
// version above
  template <typename DerivedV, typename DerivedF, typename DerivedT>
  IGL_INLINE bool readOBJ(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedV>& CN,
    Eigen::PlainObjectBase<DerivedF>& FN,
    Eigen::PlainObjectBase<DerivedT>& TC,
    Eigen::PlainObjectBase<DerivedF>& FTC);

//! Read a poly mesh from an ascii obj file
// Inputs:
// str path to .obj file
// Outputs:
// V eigen matrix #V by 3
// POLYF vector of vector with face indices
//
//
// KNOWN BUG: This only knows how to face lines without normal or texture
// indices. It will probably crash or give garbage on anything else.
//
// KNOWN BUG: The order of the attributes is different than the vector
// version above
  template <
    typename DerivedV, 
    typename DerivedF, 
    typename DerivedT, 
    typename Index>
  IGL_INLINE bool readOBJPoly(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    std::vector<std::vector<Index> >& F,
    Eigen::PlainObjectBase<DerivedV>& CN,
    Eigen::PlainObjectBase<DerivedF>& FN,
    Eigen::PlainObjectBase<DerivedT>& TC,
    Eigen::PlainObjectBase<DerivedF>& FTC);

//! Read a mesh from an ascii obj file
// Inputs:
// str path to .obj file
// Outputs:
// V eigen matrix #V by 3
// F eigen matrix #F by 3
//
// KNOWN BUG: This only knows how to read *triangle* meshes. It will probably
// crash or give garbage on anything else.
//
// KNOWN BUG: This only knows how to face lines without normal or texture
// indices. It will probably crash or give garbage on anything else.
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool readOBJ(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedF>& F);
#endif

readOFF.h // Read a mesh from an ascii obj file, filling in vertex positions, normals
// and texture coordinates. Mesh may have faces of any number of degree
//
// Templates:
// Scalar type for positions and vectors (will be read as double and cast
// to Scalar)
// Index type for indices (will be read as int and cast to Index)
// Inputs:
// str path to .obj file
// Outputs:
// V double matrix of vertex positions #V by 3
// F #F list of face indices into vertex positions
// TC double matrix of texture coordinats #TC by 2
// FTC #F list of face indices into vertex texture coordinates
// N double matrix of corner normals #N by 3
// FN #F list of face indices into vertex normals
// Returns true on success, false on errors
  template <typename Scalar, typename Index>
  IGL_INLINE bool readOFF(
    const std::string off_file_name, 
    std::vector<std::vector<Scalar > > & V,
    std::vector<std::vector<Index > > & F,
    std::vector<std::vector<Scalar > > & N);

#ifndef IGL_NO_EIGEN

// read mesh from a ascii off file
// Inputs:
// str path to .off file
// Outputs:
// V eigen double matrix #V by 3
// F eigen int matrix #F by 3
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool readOFF(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedF>& F);

  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool readOFF(
    const std::string str,
    Eigen::PlainObjectBase<DerivedV>& V,
    Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedV>& N);
#endif

readTGF.h // READTGF
//
// [V,E,P,BE,CE,PE] = readTGF(filename)
//
// Read a graph from a .tgf file
//
// Input:
// filename .tgf file name
// Ouput:
// V # vertices by 3 list of vertex positions
// E # edges by 2 list of edge indices
// P # point-handles list of point handle indices
// BE # bone-edges by 2 list of bone-edge indices
// CE # cage-edges by 2 list of cage-edge indices
// PE # pseudo-edges by 2 list of pseudo-edge indices
//
// Assumes that graph vertices are 3 dimensional
  IGL_INLINE bool readTGF(
    const std::string tgf_filename,
    std::vector<std::vector<double> > & C,
    std::vector<std::vector<int> > & E,
    std::vector<int> & P,
    std::vector<std::vector<int> > & BE,
    std::vector<std::vector<int> > & CE,
    std::vector<std::vector<int> > & PE);

  #ifndef IGL_NO_EIGEN
  IGL_INLINE bool readTGF(
    const std::string tgf_filename,
    Eigen::MatrixXd & C,
    Eigen::MatrixXi & E,
    Eigen::VectorXi & P,
    Eigen::MatrixXi & BE,
    Eigen::MatrixXi & CE,
    Eigen::MatrixXi & PE);
  #endif

remove_duplicate_vertices.h // REMOVE_DUPLICATE_VERTICES Remove duplicate vertices upto a uniqueness
// tolerance (epsilon)
//
// Inputs:
// V #V by dim list of vertex positions
// epsilon uniqueness tolerance (significant digit), can probably think of
// this as a tolerance on L1 distance
// Outputs:
// SV #SV by dim new list of vertex positions
// SVI #V by 1 list of indices so SV = V(SVI,:)
// SVJ #SV by 1 list of indices so V = SV(SVJ,:)
//
// Example:
// % Mesh in (V,F)
// [SV,SVI,SVJ] = remove_duplicate_vertices(V,1e-7);
// % remap faces
// SF = SVJ(F);
//
  template <
    typename DerivedV, 
    typename DerivedSV, 
    typename DerivedSVI, 
    typename DerivedSVJ>
  IGL_INLINE void remove_duplicate_vertices(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const double epsilon,
    Eigen::PlainObjectBase<DerivedSV>& SV,
    Eigen::PlainObjectBase<DerivedSVI>& SVI,
    Eigen::PlainObjectBase<DerivedSVJ>& SVJ);

// Wrapper that also remaps given faces (F) --> (SF) so that SF index SV
  template <
    typename DerivedV, 
    typename DerivedF,
    typename DerivedSV, 
    typename DerivedSVI, 
    typename DerivedSVJ,
    typename DerivedSF>
  IGL_INLINE void remove_duplicate_vertices(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const double epsilon,
    Eigen::PlainObjectBase<DerivedSV>& SV,
    Eigen::PlainObjectBase<DerivedSVI>& SVI,
    Eigen::PlainObjectBase<DerivedSVJ>& SVJ,
    Eigen::PlainObjectBase<DerivedSF>& SF);

removeDuplicates.h // [ NV, NF ] = removeDuplicates( V,F,epsilon )
// Merge the duplicate vertices from V, fixing the topology accordingly
//
// Input:
// V,F: mesh description
// epsilon: minimal distance to consider two vertices identical
//
// Output:
// NV, NF: new mesh without duplicate vertices
// template <typename T, typename S>
// IGL_INLINE void removeDuplicates(
// const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
// const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &F,
// Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &NV,
// Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &NF,
// Eigen::Matrix<S, Eigen::Dynamic, 1> &I,
// const double epsilon = 2.2204e-15);
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void removeDuplicates(
    const Eigen::PlainObjectBase<DerivedV> &V,
    const Eigen::PlainObjectBase<DerivedF> &F,
    Eigen::PlainObjectBase<DerivedV> &NV,
    Eigen::PlainObjectBase<DerivedF> &NF,
    Eigen::Matrix<typename DerivedF::Scalar, Eigen::Dynamic, 1> &I,
    const double epsilon = 2.2204e-15);

removeUnreferenced.h // [ NV, NF ] = removeUnreferenced( V,F,epsilon )
// Remove unreferenced vertices from V, updating F accordingly
//
// Input:
// V,F: mesh description
//
// Output:
// NV, NF: new mesh without unreferenced vertices
//
// Known bugs:
// Also removes combinatorially degenerate faces in NF
  template <typename T, typename S>
  IGL_INLINE void removeUnreferenced(
    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
    const Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &F,
    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &NV,
    Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic> &NF,
    Eigen::Matrix<S, Eigen::Dynamic, 1> &I);

render_to_tga.h // Render current open GL image to .tga file
// Inputs:
// tga_file path to output .tga file
// width width of scene and resulting image
// height height of scene and resulting image
/// alpha whether to include alpha channel
// Returns true only if no errors occured
//
// See also: png/render_to_png which is slower but writes .png files
  IGL_INLINE bool render_to_tga(
    const std::string tga_file,
    const int width,
    const int height,
    const bool alpha);

reorder.h // Act like matlab's Y = X[I] for std vectors
// where I contains a vector of indices so that after,
// Y[j] = X[I[j]] for index j
// this implies that Y.size() == I.size()
// X and Y are allowed to be the same reference
  template< class T >
  IGL_INLINE void reorder(
    const std::vector<T> & unordered,
    std::vector<size_t> const & index_map,
    std::vector<T> & ordered);

repdiag.h // REPDIAG repeat a matrix along the diagonal a certain number of times, so
// that if A is a m by n matrix and we want to repeat along the diagonal d
// times, we get a m*d by n*d matrix B such that:
// B( (k*m+1):(k*m+1+m-1), (k*n+1):(k*n+1+n-1)) = A
// for k from 0 to d-1
//
// Inputs:
// A m by n matrix we are repeating along the diagonal. May be dense or
// sparse
// d number of times to repeat A along the diagonal
// Outputs:
// B m*d by n*d matrix with A repeated d times along the diagonal,
// will be dense or sparse to match A
//
// Sparse version
  template <typename T>
  IGL_INLINE void repdiag(
    const Eigen::SparseMatrix<T>& A,
    const int d,
    Eigen::SparseMatrix<T>& B);

// Dense version
  template <typename T>
  IGL_INLINE void repdiag(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & A,
    const int d,
    Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & B);

// Wrapper with B as output
  template <class Mat>
  IGL_INLINE Mat repdiag(const Mat & A, const int d);

repmat.h // Ideally this is a super overloaded function that behaves just like
// matlab's repmat
// Replicate and tile a matrix
//
// Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// A m by n input matrix
// r number of row-direction copies
// c number of col-direction copies
// Outputs:
// B r*m by c*n output matrix
//
  template <typename DerivedA,typename DerivedB>
  IGL_INLINE void repmat(
    const Eigen::PlainObjectBase<DerivedA> & A,
    const int r,
    const int c,
    Eigen::PlainObjectBase<DerivedB> & B);
  template <typename T>
  IGL_INLINE void repmat(
    const Eigen::SparseMatrix<T> & A,
    const int r,
    const int c,
    Eigen::SparseMatrix<T> & B);

report_gl_error.h // Print last OpenGL error to stderr prefixed by specified id string
// Inputs:
// id string to appear before any error msgs
// Returns result of glGetError()
  IGL_INLINE GLenum report_gl_error(const std::string id);

// No prefix
  IGL_INLINE GLenum report_gl_error();

rgb_to_hsv.h // Convert RGB to HSV
//
// Inputs:
// r red value ([0,1])
// g green value ([0,1])
// b blue value ([0,1])
// Outputs:
// h hue value (degrees: [0,360])
// s saturation value ([0,1])
// v value value ([0,1])
  template <typename R,typename H>
  void rgb_to_hsv(const R * rgb, H * hsv);

right_axis.h // Determines the right axis or depth axis of the current gl matrix
// Outputs:
// x pointer to x-coordinate in scene coordinates of the un-normalized
// right axis
// y pointer to y-coordinate in scene coordinates of the un-normalized
// right axis
// z pointer to z-coordinate in scene coordinates of the un-normalized
// right axis
// mv pointer to modelview matrix
//
// Note: Right axis is returned *UN-normalized*
  IGL_INLINE void right_axis(double * x, double * y, double * z);
  IGL_INLINE void right_axis(const double * mv, double * x, double * y, double * z);

rotate_by_quat.h // Compute rotation of a given vector/point by a quaternion
// A Quaternion, q, is defined here as an arrays of four scalars (x,y,z,w),
// such that q = x*i + y*j + z*k + w
// Inputs:
// v input 3d point/vector
// q input quaternion
// Outputs:
// out result of rotation, allowed to be same as v
  template <typename Q_type>
  IGL_INLINE void rotate_by_quat(
    const Q_type *v,
    const Q_type *q, 
    Q_type *out);

round.h // Round a scalar value
//
// Inputs:
// x number
// Returns x rounded to integer
  template <typename DerivedX>
  DerivedX round(const DerivedX r);

// Round a given matrix to nearest integers
//
// Inputs:
// X m by n matrix of scalars
// Outputs:
// Y m by n matrix of rounded integers
  template < typename DerivedX, typename DerivedY>
  IGL_INLINE void round(
    const Eigen::PlainObjectBase<DerivedX>& X,
    Eigen::PlainObjectBase<DerivedY>& Y);

rows_to_matrix.h // Convert a list (std::vector) of row vectors of the same length to a matrix
// Template:
// Row row vector type, must implement:
// .size()
// Mat Matrix type, must implement:
// .resize(m,n)
// .row(i) = Row
// Inputs:
// V a m-long list of vectors of size n
// Outputs:
// M an m by n matrix
// Returns true on success, false on errors
  template <class Row, class Mat>
  IGL_INLINE bool rows_to_matrix(const std::vector<Row> & V,Mat & M);

sample_edges.h // Compute samples_per_edge extra points along each edge in E defined over
// vertices of V.
//
// Inputs:
// V vertices over which edges are defined, # vertices by dim
// E edge list, # edges by 2
// k number of extra samples to be computed along edge not
// including start and end points
// Output:
// S sampled vertices, size less than # edges * (2+k) by dim always begins
// with V so that E is also defined over S
  void sample_edges(
    const Eigen::MatrixXd & V,
    const Eigen::MatrixXi & E,
    const int k,
    Eigen::MatrixXd & S);

slice.h // THIS MAY HAVE BEEN SUPERSEDED BY EIGEN'S select FUNCTION
//
// Act like the matlab X(row_indices,col_indices) operator
//
// Inputs:
// X m by n matrix
// R list of row indices
// C list of column indices
// Output:
// Y #R by #C matrix
  template <typename T>
  IGL_INLINE void slice(
    const Eigen::SparseMatrix<T>& X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
    Eigen::SparseMatrix<T>& Y);

// Wrapper to only slice in one direction
//
// Inputs:
// dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R)
  template <typename T>
  IGL_INLINE void slice(
    const Eigen::SparseMatrix<T>& X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    const int dim,
    Eigen::SparseMatrix<T>& Y);

  template <typename DerivedX>
  IGL_INLINE void slice(
    const Eigen::PlainObjectBase<DerivedX> & X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
    Eigen::PlainObjectBase<DerivedX> & Y);

  template <typename DerivedX>
  IGL_INLINE void slice(
    const Eigen::PlainObjectBase<DerivedX> & X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    Eigen::PlainObjectBase<DerivedX> & Y);

slice_into.h // Act like the matlab Y(row_indices,col_indices) = X
//
// Inputs:
// X xm by xn rhs matrix
// R list of row indices
// C list of column indices
// Y ym by yn lhs matrix
// Output:
// Y ym by yn lhs matrix, same as input but Y(R,C) = X
  template <typename T>
  IGL_INLINE void slice_into(
    const Eigen::SparseMatrix<T>& X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
    Eigen::SparseMatrix<T>& Y);

  template <typename DerivedX>
  IGL_INLINE void slice_into(
    const Eigen::PlainObjectBase<DerivedX> & X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
    Eigen::PlainObjectBase<DerivedX> & Y);

  template <typename DerivedX>
  IGL_INLINE void slice_into(
    const Eigen::PlainObjectBase<DerivedX> & X,
    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
    Eigen::PlainObjectBase<DerivedX> & Y);

snap_to_canonical_view_quat.h // Snap a given quaternion to the "canonical quaternion" rotations.
// Inputs:
// q input quaternion
// threshold threshold between 0 and 1, where 0 means
  template <typename Q_type>
  IGL_INLINE bool snap_to_canonical_view_quat(
    const Q_type q[4],
    const Q_type threshold,
    Q_type s[4]);

sort.h // Sort the elements of a matrix X along a given dimension like matlabs sort
// function
//
// Templates:
// DerivedX derived scalar type, e.g. MatrixXi or MatrixXd
// DerivedIX derived integer type, e.g. MatrixXi
// Inputs:
// X m by n matrix whose entries are to be sorted
// dim dimensional along which to sort:
// 1 sort each column (matlab default)
// 2 sort each row
// ascending sort ascending (true, matlab default) or descending (false)
// Outputs:
// Y m by n matrix whose entries are sorted
// IX m by n matrix of indices so that if dim = 1, then in matlab notation
// for j = 1:n, Y(:,j) = X(I(:,j),j); end
  template <typename DerivedX, typename DerivedIX>
  IGL_INLINE void sort(
    const Eigen::PlainObjectBase<DerivedX>& X,
    const int dim,
    const bool ascending,
    Eigen::PlainObjectBase<DerivedX>& Y,
    Eigen::PlainObjectBase<DerivedIX>& IX);
  template <typename DerivedX, typename DerivedIX>

// Only better if size(X,dim) is small
  IGL_INLINE void sort_new(
    const Eigen::PlainObjectBase<DerivedX>& X,
    const int dim,
    const bool ascending,
    Eigen::PlainObjectBase<DerivedX>& Y,
    Eigen::PlainObjectBase<DerivedIX>& IX);

// Special case if size(X,dim) == 2
  template <typename DerivedX, typename DerivedIX>
  IGL_INLINE void sort2(
    const Eigen::PlainObjectBase<DerivedX>& X,
    const int dim,
    const bool ascending,
    Eigen::PlainObjectBase<DerivedX>& Y,
    Eigen::PlainObjectBase<DerivedIX>& IX);

// Act like matlab's [Y,I] = SORT(X) for std library vectors
// Templates:
// T should be a class that implements the '<' comparator operator
// Input:
// unsorted unsorted vector
// ascending sort ascending (true, matlab default) or descending (false)
// Output:
// sorted sorted vector, allowed to be same as unsorted
// index_map an index map such that sorted[i] = unsorted[index_map[i]]
  template <class T>
  IGL_INLINE void sort(
      const std::vector<T> &unsorted,
      const bool ascending,
      std::vector<T> &sorted,
      std::vector<size_t> &index_map);

sortrows.h // Act like matlab's [Y,I] = sortrows(X)
//
// Templates:
// DerivedX derived scalar type, e.g. MatrixXi or MatrixXd
// DerivedIX derived integer type, e.g. MatrixXi
// Inputs:
// X m by n matrix whose entries are to be sorted
// ascending sort ascending (true, matlab default) or descending (false)
// Outputs:
// Y m by n matrix whose entries are sorted
// IX m by n matrix of indices so that if dim = 1, then in matlab notation
// for j = 1:n, Y(:,j) = X(I(:,j),j); end
  template <typename DerivedX, typename DerivedIX>
  IGL_INLINE void sortrows(
    const Eigen::PlainObjectBase<DerivedX>& X,
    const bool ascending,
    Eigen::PlainObjectBase<DerivedX>& Y,
    Eigen::PlainObjectBase<DerivedIX>& IX);

sparse.h // Build a sparse matrix from list of indices and values (I,J,V), functions
// like the sparse function in matlab
//
// Templates:
// IndexVector list of indices, value should be non-negative and should
// expect to be cast to an index. Must implement operator(i) to retrieve
// ith element
// ValueVector list of values, value should be expect to be cast to type
// T. Must implement operator(i) to retrieve ith element
// T should be a eigen sparse matrix primitive type like int or double
// Input:
// I nnz vector of row indices of non zeros entries in X
// J nnz vector of column indices of non zeros entries in X
// V nnz vector of non-zeros entries in X
// Optional:
// m number of rows
// n number of cols
// Outputs:
// X m by n matrix of type T whose entries are to be found
//
  template <class IndexVector, class ValueVector, typename T>
  IGL_INLINE void sparse(
    const IndexVector & I,
    const IndexVector & J,
    const ValueVector & V,
    Eigen::SparseMatrix<T>& X);
  template <class IndexVector, class ValueVector, typename T>
  IGL_INLINE void sparse(
    const IndexVector & I,
    const IndexVector & J,
    const ValueVector & V,
    const size_t m,
    const size_t n,
    Eigen::SparseMatrix<T>& X);

// THIS MAY BE SUPERSEDED BY EIGEN'S .sparseView Indeed it is.
// Convert a full, dense matrix to a sparse one
//
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Input:
// D m by n full, dense matrix
// Output:
// X m by n sparse matrix
  template <typename DerivedD, typename T>
  IGL_INLINE void sparse(
    const Eigen::PlainObjectBase<DerivedD>& D,
    Eigen::SparseMatrix<T>& X);

// Wrapper with return
  template <typename DerivedD>
  IGL_INLINE Eigen::SparseMatrix<typename DerivedD::Scalar > sparse(
    const Eigen::PlainObjectBase<DerivedD>& D);

speye.h // Builds an m by n sparse identity matrix like matlab's speye function
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// m number of rows
// n number of cols
// Outputs:
// I m by n sparse matrix with 1's on the main diagonal
  template <typename T>
  IGL_INLINE void speye(const int n,const int m, Eigen::SparseMatrix<T> & I);

// Builds an n by n sparse identity matrix like matlab's speye function
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// n number of rows and cols
// Outputs:
// I n by n sparse matrix with 1's on the main diagonal
  template <typename T>
  IGL_INLINE void speye(const int n, Eigen::SparseMatrix<T> & I);

stdin_to_temp.h // Write stdin/piped input to a temporary file which can than be preprocessed as it
// is (a normal file). This is often useful if you want to process stdin/piped
// with library functions that expect to be able to fseek(), rewind() etc..
//
// If your application is not using fseek(), rewind(), etc. but just reading
// from stdin then this will likely cause a bottle neck as it defeats the whole
// purpose of piping.
//
// Outputs:
// temp_file pointer to temp file pointer, rewound to beginning of file so
// its ready to be read
// Return true only if no errors were found
//
// Note: Caller is responsible for closing the file (tmpfile() automatically
// unlinks the file so there is no need to remove/delete/unlink the file)
  IGL_INLINE bool stdin_to_temp(FILE ** temp_file);

sum.h // Note: If your looking for dense matrix matlab like sum for eigen matrics
// just use:
// M.colwise().sum() or M.rowwise().sum()
//
// Sum the columns or rows of a sparse matrix
// Templates:
// T should be a eigen sparse matrix primitive type like int or double
// Inputs:
// X m by n sparse matrix
// dim dimension along which to sum (1 or 2)
// Output:
// S n-long sparse vector (if dim == 1)
// or
// S m-long sparse vector (if dim == 2)
  template <typename T>
  IGL_INLINE void sum(
    const Eigen::SparseMatrix<T>& X, 
    const int dim,
    Eigen::SparseVector<T>& S);

svd.h// // Compute 3x3 SVD using lapack's dgesdd_ function
// //
// // Input:
// // a pointer to 3x3 matrix in COLUMN MAJOR order
// // Outputs:
// // u pointer to 3x3 matrix in COLUMN MAJOR order
// // s pointer to 3 vector
// // vt pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in
// // row-major order
// // Returns true on success, false on failure
// //
// // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen
// bool svd3x3(double * a, double * u, double * s, double * vt);
texture_from_tga.h // Read an image from a .tga file and use it as a texture
//
// Input:
// tga_file path to .tga file
// Output:
// id of generated openGL texture
// Returns true on success, false on failure
  IGL_INLINE bool texture_from_tga(const std::string tga_file, GLuint & id);

tga.h




extern gliGenericImage *gliReadTGA(FILE *fp, char *name, int hflip, int vflip);
int gli_verbose(int new_verbose);
extern int gliVerbose(int newVerbose);

void writeTGA( gliGenericImage* image, FILE *fp);




trackball.h // Applies a trackball drag to identity
// Inputs:
// w width of the trackball context
// h height of the trackball context
// speed_factor controls how fast the trackball feels, 1 is normal
// down_mouse_x x position of mouse down
// down_mouse_y y position of mouse down
// mouse_x current x position of mouse
// mouse_y current y position of mouse
// Outputs:
// quat the resulting rotation (as quaternion)
  template <typename Q_type>
  IGL_INLINE void trackball(
    const int w,
    const int h,
    const Q_type speed_factor,
    const int down_mouse_x,
    const int down_mouse_y,
    const int mouse_x,
    const int mouse_y,
    Q_type * quat);

// Applies a trackball drag to a given rotation
// Inputs:
// w width of the trackball context
// h height of the trackball context
// speed_factor controls how fast the trackball feels, 1 is normal
// down_quat rotation at mouse down, i.e. the rotation we're applying the
// trackball motion to (as quaternion)
// down_mouse_x x position of mouse down
// down_mouse_y y position of mouse down
// mouse_x current x position of mouse
// mouse_y current y position of mouse
// Outputs:
// quat the resulting rotation (as quaternion)
  template <typename Q_type>
  IGL_INLINE void trackball(
    const int w,
    const int h,
    const Q_type speed_factor,
    const Q_type * down_quat,
    const int down_mouse_x,
    const int down_mouse_y,
    const int mouse_x,
    const int mouse_y,
    Q_type * quat);

transpose_blocks.h // Templates:
// T should be a eigen matrix primitive type like int or double
// Inputs:
// A m*k by n (dim: 1) or m by n*k (dim: 2) eigen Matrix of type T values
// k number of blocks
// dim dimension in which to transpose
// Output
// B n*k by m (dim: 1) or n by m*k (dim: 2) eigen Matrix of type T values,
// NOT allowed to be the same as A
//
// Example:
// A = [
// 1 2 3 4
// 5 6 7 8
// 101 102 103 104
// 105 106 107 108
// 201 202 203 204
// 205 206 207 208];
// transpose_blocks(A,1,3,B);
// B -> [
// 1 5
// 2 6
// 3 7
// 4 8
// 101 105
// 102 106
// 103 107
// 104 108
// 201 205
// 202 206
// 203 207
// 204 208];
//
  template <typename T>
  IGL_INLINE void transpose_blocks(
    const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & A,
    const size_t k,
    const size_t dim,
    Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & B);

tt.h // Preprocessing
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE void tt_preprocess(const Eigen::PlainObjectBase<DerivedV>& V,
                                const Eigen::PlainObjectBase<DerivedF>& F,
                                std::vector<std::vector<int> >& TTT);

// Extract the face adjacencies
  template <typename DerivedF, typename DerivedTT>
  IGL_INLINE void tt_extractTT(const Eigen::PlainObjectBase<DerivedF>& F,
                               std::vector<std::vector<int> >& TTT,
                               Eigen::PlainObjectBase<DerivedTT>& TT);

// Extract the face adjacencies indices (needed for fast traversal)
  template <typename DerivedF, typename DerivedTT>
  IGL_INLINE void tt_extractTTi(const Eigen::PlainObjectBase<DerivedF>& F,
                                std::vector<std::vector<int> >& TTT,
                                Eigen::PlainObjectBase<DerivedTT>& TTi);

// Compute triangle-triangle adjacency
  template <typename DerivedV, typename DerivedF, typename DerivedTT>
  IGL_INLINE void tt(const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     Eigen::PlainObjectBase<DerivedTT>& TT);

// Compute triangle-triangle adjacency with indices
  template <typename DerivedV, typename DerivedF, typename DerivedTT>
  IGL_INLINE void tt(const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     Eigen::PlainObjectBase<DerivedTT>& TT,
                     Eigen::PlainObjectBase<DerivedTT>& TTi);

uniform_type_to_string.h // Convert a GL uniform variable type (say, returned from
// glGetActiveUniform) and output a string naming that type
// Inputs:
// type enum for given type
// Returns string name of that type
  IGL_INLINE std::string uniform_type_to_string(const GLenum type);

unique.h // Act like matlab's [C,IA,IC] = unique(X)
//
// Templates:
// T comparable type T
// Inputs:
// A #A vector of type T
// Outputs:
// C #C vector of unique entries in A
// IA #A index vector so that C = A(IA);
// IC #C index vector so that A = C(IC);
  template <typename T>
  IGL_INLINE void unique(
    const std::vector<T> & A,
    std::vector<T> & C,
    std::vector<size_t> & IA,
    std::vector<size_t> & IC);

// Act like matlab's [C,IA,IC] = unique(X,'rows')
//
// Templates:
// DerivedA derived scalar type, e.g. MatrixXi or MatrixXd
// DerivedIA derived integer type, e.g. MatrixXi
// DerivedIC derived integer type, e.g. MatrixXi
// Inputs:
// A m by n matrix whose entries are to unique'd according to rows
// Outputs:
// C #C vector of unique rows in A
// IA #A index vector so that C = A(IA,:);
// IC #C index vector so that A = C(IC,:);
  template <typename DerivedA, typename DerivedIA, typename DerivedIC>
  IGL_INLINE void unique_rows(
    const Eigen::PlainObjectBase<DerivedA>& A,
    Eigen::PlainObjectBase<DerivedA>& C,
    Eigen::PlainObjectBase<DerivedIA>& IA,
    Eigen::PlainObjectBase<DerivedIC>& IC);

unique_simplices.h // Find *combinatorially* unique simplices in F
//
// Inputs:
// F #F by simplex-size list of simplices
// Outputs:
// FF #FF by simplex-size list of unique simplices in F
  IGL_INLINE void unique_simplices(
    const Eigen::MatrixXi & F,
    Eigen::MatrixXi & FF);

unproject.h // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX,
// GL_PROJECTION_MATRIX, and GL_VIEWPORT
// Inputs:
// win* screen space x, y, and z coordinates respectively
// Outputs:
// obj* pointers to 3D objects' x, y, and z coordinates respectively
// Returns return value of gluUnProject call
  IGL_INLINE int unproject(
    const double winX,
    const double winY,
    const double winZ,
    double* objX,
    double* objY,
    double* objZ);

unproject_to_zero_plane.h // Wrapper for gluUnproject that uses the current GL_MODELVIEW_MATRIX,
// GL_PROJECTION_MATRIX, and GL_VIEWPORT to unproject a screen postion
// (winX,winY) to a 3d location at same depth as the current origin.
// Inputs:
// win* screen space x, y, and z coordinates respectively
// Outputs:
// obj* pointers to 3D objects' x, y, and z coordinates respectively
// Returns return value of gluUnProject call
  IGL_INLINE int unproject_to_zero_plane(
    const double winX,
    const double winY,
    double* objX,
    double* objY,
    double* objZ);

upsample.h // Subdivide a mesh without moving vertices: loop subdivision but odd
// vertices stay put and even vertices are just edge midpoints
//
// Templates:
// MatV matrix for vertex positions, e.g. MatrixXd
// MatF matrix for vertex positions, e.g. MatrixXi
// Inputs:
// V #V by dim mesh vertices
// F #F by 3 mesh triangles
// Outputs:
// NV new vertex positions, V is guaranteed to be at top
// NF new list of face indices
//
// NOTE: V should not be the same as NV,
// NOTE: F should not be the same as NF, use other proto
  template <
    typename DerivedV, 
    typename DerivedF,
    typename DerivedNV,
    typename DerivedNF>
  IGL_INLINE void upsample(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    Eigen::PlainObjectBase<DerivedNV>& NV,
    Eigen::PlainObjectBase<DerivedNF>& NF);

// Virtually in place wrapper
  template <
    typename MatV, 
    typename MatF>
  IGL_INLINE void upsample(
    MatV& V,
    MatF& F);

up_axis.h// Determines the up axis or depth axis of the current gl matrix
// Outputs:
// x pointer to x-coordinate in scene coordinates of the un-normalized
// up axis
// y pointer to y-coordinate in scene coordinates of the un-normalized
// up axis
// z pointer to z-coordinate in scene coordinates of the un-normalized
// up axis
// mv pointer to modelview matrix
//
// Note: Up axis is returned *UN-normalized*
IGL_INLINE void up_axis(double * x, double * y, double * z);
IGL_INLINE void up_axis(const double * mv, double * x, double * y, double * z);

vf.h // Constructs the vertex-face topology of a given mesh (V,F)
// Inputs:
// V #V by 3 list of vertex coordinates
// F #F by dim list of mesh faces (must be triangles)
// Outputs:
//
//
// See also: edges, cotmatrix, diag, vv
  template <typename DerivedV, typename DerivedF, typename IndexType>
  IGL_INLINE void vf(
                     const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     std::vector<std::vector<IndexType> >& VF,
                     std::vector<std::vector<IndexType> >& VFi);

view_axis.h // Determines the view axis or depth axis of the current gl matrix
// Outputs:
// x pointer to x-coordinate in scene coordinates of the un-normalized
// viewing axis
// y pointer to y-coordinate in scene coordinates of the un-normalized
// viewing axis
// z pointer to z-coordinate in scene coordinates of the un-normalized
// viewing axis
// mv pointer to modelview matrix
//
// Note: View axis is returned *UN-normalized*
  IGL_INLINE void view_axis(double * x, double * y, double * z);
  IGL_INLINE void view_axis(const double * mv, double * x, double * y, double * z);

write.h // write mesh to an ascii file with automatic detection of file format. supported: obj, off)
// Known Bugs:
// Does not correctly find file extensions: myfile.foo.off
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool write(
                        const std::string str,
                        const Eigen::PlainObjectBase<DerivedV>& V,
                        const Eigen::PlainObjectBase<DerivedF>& F);

writeDMAT.h // Write a matrix using ascii dmat file type
//
// Template:
// Mat matrix type that supports .rows(), .cols(), operator(i,j)
// Inputs:
// file_name path to .dmat file
// W eigen matrix containing to-be-written coefficients
#ifdef IGL_HEADER_ONLY
#  include "writeDMAT.cpp"
#endif

#endif

writeMESH.h // save a tetrahedral volume mesh to a .mesh file
//
// Templates:
// Scalar type for positions and vectors (will be cast as double)
// Index type for indices (will be cast to int)
// Input:
// mesh_file_name path of .mesh file
// V double matrix of vertex positions #V by 3
// T #T list of tet indices into vertex positions
// F #F list of face indices into vertex positions
//
// Known bugs: Holes and regions are not supported
  template <typename Scalar, typename Index>
  IGL_INLINE bool writeMESH(
    const std::string mesh_file_name,
    const std::vector<std::vector<Scalar > > & V,
    const std::vector<std::vector<Index > > & T,
    const std::vector<std::vector<Index > > & F);

// Templates:
// DerivedV real-value: i.e. from MatrixXd
// DerivedT integer-value: i.e. from MatrixXi
// DerivedF integer-value: i.e. from MatrixXi
// Input:
// mesh_file_name path of .mesh file
// V eigen double matrix #V by 3
// T eigen int matrix #T by 4
// F eigen int matrix #F by 3
  template <typename DerivedV, typename DerivedT, typename DerivedF>
  IGL_INLINE bool writeMESH(
    const std::string str,
    const Eigen::PlainObjectBase<DerivedV> & V, 
    const Eigen::PlainObjectBase<DerivedT> & T,
    const Eigen::PlainObjectBase<DerivedF> & F);

writeOBJ.h // Write a mesh in an ascii obj file
// Inputs:
// str path to outputfile
// V eigen double matrix #V by 3 (mesh vertices)
// F eigen int matrix #F by 3 (mesh indices)
// Returns true on success, false on error
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool writeOBJ(
    const std::string str,
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F);

  template <typename DerivedV, typename DerivedF, typename DerivedT>
  IGL_INLINE bool writeOBJ(
    const std::string str,
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    const Eigen::PlainObjectBase<DerivedV>& CN,
    const Eigen::PlainObjectBase<DerivedF>& FN,
    const Eigen::PlainObjectBase<DerivedT>& TC,
    const Eigen::PlainObjectBase<DerivedF>& FTC);

writeOFF.h
  template <typename DerivedV, typename DerivedF>
  IGL_INLINE bool writeOFF(
                        const std::string str,
                        const Eigen::PlainObjectBase<DerivedV>& V,
                        const Eigen::PlainObjectBase<DerivedF>& F);

writeTGF.h // WRITETGF
//
// Write a graph to a .tgf file
//
// Input:
// filename .tgf file name
// V # vertices by 3 list of vertex positions
// E # edges by 2 list of edge indices
//
// Assumes that graph vertices are 3 dimensional
  IGL_INLINE bool writeTGF(
    const std::string tgf_filename,
    const std::vector<std::vector<double> > & C,
    const std::vector<std::vector<int> > & E);

  #ifndef IGL_NO_EIGEN
  IGL_INLINE bool writeTGF(
    const std::string tgf_filename,
    const Eigen::MatrixXd & C,
    const Eigen::MatrixXi & E);
  #endif

Camera.h
  class Camera

#ifdef IGL_HEADER_ONLY
#  include "Camera.cpp"
#endif

#endif

EPS.h
  const double DOUBLE_EPS    = 1.0e-14;
  const double DOUBLE_EPS_SQ = 1.0e-28;
  const float FLOAT_EPS    = 1.0e-7;
  const float FLOAT_EPS_SQ = 1.0e-14;

// Function returning EPS for corresponding type
  template <typename S_type> IGL_INLINE S_type EPS();
  template <typename S_type> IGL_INLINE S_type EPS_SQ();

// Template specializations for float and double
  template <> IGL_INLINE float EPS<float>();
  template <> IGL_INLINE double EPS<double>();
  template <> IGL_INLINE float EPS_SQ<float>();
  template <> IGL_INLINE double EPS_SQ<double>();

ReAntTweakBar.h
  TwType ReTwDefineEnum(
    const char *name, 
    const TwEnumVal *enumValues, 
    unsigned int nbValues);

  struct ReTwRWItem
      if(this != &that)
      return *this;

  struct ReTwCBItem
      if(this != &that)
      return *this;

  class ReTwBar

See also: tutorial, style guidelines, file formats

Automatically generated on Fri Sep 13 13:21:17 CEST 2013 by scripts/doc.sh.