# doc-cache created by Octave 10.3.0
# name: cache
# type: cell
# rows: 3
# columns: 8
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
affinemap


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 715
  [A,b]=affinemap(pfrom,pto)

  calculate an affine transform (A matrix and b vector) to map n
  vertices from one space to the other using least square solutions

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      pfrom: nx3 matrix, each row is a 3d point in original space
      pto: nx3 matrix, each row is a 3d point in the mapped space

 outputs:
      A: 3x3 matrix, the calculated affine A matrix
      b: 3x1 vector, the calculated affine b vector

 the solution will satisfy the following equation: A*pfrom'+b=pto

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
  [A,b]=affinemap(pfrom,pto)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
dist2surf


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 855
  [d2surf,cn]=dist2surf(node,nv,p)

  calculate the distances from a point cloud to a surface, and return
  the indices of the closest surface node

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      node: node coordinate of the surface mesh (nn x 3)
      nv: nodal norms (vector) calculated from nodesurfnorm.m
          with dimensions of (size(node,1),3), this can be 
          calcuated from nodesurfnorm.m
      pt: points to be calculated, 3 columns for x,y and z respectively

 outputs:
      d2surf: a vector of length of p, the distances from p(i) to the surface
      cn: a integer vector with the length of p, the indices of the closest surface node

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
  [d2surf,cn]=dist2surf(node,nv,p)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
getplanefrom3pt


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 628
  [a,b,c,d]=getplanefrom3pt(plane)

  calculate the plane equation coefficients for a plane 
   (determined by 3 points), the plane equation is a*x+b*y+c*z+d=0

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      plane: a 3x3 matrix, each row is a 3d point in form of (x,y,z)
             this is used to define a plane
 outputs:
      a,b,c,d: the coefficients of the plane equation

 for degenerated lines or triangles, this will stop

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
  [a,b,c,d]=getplanefrom3pt(plane)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
linextriangle


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1072
  [isinside,pt,coord]=linextriangle(p0,p1,plane)

  calculate the intersection of a 3d line (passing two points)
  with a plane (determined by 3 points)

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      p0: a 3d point in form of (x,y,z)
      p1: another 3d point in form of (x,y,z), p0 and p1 determins the line
      plane: a 3x3 matrix, each row is a 3d point in form of (x,y,z)
             this is used to define a plane
 outputs:
      isinside: a boolean variable, 1 for the intersection is within the 
               3d triangle determined by the 3 points in plane; 0 is outside
      pt: the coordinates of the intersection pint
      coord: 1x3 vector, if isinside=1, coord will record the barycentric 
          coordinate for the intersection point within the triangle; 
          otherwise it will be all zeros.

 for degenerated lines or triangles, this will stop

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
  [isinside,pt,coord]=linextriangle(p0,p1,plane)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
nodesurfnorm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 741
  nv=nodesurfnorm(node,elem)

  calculate a nodal norm for each vertix on a surface mesh (surface 
   can only be triangular or cubic)

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      node: node coordinate of the surface mesh (nn x 3)
      elem: element list of the surface mesh (3 columns for 
            triangular mesh, 4 columns for cubic surface mesh)
      pt: points to be projected, 3 columns for x,y and z respectively

 outputs:
      nv: nodal norms (vector) calculated from nodesurfnorm.m
          with dimensions of (size(v,1),3)

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
  nv=nodesurfnorm(node,elem)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
proj2mesh


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1544
  [newpt elemid weight]=proj2mesh(v,f,pt,nv,cn)

  project a point cloud on to the surface mesh (surface can only be triangular)

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      v: node coordinate of the surface mesh (nn x 3)
      f: element list of the surface mesh (3 columns for 
            triangular mesh, 4 columns for cubic surface mesh)
      pt: points to be projected, 3 columns for x,y and z respectively
      nv: nodal norms (vector) calculated from nodesurfnorm.m
          with dimensions of (size(v,1),3)
      cn: a integer vector with the length of p, denoting the closest
          surface nodes (indices of v) for each point in p. this 
          value can be calculated from dist2surf.m
      radmax: if speicified, the search for elements to project will be
          limited to those within a bounding box with half-edge-length 
          of radmax centered at the point to be projected

      if nv and cn are not supplied, proj2mesh will project the point
      cloud onto the surface by the direction pointing to the centroid
      of the mesh

 outputs:
      newpt: the projected points from p
      elemid: a vector of length of p, denotes which surface trangle (in elem)
             contains the projected point
      weight: the barycentric coordinate for each projected points, these are
             the weights 

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
  [newpt elemid weight]=proj2mesh(v,f,pt,nv,cn)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
regpt2surf


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1640
  [A,b,newpos]=regpt2surf(node,elem,p,pmask,A0,b0,cmask,maxiter)
  Perform point cloud registration to a triangular surface
  (surface can be either triangular or cubic), Gauss-Newton method
  is used for the calculation

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      node: node coordinate of the surface mesh (nn x 3)
      elem: element list of the surface mesh (3 columns for 
            triangular mesh, 4 columns for cubic surface mesh)
      p: points to be registered, 3 columns for x,y and z respectively
      pmask: a mask vector with the same length as p, determines the 
         method to handle the point, if pmask(i)=-1, the point is a free
         node and can be move by the optimization, if pmask(i)=0, the
         point is fixed; if pmask(i)=n>0, the distance between p(i,:)
         and node(n,:) will be part of the object function and be optimized
      A0: a 3x3 matrix, as the initial guess for the affine A matrix (rotation&scaling)
      b0: a 3x1 vector, as the initial guess for the affine b vector (translation)
      cmask: a binary 12x1 vector, determines which element of [A(:);b] will be optimized
          if cmask(i)=0, the corresponding coefficient will not be updated
      maxiter: a integer, specifying the optimization iterations

 outputs:
      A: 3x3 matrix, the updated affine A matrix
      b: 3x1 vector, the updated affine b vector
      newpos: the registered positions for p, newpos=A*p'+b

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
  [A,b,newpos]=regpt2surf(node,elem,p,pmask,A0,b0,cmask,maxiter)
  Perform po...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
trisurfnorm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 597
  ev=trisurfnorm(node,elem)
  calculate the surface norms for each element
  (surface can be either triangular or cubic)

  author: Qianqian Fang <fangq at nmr.mgh.harvard.edu>
  date: 12/12/2008

 parameters: 
      node: node coordinate of the surface mesh (nn x 3)
      elem: element list of the surface mesh (3 columns for 
            triangular mesh, 4 columns for cubic surface mesh)
 outputs:
      ev: norm vector for each surface element

 Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch

 this function is part of "metch" toobox, see COPYING for license



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
  ev=trisurfnorm(node,elem)
  calculate the surface norms for each element
  ...





