# \donttest{
# check if the vertices in these neurons are inside the mushroom body calyx
# surface object
inout=pointsinside(kcs20, surf=subset(MBL.surf, "MB_CA_L"))
table(inout)
# be a bit more lenient and include points less than 5 microns from surface
MBCAL=subset(MBL.surf, "MB_CA_L")
inout5=pointsinside(kcs20, surf=MBCAL, rval='distance') > -5
table(inout5)
# show which points are in or out
# Hmm seems like there are a few red points in the vertical lobe
# that are well outside the calyx
points3d(xyzmatrix(kcs20), col=ifelse(inout5, 'red', 'black'))
plot3d(MBL.surf, alpha=.3)
# Let's try to make an alphashape for the mesh to clean it up
library(alphashape3d)
MBCAL.as=ashape3d(xyzmatrix(MBCAL), alpha = 10)
# Plotting the points, we can see that is much better behaved
points3d(xyzmatrix(kcs20),
col=ifelse(pointsinside(kcs20, MBCAL.as), 'red', 'black'))
# }
if (FALSE) {
# Show the face normals for a surface
if(require('Morpho')) {
# convert to a mesh3d object used by rgl and Morpho packge
MBCAL.mesh=as.mesh3d(subset(MBL.surf, "MB_CA_L"))
fn=facenormals(MBCAL.mesh)
wire3d(MBCAL.mesh)
# show that the normals point out of the object
plotNormals(fn, long=5, col='red')
# invert the faces of the mesh and show that normals point in
MBCAL.inv=invertFaces(MBCAL.mesh)
plotNormals(facenormals(MBCAL.inv), long=5, col='cyan')
}
}
Run the code above in your browser using DataLab