This file contains 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) | |
volcano |> | |
height_shade() |> | |
plot_3d(volcano,zscale=3) | |
render_contours(volcano, clear_previous = T, offset=1,color="purple", | |
zscale=3, nlevels = 20) | |
for(i in 1:360) { |
This file contains 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(RColorBrewer) | |
colors = brewer.pal(n = 8, name = "Dark2") | |
set.seed(1) | |
spherelist = list() | |
for(i in 1:1000) { | |
spherelist[[i]] = sphere(x=runif(1)*535+10,y=runif(1)*535+10,z=runif(1)*535+10, | |
radius=10, | |
material=glossy(color = sample(colors,1))) | |
} |
This file contains 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
moss_landing_coord = c(36.806807, -121.793332) | |
t = seq(0,2*pi,length.out=1000) | |
circle_coords_lat = moss_landing_coord[1] + 0.5 * t/8 * sin(t*6) | |
circle_coords_long = moss_landing_coord[2] + 0.5 * t/8 * cos(t*6) | |
montereybay %>% | |
sphere_shade() %>% | |
plot_3d(montereybay,zscale=50,water=TRUE, | |
shadowcolor="#40310a", watercolor="#233aa1", background = "tan", | |
theta=210, phi=22, zoom=0.20, fov=55) |
This file contains 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
#Load all the libraries needed | |
library(sf) | |
library(dplyr) | |
library(rayrender) | |
library(elevatr) | |
library(rayshader) | |
library(geojsonsf) | |
library(raster) | |
library(lidR) |
This file contains 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
testapply = list() | |
testvapply = list() | |
# First, we generate a 10001 x 10001 matrix of random numbers pulled from a gaussian distribution. Our goal is to sum each of the columns and return a vector of each sum. Here, we have two strategies: | |
# 1) Loop through each column, calculate the sum, and assign into a vector. | |
# 2) apply() the sum function to each column. | |
numbers = matrix(rnorm(10001^2,0,1),nrow=10001,ncol=10001) | |
iter=1 |
This file contains 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
#Load all the libraries needed | |
library(sf) | |
library(dplyr) | |
library(rayrender) | |
library(elevatr) | |
library(rayshader) | |
library(geojsonsf) | |
library(raster) | |
#To recreate the wapo visualization, we need to visualize a few things in 3D: the buildings, |
This file contains 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) | |
starlink_traj = list() | |
earthrad = 3958.8 | |
orbit_alt = 340 | |
t=seq(0,360,length.out=31)[-31] | |
xpos = (earthrad + orbit_alt) * cospi(t/180) | |
zpos = (earthrad + orbit_alt) * sinpi(t/180) |
This file contains 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) | |
library(ggplot2) | |
ggdiamonds = ggplot(diamonds) + | |
stat_density_2d(aes(x = x, y = depth, fill = stat(nlevel)), | |
geom = "polygon", n = 200, bins = 50,contour = TRUE) + | |
facet_wrap(clarity~.) + | |
scale_fill_viridis_c(option = "A") |
This file contains 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
#JWST OBJ file located at www.tylermw.com/webb.zip | |
#Parse OBJ MTL file to read and write red color for highlighted component | |
mtl_file = readLines("jwebb.mtl") | |
kd_entries = (grepl("Kd",mtl_file,fixed=T)) | |
kd_ind = which(grepl("Kd",mtl_file,fixed=T)) | |
#Set all to white | |
mtl_file[kd_entries] = "Kd 1.000000 1.000000 1.000000" |
This file contains 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) | |
montereybay2 = montereybay | |
montereybay2[montereybay2<0] = 0 | |
for(i in 1:720) { | |
montereybay2 %>% | |
sphere_shade() %>% | |
add_water(detect_water(montereybay2), color="lightblue") |> | |
add_shadow(cloud_shade(montereybay2,zscale=50, sun_altitude = 90, seed=10, attenuation_coef = 1, time=i, |
NewerOlder