Skip to content

Instantly share code, notes, and snippets.

@tylermorganwall
tylermorganwall / beeswarm.R
Created January 4, 2025 20:12
3D beeswarm
#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