require(methods) setClass(Class = 'POI', representation(matrizSim = 'matrix',cos.query.docs = 'vector', wordsInQuery = 'ANY',docs = 'matrix', objeto = 'matrix', objetoC = 'matrix', Pcoords = 'matrix', PcoordsFI = 'matrix', newPcoords = 'matrix', newcoords = 'numeric' , newcoords_1 = 'numeric', M = 'numeric', poisTextCol = 'character' , colores = 'vector' , poisCircleCol = 'character' , linesCol = 'character', itemsCol = 'character', LABELS = 'logical', vscale = 'numeric', hscale = 'numeric', circleCol = 'character', plotCol = 'character', itemsFamily = 'character', lenteDefault = 'numeric', zoomDefault = 'numeric' , rateDefault = 'numeric' , topKDefault = 'numeric' , pal = 'character', selected = 'numeric' , circRadio = 'numeric' , IncVscale = 'numeric', cgnsphrFont = 'numeric', xClick_old = 'numeric', yClick_old = 'numeric', wordsInQueryFull = 'character' ), prototype(cos.query.docs = 0, colores = 0, newcoords = 0, newcoords_1 = 0, M = 3, vscale = 0.5 , hscale = 1.5 , circleCol = 'black' , itemsCol = 'white', poisTextCol = '#fff5ee', poisCircleCol = '#fff5ee', linesCol = 'white', plotCol = 'black', itemsFamily = 'sans', lenteDefault = 1, zoomDefault = 15 , rateDefault = 0.1 , topKDefault = 25, pal = 'topo' , selected = 1 , circRadio = 0.25 , IncVscale = 0.05 , cgnsphrFont = 1.01, LABELS = T) ) setGeneric("puntosMedios" , function(Pcoords, detalle = 5){standardGeneric("puntosMedios")}) setMethod("puntosMedios" , signature = "matrix", function(Pcoords, detalle = 5){ for (i in 1:detalle){ new_pcoords = matrix(rep(0,4*nrow(Pcoords)), nrow = 2* nrow(Pcoords), byrow = T ) cont = 0 for (i in 1:nrow(Pcoords)){ if (i == nrow(Pcoords)) { cont = cont + 1 new_pcoords[cont,] = Pcoords[i,] cont = cont + 1 new_pcoords[cont,] = Pcoords[i,] - ((Pcoords[i,]-Pcoords[1,])/2) }else{ cont = cont + 1 new_pcoords[cont,] = Pcoords[i,] cont = cont + 1 new_pcoords[cont,] = Pcoords[i,] - ((Pcoords[i,]-Pcoords[i+1,])/2)}} Pcoords = new_pcoords} return(Pcoords) } ) setGeneric("fishIout" , function(x, value){standardGeneric ("fishIout")}) setMethod("fishIout" , signature = "numeric", function(x, value){ d = value if (x > 0){ signo = 1 }else{ signo = -1 } x = abs(x) return(signo*(-(x/((d*x)-d-1)))) } ) setGeneric("fishIin" , function(x, value){standardGeneric ("fishIin")}) setMethod("fishIin" , signature = "numeric", function(x, value){ d = value if (x > 0){ signo = 1 }else{ signo = -1 } x = abs(x) return(signo*(((d+1)*x)/(d*x+1))) } ) setGeneric("toPolar" , function(x, y){standardGeneric ("toPolar")}) setMethod("toPolar" , signature = "numeric", function(x, y){ t1 = atan2(y,x) rP = sqrt(x^2+y^2) return(c(t1 = t1,rP = rP)) } ) setGeneric("toCartesian" , function(t1, rP){standardGeneric ("toCartesian")}) setMethod("toCartesian" , signature = "numeric", function(t1, rP){ x1 = rP*cos(t1) y1 = rP*sin(t1) return(c(x = x1,y = y1)) } ) setGeneric("circulo" , function(cx, cy, r, circleCol, PLOT = TRUE){standardGeneric ("circulo")}) setMethod("circulo" , signature = "numeric", function(cx, cy, r, circleCol, PLOT = TRUE){ t = seq(0,2*pi,length=100) circle = t(rbind(cx+sin(t)*r,cy+cos(t)*r)) if (PLOT == TRUE) plot(circle,type='l',,ylim=c(-1.15,1.15),xlim=c(-1.15,1.15), ann=FALSE, axes=F, col = circleCol) return(circle) } ) setGeneric("circulin" , function(cx, cy, r = 0.045, objeto, col = 'blue', PLOT = TRUE, label = 0){ standardGeneric ("circulin")}) setMethod("circulin" , signature = "ANY", function(cx, cy, r = 0.045, objeto, col = 'blue', PLOT = TRUE, label = 0){ t = seq(0,2*pi,length=100) circle = t(rbind(cx+sin(t)*r,cy+cos(t)*r)) points(circle,type='l', col = col) if (label != 0) text(cx,cy,label,cex = .7) insiders <- apply(objeto,1,function(co)(cx-co[1])^2+(cy-co[2])^2