Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Emulate Eye tracking data and remove all that is x pixels away from the centre
- set.seed(007)
- # Assume screen of 1920 by 1080 pixels
- xmax <- 1920
- ymax <- 1080
- ymid <- ymax/2
- xmid <- xmax/2
- # Simulate some data that truly fixes on the centre screen
- sims <- 10000 # How many simulations
- xT <- rnorm(sims,xmid,20)
- yT <- rnorm(sims,ymid,20)
- # Add noise where people fixed at random points of screen
- xN <- runif(sims/5,0,xmax)
- yN <- runif(sims/5,0,ymax)
- # Merge together
- x <- c(xT,xN)
- y <- c(yT,yN)
- results <- data.frame(x,y)
- # Plot all simulations
- plot(results, xlim=c(0,xmax), ylim=c(0,ymax))
- # Try to subset part of data that is within radius of centre
- threshold <- 40 # Threshold set aggressive to clarify issue
- resultsSub <- results[results$x <= xmid+threshold & results$x >= xmid-threshold & results$y <= ymid+threshold & results$y >= ymid-threshold,]
- # Plot obviously wrong solulution. Now a square is left rather than a circle
- plot(resultsSub, xlim=c(0,xmax), ylim=c(0,ymax))
- # Potential way forward?
- # Centre as 0.0
- resultsC <- results
- resultsC$x <- resultsC$x-xmid
- resultsC$y <- resultsC$y-ymid
- # Create circle with radius of threshold
- objects <- 100
- th = seq(0,(2*pi),2*pi/objects)
- thred = th[seq(1,100,1)]
- ### Default
- xposd = cos(thred)*40
- yposd = sin(thred)*40
- # Somehow compare defined circle against data
- plot(resultsC)
- points(xposd,yposd, col="red")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement