----- Forwarded message from Dean Adams
<dcad...@iastate.edu> -----
Date: Tue, 23 Apr 2013 11:26:33
-0400
From: Dean Adams <dcad...@iastate.edu>
Reply-To:
Dean Adams <dcad...@iastate.edu>
Subject: New fixed.angle
function
To: morphmet@morphometrics.org
Below is a new version of the fixed.angle() function. We will incorporate this into the next version of geomorph later this spring.
Thanks to Fabio Machado for identifying the problem.
Best,
Dean
-- Dr. Dean C. Adams Professor Department of Ecology, Evolution, and Organismal Biology Department of Statistics Iowa State University Ames, Iowa 50011 www.public.iastate.edu/~dcadams/ phone: 515-294-3834
fixed.angle<-function(A,art.pt=NULL,angle.pts=NULL,rot.pts=NULL,angle=0){
if (length(dim(A))!=3){
stop("Data matrix 1 not a 3D array (see 'arrayspecs').") }
if(length(grep("-999",A))!=0){
stop("Data matrix 1 contains missing values. Estimate these first(see 'estimate.missing').") }
n<-dim(A)[3]; k<-dim(A)[2]; p<-dim(A)[1]
if (k!=2){
stop("Method presently implemented for two-dimensional data only.")}
if (angle>pi*2){
stop("Additional angle must be specified in radians.")}
if (angle< -pi*2){
stop("Additional angle must be specified in radians.")}
angl<-array(NA,dim=n)
for (i in 1:n){
A[,,i]<-t(t(A[,,i])-A[art.pt,,i]) #DCA 22 April, 2013: corrected translation and angle calculation
angl[i]<- acos((A[angle.pts[1],,i]/sqrt(sum(A[angle.pts[1],,i]^2)))%*%
(A[angle.pts[2],,i]/sqrt(sum(A[angle.pts[2],,i]^2))))
}
dev.angle<- (angl-mean(angl))+angle
if(A[angle.pts[1],1,1]<0){dev.angle<- -1*dev.angle}
for (i in 1:n){
r = matrix(c(cos(dev.angle[i]),-sin(dev.angle[i]),
sin(dev.angle[i]),cos(dev.angle[i])),2)
A[rot.pts,,i] = A[rot.pts,,i]%*%r
}
return(A)
}
----- Forwarded message from Fabio Machado <macfa...@gmail.com> -----
Date: Thu, 18 Apr 2013 20:53:03 -0400
From: Fabio Machado <macfa...@gmail.com>
Reply-To: Fabio Machado <macfa...@gmail.com>
Subject: problem with fixed.angle?
To: morphmet@morphometrics.orgDear List,I was trying to use the fixed.angle function in geomorph, and there seams to be a problem. The function deforms the resulting shape, even in the example given in the package. The problem seams to be in the centering on the rotation landmark, as you can check with the following code:data(plethspecies)plot(plethspecies$land[,,1],asp=1, xlim=c(-1,1))points(plethspecies$land[,,1]-plethspecies$land[1,,1],asp=1, col="red")points(fixed[,,1],asp=1, col="blue", pch=4)Apparently, the subtraction of the articulation point follows "downwards" through the column and recycle through the entire configuration. I've altered the code of the function as followingtoAnd this seams to solve the issue, but I'm not sure if I'm altering anything essential for the function or even if the problem I'm having is not due to anything else.Any input is appreciated.Best,-----------------------------------------------------
Fabio Andrade Machado
Laboratório de Evolução de Mamíferos
Departamento de Genética e Biologia Evolutiva
Universidade de São Paulo
Rua do Matão, trav.14, nº277,Edificio Minas Gerais+55 11 3091-8758+55 11 982-631-029skype: fabio_a_machadoGoogle Scholar: http://scholar.google.com/citations?hl=en&user=2l6-VrQAAAAJ
----- End forwarded message -----
----- End forwarded message
-----