国庆长假就这样过完了,国庆阅兵绝对是重点。很多人包括外媒讨论的焦点更多的是DF-41和DF-17,但是冷静的分析,我认为这不是祖国强大的原因而是经济发展的结果。经济发展人才是关键,联想到我,拿着微薄的失业金,忍受着毕业的压力和家庭的压力,时常有种报国无门壮志难酬的感觉,我能做点什么呢?借用别人的代码1画个国旗聊以自慰吧,当下我得赶紧克服我得拖延症,抓紧写论文,希望两年后的今天我能从容淡定的面对一切。

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 画五角星的函数
star <- function(posXY, size = 1, theta = 0, color = "yellow") {
    alpha <- 2 * pi/5
    R <- size
    r <- sin(pi/10) * R/sin(7 * pi/10)
    
    pointpos <- matrix(0, nrow = 10, ncol = 2)
    
    Beta <- (pi/10 + theta) + (0:4) * alpha
    pointpos[seq(1, 9, 2), ] <- cbind(cos(Beta) * R + posXY[1], sin(Beta) * 
        R + posXY[2])
    
    Beta <- (3 * pi/10 + theta) + (0:4) * alpha
    pointpos[seq(2, 10, 2), ] <- cbind(cos(Beta) * r + posXY[1], sin(Beta) * 
        r + posXY[2])
    
    polygon(pointpos, col = color, border = color)
}

# 计算小五角星旋转角度的函数
rotTheta <- function(posxy, posXY) {
    atan((posXY[2] - posxy[2])/(posXY[1] - posxy[1])) + pi/2
}

# 常量设置
width <- 3
height <- 2 * width/3
d <- width/30
yshift <- height/2

# 国旗的坐标
Flag <- cbind(c(0, width, width, 0), c(0, 0, height, height))

# 大五角星坐标
posXY <- c(5 * d, yshift + 5 * d)

# 小五角星坐标
posxy <- matrix(c(10, 8, 12, 6, 12, 3, 10, 1), ncol = 2, byrow = T) * d + matrix(c(0, 
    yshift), nrow = 4, ncol = 2, byrow = T)

# 小五角星旋转角度
rottheta <- rep(0, nrow(posxy))
rottheta <- apply(posxy, 1, rotTheta, posXY)

# 画红色的国旗底面
plot(Flag, type = "n", col = "red", axes = F, xlim = c(0, width), ylim = c(0, 
    height), xlab = "", ylab = "", main = "People's Republic of China", asp = 1)
polygon(Flag, density = NULL, col = "red", border = "red")

# 画出大五角星
star(posXY, size = 3 * height/20, theta = 0, color = "yellow")

# 画出四颗小星
for (i in 1:nrow(posxy)) {
    star(posxy[i, ], size = height/20, theta = rottheta[i], color = "yellow")
}