Last active
August 29, 2015 14:27
-
-
Save pepijn-devries/7b78fc80674c33a91b51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################# | |
# ball and stick model | |
################################# | |
# get bond info | |
bonds <- get.bonds(molfile) | |
bonds.atoms <- data.frame(do.call('rbind', lapply(bonds, function(x){ | |
atoms <- get.atoms(x) | |
start <- get.point3d(atoms[[1]]) | |
end <- get.point3d(atoms[[2]]) | |
return (list(start.x = start[1], start.y = start[2], start.z = start[3], | |
end.x = end[1], end.y = end[2], end.z = end[3])) | |
}))) | |
# open rgl device | |
open3d() | |
# plot sticks | |
mapply(function(x1, y1, z1, x2, y2, z2){ | |
shade3d(cylinder3d(data.frame(x = c(x1, x2), y = c(y1, y2), z = c(z1, z2)), | |
radius = 0.1, sides = 16, | |
e2=rbind(c(1,0,0),c(1,0,0))), col="grey") | |
}, bonds.atoms$start.x, bonds.atoms$start.y, bonds.atoms$start.z, | |
bonds.atoms$end.x, bonds.atoms$end.y, bonds.atoms$end.z) | |
# plot balls | |
mapply(function(x, y, z, vdw, col){ | |
spheres3d(x, y, z, vdw*0.25, col = col, add = T) | |
}, atom_dat$x, atom_dat$y, atom_dat$z, | |
atom_dat$vanderwaals, atom_dat$colour) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment