R/Spheres3d.R

Defines functions Spheres3d.default Spheres3d

Documented in Spheres3d Spheres3d.default

##
## p3d:Spheres3d.R
## 2016-10-08
##
## Copined from Lines3d.R
## merged Lines3d.R and Lines3d.default.R  10-30-2011 (MF)
#  fixed args for Lines3d.default as an S3 method
# TODO: obj serves no useful role and should be deleted if no other Linesed methods contemplated -- removed 11-04-2011 (GM)


#' @export
Spheres3d <-
function( ... , verbose = FALSE) {
    "
    Lines3d allows arguments to be vectors or matrices whose corresponding
    axes as specified with names of the form 'x', 'xy', 'yxz', etc.
    "
    UseMethod("Spheres3d")
}

#' @export
Spheres3d.default <-
		function( ... , verbose = FALSE)  {
	a <- args3d(...)
	# disp(a)
	xyz <- a$x
	if (nrow(xyz) == 0) return( invisible(0))
	nas <- apply(xyz, 1, function(x) any(is.na(x)))
	inds <- 1:nrow(xyz)
	inds[nas] <- NA
	inds <-  cbind(inds[-length(inds)],inds[-1])
	inds <- na.omit(inds)
	inds <- c(t(inds))
	xyz <- xyz[inds,]
	a$x <- xyz
	# names(a) <- sub('^lwd$','size', names(a))
	# do.call("rgl.lines", a)
	if (verbose) disp(a)
	do.call("spheres3d", a)
}

# Lines3d( y = 1, z = 1.1, x =c(0,2), col = 'red')
# Lines3d( y = 1.1, z = 1.1, x =c(0,2), color = 'red')

# Lines3d( y = 1, z = 1.2, x =c(0,2))
# Lines3d( y = 1.1, z = 1.2, x =c(0,2))


# Lines3d( y = 1, z = 1.5, x =c(0,2), col = 'red3', lwd = 3)
# Lines3d( y = 1.1, z = 1.5, x =c(0,2), color = 'red3', lwd = 3)
# Lines3d( y = 1.1, z = 1.8, x =c(0,2),col='red',lwd = 3)
# material3d()
gmonette/p3d documentation built on Nov. 16, 2023, 11:31 p.m.