

"vector.xyz" <-
function(xyz, atoms.inds=c(1,2) ) {

  
  if(!is.vector(xyz) || !is.numeric(xyz))
    stop("input 'xyz' should be a numeric vector")
  natm  <- length(xyz)/3
  if(natm < 2)
    stop("Need at least two atoms to define a vector")
  if(natm %% 1 != 0)
    stop("There should be three 'xyz' elements per atom")

  
  m.xyz <- matrix(xyz, ncol=3, byrow=T)
  v <- m.xyz[atoms.inds[1],] -  m.xyz[atoms.inds[2],]

  out <- c(v)
  return(out)
}

"unit.vector" <-
function(x) {
  return(x / sqrt(x%*%x))
}


"cm" <-
  function(pdb, inds) {

    cm=c(0,0,0)
    for ( i in 1:length(inds) ) {

      

    }
    

  }
