# (1) Read an ang file type and parse it into landmark and outline data
# (2) Plot the data.

 require(MASS)       # includes ginv() function
 require(session)    # includes texteval() function
# library(clim.pact) mod fn is N %% n
# Function Deffinition Section

# Ask function
ask<- function(text) {
cat(text,": ", sep="")
indata<- readLines(con=stdin(), n=1, ok = TRUE)
                     }
cat("Directory of ang files \n")   
lsout<- system("ls *.dta*", TRUE, TRUE)
print(lsout)
file= ask("Enter an dta file name")

WingAng<- read.table(file, header =TRUE)
 
 Wingf<-WingAng[1,]
 Wingm<-WingAng[2,]
 wingf<-matrix(as.numeric(matrix(Wingf)[2:63]), 31, 2, byrow=TRUE)
 wingm<-matrix(as.numeric(matrix(Wingm)[2:63]), 31, 2, byrow=TRUE)
# browser()
  par(mfrow = c(1, 2))
  mag <- 2
  FF <- wingf
  MM <- wingm
  PP <- MM + (FF - MM) * mag
#    tpsgrid(MM,PP,-2,-2,5,2,1) 
   tpsgrid(MM, PP, -0.25, -0.25, 0.55, 2, 0.05, 22)

  title("TPS grid: Female mean (left) to Male mean (right)")

 