R/vac.R

#' Variable covariant linear mapping
#' 
#' This function encodes a linear mapping that sends a vector in the vector 
#' space containing a point cloud $M^J$ to the vector space of variables over 
#' $J$, whose coordinates are the covariant coordinates of the cloud, relative
#' to a given point $P$, with respect to the axis generated by the vector.
#' @param cloud An m-by-n matrix of coordinates for m points in n-dimensional 
#'   space.
#' @param point An n-coordinate point in the same space as the cloud.
#' @param dir_vec An n-dimensional vector giving the direction of the axis 
#'   through the cloud.
#' @export

vac <-
    function(cloud, point, dir_vec) {
        
        # If point is unspecified, use barycenter
        if (missing(point)) point <- barycenter(cloud)
        
        # Transform cloud relative to point
        transform_cloud <- cloud - rep(point, each = nrow(cloud))
        
        # Calculate coordinates
        transform_cloud %*% matrix(dir_vec, ncol = 1)
    }
corybrunson/cloud documentation built on May 13, 2019, 10:51 p.m.