Skip to content

Commit

Permalink
bias toward shorter rods
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbowen committed Feb 24, 2024
1 parent 18b5188 commit 1925ca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ class SphereWithRods {
// Base length and maximum length of the rods
const baseLength = 1; // Assuming R = 1 for simplicity
const maxLength = 4; // 4R
const biasFactor = 3; // Adjust this value to control the bias; higher values favor shorter rods more

// Generate a biased random length
// Math.pow(Math.random(), biasFactor) generates a number between 0 and 1, skewed towards 0
// Multiplying by (maxLength - baseLength) scales it to the desired range
// Adding baseLength offsets it so the minimum is baseLength, not 0
const rodLength = baseLength + Math.pow(Math.random(), biasFactor) * (maxLength - baseLength);

// Random length for the rod between baseLength and maxLength
const rodLength = baseLength + Math.random() * (maxLength - baseLength);

// Rod geometry
const rodGeometry = new THREE.CylinderGeometry(0.01, 0.01, rodLength, 32);
Expand Down

0 comments on commit 1925ca9

Please sign in to comment.