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
#Function to generate random 3D points within a defined space | |
initialize_swarm = function(n=100, range=10) { | |
swarm = matrix(runif(n * 3, -range, range), ncol=3) | |
velocities = matrix(runif(n * 3, -0.1, 0.1), ncol=3) | |
list(swarm=swarm, velocities=velocities) | |
} | |
spinning_vector_field = function(swarm, spin_strength=0.05) { | |
#Swirl around the Z-axis |
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
javascript:(function(){const%20issues=document.querySelectorAll('.js-issue-row');if(!issues.length){alert('No%20issues%20found!');return;}document.body.innerHTML='';document.body.style.margin='0';document.body.style.padding='0';document.body.style.backgroundColor='#000';document.body.style.overflow='hidden';document.body.style.position='relative';document.documentElement.style.height='100%';document.body.style.height='100%';const%20createSnowflake=()=>{const%20flake=document.createElement('div');flake.style.position='absolute';flake.style.top='-10px';flake.style.left=Math.random()*100+'vw';const%20size=Math.random()*5+5;flake.style.width=size+'px';flake.style.height=size+'px';flake.style.backgroundColor='white';flake.style.borderRadius='50%';flake.style.opacity=Math.random()*0.5+0.5;flake.style.filter='blur(2px)';flake.style.zIndex='1000';const%20duration=Math.random()*5+5;flake.style.animation=`fall%20${duration}s%20linear%200s%20forwards`;document.body.appendChild(flake);setTimeout(()=>{flake.remove();},dur |
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") |
NewerOlder