Created
          June 28, 2020 14:48 
        
      - 
      
- 
        Save tylermorganwall/2b744899dc745d601fb1efec3b807109 to your computer and use it in GitHub Desktop. 
    The Most Beautiful 3D Pie Charts You've Ever Seen
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | library(rayrender) | |
| pielist = list() | |
| counter = 1 | |
| for(i in seq(60-90,360-90,by=60)) { | |
| angles = seq(i-60,i,by=1) | |
| xx = 2*sinpi(angles/180) | |
| yy = 2*cospi(angles/180) | |
| pielist[[counter]] = data.frame(x=c(0,xx),y=c(0,yy)) | |
| counter = counter + 1 | |
| } | |
| soff = function(i, off) { | |
| 0.8 + 0.75*sinpi((4*i+off)/180) | |
| } | |
| for(i in seq(1,180,by=1)) { | |
| xz_rect(xwidth=20,zwidth=20,material=glossy(image_repeat = c(2),image_texture = "wood.png")) %>% | |
| add_object(xy_rect(xwidth=20,ywidth=20, y=10, z=-2,material=diffuse(image_repeat = c(10,20),sigma=30, | |
| image_texture = "walltile.png"))) %>% | |
| add_object(sphere(y=20,x=10,z=10,radius=5,material=light(intensity=20))) %>% | |
| add_object(group_objects(extruded_polygon(pielist[[1]],z=1,material = glossy(color="red"),top=soff(i,30)) %>% | |
| add_object(extruded_polygon(pielist[[2]],z=1,material = glossy(color="purple"),top=soff(i,60))) %>% | |
| add_object(extruded_polygon(pielist[[3]],z=1,material = glossy(color="blue"),top=soff(i,90))) %>% | |
| add_object(extruded_polygon(pielist[[4]],z=1,material = glossy(color="green"),top=soff(i,120))) %>% | |
| add_object(extruded_polygon(pielist[[5]],z=1,material = glossy(color="yellow"),top=soff(i,150))) %>% | |
| add_object(extruded_polygon(pielist[[6]],z=1,material = glossy(color="orange"),top=soff(i,180))), | |
| group_angle = c(0,4*i,0), pivot_point = c(0,0,1))) %>% | |
| render_scene(samples=256, lookfrom=c(0,5,10),lookat=c(0,0.75,0), | |
| filename=glue::glue("piechart{i}"), clamp_value = 10, fov=30) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment