Skip to content

Commit 0f7e9ed

Browse files
author
Kevin Cazelles
committed
make circles way more simple
1 parent f47cccc commit 0f7e9ed

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

R/circles.R

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,19 @@ circles <- function(x, y = x, radi = 1, from = 0, to = 2*pi, incr = 0.01, pie =
6666
# drawing circles
6767
out <- list()
6868
for (i in 1L:sz) {
69+
## distance (in rardian)
70+
dagl <- abs(to[i] - from[i])
6971
## --- angles sequence
70-
if (abs(to[i] - from[i]) >= (pipi)) {
72+
if (dagl >= pipi) {
73+
# no point of drawing a circle multiple times
7174
to[i] <- pipi
7275
from[i] <- 0
73-
} else {
74-
if ((to[i] > from[i]) & (to[i]%%(pipi) == 0))
75-
to[i] <- pipi
76-
to[i] <- to[i]%%(pipi)
77-
from[i] <- from[i]%%(pipi)
78-
if (to[i] < from[i])
79-
to[i] <- to[i] + pipi
8076
}
8177
##
8278
if (!clockwise) {
83-
sqc <- seq(from[i], to[i], by = incr)
79+
sqc <- seq(from[i], from[i] + dagl, by = incr)
8480
} else {
85-
sqc <- seq(from[i], 2*from[i] - to[i], by = -incr)
81+
sqc <- seq(from[i], from[i] -dagl, by = -incr)
8682
}
8783

8884
if (!pie) {

0 commit comments

Comments
 (0)