# # book_ch_3_fig_12.r -- Does Two-Dim Plot of Cutting Plane Procedur # # Figure 3.12 of the Book # library(MASS) library(pcurve) # # Read in Iterations of Procedure # T <- matrix(scan("C:/R_Files/fort.50",0),ncol=5,byrow=TRUE) # # Kludge To Prevent Overstrike # T[8,4] <- 0.05 # # Cutpoint and Normal Vector # TT <- matrix(scan("C:/R_Files/fort.51",0),ncol=5,byrow=TRUE) # # 1 3 0.075 0.000 1.000 # 2 2 0.076 0.157 0.988 # 3 2 0.121 0.297 0.955 # 4 2 0.181 0.413 0.911 # 5 1 0.353 0.492 0.871 # 6 1 0.355 0.504 0.863 # 7 0 0.390 0.514 0.858 # #nplane <- 1 nplane <- 2 #nplane <- 5 #nplane <- 7 # ws <- TT[nplane,3] N1 <- TT[nplane,4] N2 <- TT[nplane,5] # plot(T[,3],T[,4],type="n",asp=1, # main="Figure 3.10B: Cutting Plane Procedure\nN = (0.000 1.000), 1st Iteration", main="Cutting Plane Procedure\nN = (0.157 0.988), 2nd Iteration", # main="Figure 3.12B: Cutting Plane Procedure\nN = (0.492 0.871), 5th Iteration", # main="Figure 3.12C: Cutting Plane Procedure\nN = (0.514 0.858), 7th Iteration", xlab="(A)", ylab="", xlim=c(-1.0,1.0),ylim=c(-1.0,1.0)) # # Yea points(T[T[,2]==nplane & T[,3]==1,4],T[T[,2]==nplane & T[,3]==1,5],pch='Y',col="red") # Nay points(T[T[,2]==nplane & T[,3]==6,4],T[T[,2]==nplane & T[,3]==6,5],pch='N',col="blue") # # Plot Cutting Line # # This computes the point on the Normal Vector # Through which the Cutting Line passes # xws <- ws*N1 yws <- ws*N2 # # This computes the Cutting Line # arrows(xws,yws,xws+N2,yws-N1,length=0.0,lwd=1,col="black") arrows(xws,yws,xws-N2,yws+N1,length=0.0,lwd=1,col="black") # # This does the Normal Vector # arrows(0.0,0.0,N1,N2,length=0.1,lwd=1,col="black") # #