make_graphics.R 2.59 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
DEFAULT_MAX_PLAYER <- 11
DEFAULT_PITCH_LENGTH <- 105.0
DEFAULT_PITCH_WIDTH <- 70.0
DEFAULT_PITCH_MARGIN <- 5.0
DEFAULT_CENTER_CIRCLE_R <- 9.15
DEFAULT_PENALTY_AREA_LENGTH <- 16.5
DEFAULT_PENALTY_AREA_WIDTH <- 40.32
DEFAULT_PENALTY_CIRCLE_R <- 9.15
DEFAULT_PENALTY_SPOT_DIST <- 11.0
DEFAULT_GOAL_AREA_LENGTH <- 5.5
DEFAULT_GOAL_AREA_WIDTH <- 18.32
DEFAULT_GOAL_DEPTH <- 2.44
# DEFAULT_CORNER_ARC_R <- 1.0
half_p_l <- DEFAULT_PITCH_LENGTH/2
half_p_w <- DEFAULT_PITCH_WIDTH/2
penalty_x <- half_p_l - DEFAULT_PENALTY_AREA_LENGTH
penalty_y <- DEFAULT_PENALTY_AREA_WIDTH/2
goal_x <- half_p_l - DEFAULT_GOAL_AREA_LENGTH
goal_y <- DEFAULT_GOAL_AREA_WIDTH/2



make_field <- function(input_graph){
    p <- input_graph +
    
26
27
    geom_hline(yintercept = 0, linetype = "solid")+
    geom_vline(xintercept = 0, linetype = "solid")+
28
29
30
31
32
    geom_linerange(aes(x=half_p_l, y=NULL, ymin=-half_p_w, ymax=half_p_w))+
    geom_linerange(aes(x=-half_p_l, y=NULL, ymin=-half_p_w, ymax=half_p_w))+
    geom_linerange(aes(x=NULL, y=half_p_w, xmin=-half_p_l, xmax=half_p_l))+
    geom_linerange(aes(x=NULL, y=-half_p_w, xmin=-half_p_l, xmax=half_p_l))+

33
    geom_point(size=0.1) +
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    geom_linerange(aes(x=penalty_x, y=NULL, ymin=-penalty_y, ymax=penalty_y))+
    geom_linerange(aes(x=-penalty_x, y=NULL, ymin=-penalty_y, ymax=penalty_y))+
    geom_linerange(aes(x=NULL, y=penalty_y, xmin=penalty_x, xmax=half_p_l))+
    geom_linerange(aes(x=NULL, y=-penalty_y, xmin=penalty_x, xmax=half_p_l))+
    geom_linerange(aes(x=NULL, y=penalty_y, xmax=-penalty_x, xmin=-half_p_l))+
    geom_linerange(aes(x=NULL, y=-penalty_y, xmax=-penalty_x, xmin=-half_p_l))+

    geom_linerange(aes(x=goal_x, y=NULL, ymin=-goal_y, ymax=goal_y))+
    geom_linerange(aes(x=-goal_x, y=NULL, ymin=-goal_y, ymax=goal_y))+
    geom_linerange(aes(x=NULL, y=goal_y, xmax=goal_x, xmin=half_p_l))+
    geom_linerange(aes(x=NULL, y=-goal_y, xmax=goal_x, xmin=half_p_l))+
    geom_linerange(aes(x=NULL, y=goal_y, xmin=-goal_x, xmax=-half_p_l))+
    geom_linerange(aes(x=NULL, y=-goal_y, xmin=-goal_x, xmax=-half_p_l))+

    ggforce::geom_circle(aes(x0 = 0, y0 = 0, r = DEFAULT_CENTER_CIRCLE_R),inherit.aes = FALSE)
    return(p)
}

make_heatmap <- function(p_data){
    p <- ggplot(data = p_data, aes(x = as.numeric(x), y = as.numeric(y))) +
    ggplot2::coord_fixed(xlim=c(-half_p_l,half_p_l),ylim =c(-half_p_w,half_p_w))+ 
    geom_density_2d_filled(alpha = 0.5)

    p <- p |> make_field()
58
59
60
    return(p)
}

61
62
63
64
65
66
67
68
69
70
# make_kick_point <- function(p_data,input_graph){
#     log_data <- p_data

#     p <- input_graph +
#     geom_point(data = p_data,aes(x = as.numeric(x), y = as.numeric(y)))


#     return(p)
# }