R/functions.R
funcCircleCoords.Rd
Generate coordinates to draw a circle.
funcCircleCoords(center = c(0, 0), r = 1, npoints = 100)
Adapted from Joran's response to https://stackoverflow.com/questions/6862742/draw-a-circle-with-ggplot2.
coordinate for centroid
radius
number of coordinates to generate
a dataframe
funcCircleCoords(c(1,2),1)
#> x y
#> 1 2.0000000000 2.000000
#> 2 1.9979866765 2.063424
#> 3 1.9919548128 2.126592
#> 4 1.9819286973 2.189251
#> 5 1.9679487014 2.251148
#> 6 1.9500711177 2.312033
#> 7 1.9283679330 2.371662
#> 8 1.9029265383 2.429795
#> 9 1.8738493771 2.486197
#> 10 1.8412535328 2.540641
#> 11 1.8052702575 2.592908
#> 12 1.7660444431 2.642788
#> 13 1.7237340381 2.690079
#> 14 1.6785094116 2.734592
#> 15 1.6305526671 2.776146
#> 16 1.5800569096 2.814576
#> 17 1.5272254676 2.849725
#> 18 1.4722710748 2.881453
#> 19 1.4154150130 2.909632
#> 20 1.3568862216 2.934148
#> 21 1.2969203753 2.954902
#> 22 1.2357589355 2.971812
#> 23 1.1736481777 2.984808
#> 24 1.1108381999 2.993838
#> 25 1.0475819158 2.998867
#> 26 0.9841340362 2.999874
#> 27 0.9207500431 2.996855
#> 28 0.8576851617 2.989821
#> 29 0.7951933319 2.978802
#> 30 0.7335261863 2.963842
#> 31 0.6729320367 2.945001
#> 32 0.6136548743 2.922354
#> 33 0.5559333874 2.895994
#> 34 0.5000000000 2.866025
#> 35 0.4460799361 2.832570
#> 36 0.3943903129 2.795762
#> 37 0.3451392661 2.755750
#> 38 0.2985251123 2.712694
#> 39 0.2547355503 2.666769
#> 40 0.2139469053 2.618159
#> 41 0.1763234186 2.567060
#> 42 0.1420165868 2.513677
#> 43 0.1111645513 2.458227
#> 44 0.0838915426 2.400931
#> 45 0.0603073792 2.342020
#> 46 0.0405070264 2.281733
#> 47 0.0245702131 2.220311
#> 48 0.0125611113 2.158001
#> 49 0.0045280774 2.095056
#> 50 0.0005034576 2.031728
#> 51 0.0005034576 1.968272
#> 52 0.0045280774 1.904944
#> 53 0.0125611113 1.841999
#> 54 0.0245702131 1.779689
#> 55 0.0405070264 1.718267
#> 56 0.0603073792 1.657980
#> 57 0.0838915426 1.599069
#> 58 0.1111645513 1.541773
#> 59 0.1420165868 1.486323
#> 60 0.1763234186 1.432940
#> 61 0.2139469053 1.381841
#> 62 0.2547355503 1.333231
#> 63 0.2985251123 1.287306
#> 64 0.3451392661 1.244250
#> 65 0.3943903129 1.204238
#> 66 0.4460799361 1.167430
#> 67 0.5000000000 1.133975
#> 68 0.5559333874 1.104006
#> 69 0.6136548743 1.077646
#> 70 0.6729320367 1.054999
#> 71 0.7335261863 1.036158
#> 72 0.7951933319 1.021198
#> 73 0.8576851617 1.010179
#> 74 0.9207500431 1.003145
#> 75 0.9841340362 1.000126
#> 76 1.0475819158 1.001133
#> 77 1.1108381999 1.006162
#> 78 1.1736481777 1.015192
#> 79 1.2357589355 1.028188
#> 80 1.2969203753 1.045098
#> 81 1.3568862216 1.065852
#> 82 1.4154150130 1.090368
#> 83 1.4722710748 1.118547
#> 84 1.5272254676 1.150275
#> 85 1.5800569096 1.185424
#> 86 1.6305526671 1.223854
#> 87 1.6785094116 1.265408
#> 88 1.7237340381 1.309921
#> 89 1.7660444431 1.357212
#> 90 1.8052702575 1.407092
#> 91 1.8412535328 1.459359
#> 92 1.8738493771 1.513803
#> 93 1.9029265383 1.570205
#> 94 1.9283679330 1.628338
#> 95 1.9500711177 1.687967
#> 96 1.9679487014 1.748852
#> 97 1.9819286973 1.810749
#> 98 1.9919548128 1.873408
#> 99 1.9979866765 1.936576
#> 100 2.0000000000 2.000000
plot(funcCircleCoords(c(1,2),1))