Skip to content

Instantly share code, notes, and snippets.

@tamanobi
Last active March 26, 2021 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamanobi/bef8eb807058738bcd56 to your computer and use it in GitHub Desktop.
Save tamanobi/bef8eb807058738bcd56 to your computer and use it in GitHub Desktop.
等高線グラフでスーパー楕円を描画する
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