Hi morphometricians,
A quick update: a function to plot Morphologika 3D wireframes using the package geomorph. This routine (or a version of it) will be included in our next package update under the "read.morphologika" function.
Enjoy!
Example:
library(geomorph)
# create an array of 10 random 3D specimens with 6 landmarks each to GPA
data<-array(abs(rnorm(18*10)),c(6,3,5))
# create a simple wireframe, e.g., pt1 connects to pt2, 2-to-3, 3-to-4,...etc.
wireframe<-matrix(c(1,2,2,3,3,4,4,5,5,6),ncol=2,byrow=T)
wireframe
mydata.gpa<-gpagen(data) #gpa landmarks
# choose the largest and/or smallest specimen
max<-which.max(mydata.gpa$Csize) #ID specimen w/largest CS
min<-which.min(mydata.gpa$Csize) #ID specimen w/smallest CS
# wireframe function: wirefun
# Input: 2 matrices: A & W
# A is the procrustes residualsmatrix
# W is the wireframe matrix
wirefun<-function(A,W,...){
plot3d(A,type="n", aspect=FALSE,...)
for(i in 1:dim(W)[1]){
points3d(A[W[i,],],...)
text3d(A[W[i,],],texts=W[i,],...)
lines3d(rbind(A[W[i,1],],A[W[i,2],]),...)
}
}
# Plot
wirefun(A=mydata.gpa$coords[,,1],W=wireframe,size=10,adj=2.5,col="black")
No comments:
Post a Comment