Skip to content

Instantly share code, notes, and snippets.

@tylermorganwall
Created June 27, 2022 01:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylermorganwall/dccf42958ec549f5042856dee685be5b to your computer and use it in GitHub Desktop.
Save tylermorganwall/dccf42958ec549f5042856dee685be5b to your computer and use it in GitHub Desktop.
Starlink Visualization
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)
angles = seq(0,360,length.out=8)
xx = 1 / 2 * sinpi(angles/180)
yy = 1 / 2 * cospi(angles/180)
polygon = as.matrix(data.frame(x=xx,y=yy,z=0))
starlink_traj = matrix(c(xpos,rep(0,length(xpos)),zpos), ncol=3)
u_gen = function(t, speed = 1) {
steps = tweenr::tween(c(0,1),n=t, ease = "cubic-in-out")[[1]]
uvals = matrix(c(rep(0,t),steps),ncol=2,nrow=t)
return(uvals)
}
uvals = u_gen(361, 1)[-1,]
phase = seq(0,6,length.out=72)
for(j in seq(1,nrow(uvals),by=1)) {
traj_scene = list()
for(i in 1:72) {
single_traj = extruded_path(points=starlink_traj,closed=T,
u_min = (phase[i] + uvals[j,1])+j/nrow(uvals),
u_max = (phase[i] + uvals[j,2])+j/nrow(uvals),
polygon=polygon,
width=10,
angle=c(0,0,53), order_rotation = c(3,2,1),
material=light(importance_sample = F, color="purple"))
traj_scene[[i]] = group_objects(single_traj, angle=c(0,i*5,0))
}
full_traj = do.call(rbind,traj_scene)
generate_ground(spheresize = earthrad, depth = earthrad,
material=glossy(image_texture = "2k_earth_daymap.jpg",
roughness_texture = "2k_earth_earthspec.jpg",
roughness_range = c(0.05,1), roughness_flip = T)) |>
group_objects(angle=c(0,2*j,0)) %>%
add_object(group_objects(full_traj,angle=c(0,-2*j/360*5,0))) |>
add_object(sphere(x=40000,y=15000,radius=10000,material=light(color="white",intensity = 20))) |>
add_object(sphere(x=-60000,y=-20000,radius=1000,material=light(color="orange",intensity = 30))) |>
render_scene(fov=10, lookfrom=c(10000,0,10000)*4, sample_method = "sobol_blue",
filename=sprintf("spacex_two%d.png",j), min_variance = 1e-6,
width=1200,height=1200, samples=128, aperture=0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment