An error occurred while loading the file. Please try again.
-
Takumi Amano authoredde8a994f
make_soccer_map_pp <- function(rcg) {
soocer_field = c(6000,104,68)
names(soocer_field) = c("time","length","width")
soccer_map <- array(0, dim = c(6000,13,104,68))
for(i in seq_along(rcg)){
# SP - (x,y) location 1 on attacking players’ location (x,y)
px <- round(rcg$x[i])+soocer_field["length"]/2
py <- round(rcg$y[i])+soocer_field["width"]/2
bx <- round(rcg$ball_x[i])+soocer_field["length"]/2
by <- round(rcg$ball_y[i])+soocer_field["width"]/2
step <- rcg$step[i]
if(rcg$side[i]=="l"){
soccer_map[step,1,px,py] = rcg$unum[i]
soccer_map[step,3,px,py] = rcg$vx[i]
soccer_map[step,4,px,py] = rcg$vy[i]
}else if (rcg$side[i]=="r"){
soccer_map[step,2,px,py] = rcg$unum[i]
soccer_map[step,5,px,py] = rcg$vx[i]
soccer_map[step,6,px,py] = rcg$vy[i]
}
soccer_map[step,7,px,py] = atan(py/(soocer_field["length"]/2 - px))
dist_p_b = sqrt((bx-px)^2+(by-py)^2)
dist_p_g = sqrt(((soocer_field["length"]/2)-px)^2+(py)^2)
soccer_map[step,8,px,py] = (py-by) / dist_p_b
soccer_map[step,9,px,py] = (px-bx) / dist_p_b
soccer_map[step,10,px,py] = py / dist_p_g
soccer_map[step,11,px,py] = px / dist_p_g
soccer_map[step,12,px,py] = dist_p_b
soccer_map[step,13,px,py] = dist_p_g
}
return(soccer_map)
}
make_soccer_map_ps <- function(rcg) {
soocer_field = c(6000,104,68)
names(soocer_field) = c("time","length","width")
soccer_map <- array(0, dim = c(6000,13,104,68))
for(i in seq_along(rcg)){
# SP - (x,y) location 1 on attacking players’ location (x,y)
px <- round(rcg$x[i])+soocer_field["length"]/2
py <- round(rcg$y[i])+soocer_field["width"]/2
bx <- round(rcg$ball_x[i])+soocer_field["length"]/2
by <- round(rcg$ball_y[i])+soocer_field["width"]/2
step <- rcg$step[i]
if(rcg$side[i]=="l"){
soccer_map[step,1,px,py] = rcg$unum[i]
soccer_map[step,3,px,py] = rcg$vx[i]
soccer_map[step,4,px,py] = rcg$vy[i]
}else if (rcg$side[i]=="r"){
soccer_map[step,2,px,py] = rcg$unum[i]
soccer_map[step,5,px,py] = rcg$vx[i]
soccer_map[step,6,px,py] = rcg$vy[i]
}
soccer_map[step,7,px,py] = atan(py/(soocer_field["length"]/2 - px))
dist_p_b = sqrt((bx-px)^2+(by-py)^2)
dist_p_g = sqrt(((soocer_field["length"]/2)-px)^2+(py)^2)
soccer_map[step,8,px,py] = (py-by) / dist_p_b
soccer_map[step,9,px,py] = (px-bx) / dist_p_b
soccer_map[step,10,px,py] = py / dist_p_g
soccer_map[step,11,px,py] = px / dist_p_g
soccer_map[step,12,px,py] = dist_p_b
soccer_map[step,13,px,py] = dist_p_g
}
return(soccer_map)
}
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
make_soccer_map_pe <- function(rcg) {
soocer_field = c(6000,104,68)
names(soocer_field) = c("time","length","width")
soccer_map <- array(0, dim = c(6000,13,104,68))
for(i in seq_along(rcg)){
# SP - (x,y) location 1 on attacking players’ location (x,y)
px <- round(rcg$x[i])+soocer_field["length"]/2
py <- round(rcg$y[i])+soocer_field["width"]/2
bx <- round(rcg$ball_x[i])+soocer_field["length"]/2
by <- round(rcg$ball_y[i])+soocer_field["width"]/2
step <- rcg$step[i]
if(rcg$side[i]=="l"){
soccer_map[step,1,px,py] = rcg$unum[i]
soccer_map[step,3,px,py] = rcg$vx[i]
soccer_map[step,4,px,py] = rcg$vy[i]
}else if (rcg$side[i]=="r"){
soccer_map[step,2,px,py] = rcg$unum[i]
soccer_map[step,5,px,py] = rcg$vx[i]
soccer_map[step,6,px,py] = rcg$vy[i]
}
soccer_map[step,7,px,py] = atan(py/(soocer_field["length"]/2 - px))
dist_p_b = sqrt((bx-px)^2+(by-py)^2)
dist_p_g = sqrt(((soocer_field["length"]/2)-px)^2+(py)^2)
soccer_map[step,8,px,py] = (py-by) / dist_p_b
soccer_map[step,9,px,py] = (px-bx) / dist_p_b
soccer_map[step,10,px,py] = py / dist_p_g
soccer_map[step,11,px,py] = px / dist_p_g
soccer_map[step,12,px,py] = dist_p_b
soccer_map[step,13,px,py] = dist_p_g
}
return(soccer_map)
}