Last active
March 26, 2021 15:43
-
-
Save tamanobi/bef8eb807058738bcd56 to your computer and use it in GitHub Desktop.
等高線グラフでスーパー楕円を描画する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n <- 100 # num. of mesh | |
a <- 1.0 # x-axis param | |
b <- 1.0 # y-axis param | |
r <- 2.5 # when r is 2.5, it's superelipse | |
x <- seq( -a, a, length = n ) | |
y <- seq( -b, b, length = n ) | |
z <- matrix(0, n, n) | |
for (i in 1:n) { | |
for (j in 1:n) { | |
# superelipse | |
z[i, j] <- abs(x[i]/a) ^ r + abs(y[j]/b) ^ r | |
} | |
} | |
contour(x, y, z, drawlabels = F, levels=1, asp=1, lwd=12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment