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) | |
| #Create base scene | |
| basescene = xz_rect(x=555/2,y=0.1,z=555/2,555,555, | |
| material = lambertian(color="#bababa", checkercolor = "grey10", checkerperiod = 100)) %>% | |
| add_object(xz_rect(x=555/2,y=1000,z=555/2,343,332, | |
| material = lambertian(color="white", lightintensity=40,implicit_sample = TRUE), | |
| flipped=TRUE)) | |
| #Function for sphere bouncing |
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
| options(rgl.useNULL = FALSE) | |
| install.packages(c("ggplot2","raster", "spatstat", "spatstat.utils","suncalc", "remotes", | |
| "here", "sp","lubridate","rgdal", "magick", "av","xml2","rayrender")) | |
| install.packages("whitebox", repos="http://R-Forge.R-project.org") | |
| library(whitebox) | |
| whitebox::wbt_init() | |
| #macOS: xcrun issue? type "xcode-select --install" into terminal | |
| #macOS imager.so or libx11 errors? Install X11: https://www.xquartz.org |
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(rayshader) | |
| wave = matrix(0,200,200) | |
| for(t in seq(1,360,1)) { | |
| for(i in 1:200) { | |
| for(j in 1:200) { | |
| wave[i,j] = 50*sinpi(sqrt((i-100)^2 + (j-100)^2)/30-t/180) * exp(-(sqrt((i-100)^2 + (j-100)^2))/100) | |
| } | |
| } | |
| wave %>% height_shade() %>% plot_3d(wave, soliddepth = -50, shadowdepth = -70, theta=315,zoom=1.1) |
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(rayshader) | |
| library(raster) | |
| library(stringr) | |
| library(sp) | |
| library(maptools) | |
| library(dplyr) | |
| library(rgdal) | |
| library(sf) | |
| readShapePoly("eastern-states") |
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) | |
| vecx = 10 * sinpi(1:360/180) | |
| vecz = 10 * cospi(1:360/180) | |
| anglevec = -10 * cospi(1:360/90) | |
| for(i in seq(1,360,by=1)) { | |
| generate_ground(material = dielectric()) %>% | |
| add_object(sphere(material = metal())) %>% | |
| add_object(disk(radius=3, inner_radius = 2, angle = c(anglevec[i],-i,0))) %>% |
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) | |
| drawspiral = function(n, x = 0, material=diffuse(color="white")) { | |
| segments = list() | |
| for(i in seq_len(n)) { | |
| if(i %% 2 != 0) { | |
| segments[[i]] = cylinder(z=0.5,x=x, length=0.5, radius=0.5*i, material = material, phi_min = 90, phi_max = 270) | |
| } else { | |
| segments[[i]] = cylinder(z=0,x=x, length=0.5, radius=0.5*i, material = material, phi_min = 90, phi_max = 270, angle=c(0,180,0)) | |
| } |
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(rayshader) | |
| library(rayrender) | |
| for(t in 1:90) { | |
| sliced = matrix(10, 99, 99) | |
| sliced2 = sliced | |
| for(i in 1:nrow(sliced)) { | |
| for(j in 1:ncol(sliced)) { | |
| sliced2[i,j] = 10+1*cos(-t/90*2*pi + 8*i/nrow(sliced)) | |
| if(i %% 3 == 0 || j %% 3 == 0) { |
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(tidyverse) | |
| dbf = data.frame(color=character(0), x=numeric(0), y=numeric(0), stringsAsFactors = F) | |
| ## Distractive woman | |
| # Left arm | |
| dbf = bind_rows(dbf, crossing(color='skin', x=seq(4,5), y=seq(1,9),z=3)) | |
| dbf = bind_rows(dbf, data.frame(color='skin', x=5, y=10,z=3)) |
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 |
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) | |
| library(sf) | |
| library(dplyr) | |
| library(ggplot2) | |
| library(lubridate) | |
| library(magick) | |
| #Extract state data | |
| us_states = spData::us_states |