rename fn
This commit is contained in:
parent
c0227f4203
commit
f951b7b96b
2 changed files with 3 additions and 3 deletions
|
@ -25,7 +25,7 @@ pub fn disable_mouse_trap(mut windows: ResMut<Windows>) {
|
|||
window.set_cursor_visibility(true);
|
||||
}
|
||||
|
||||
pub fn random_sphere_vec(r: &mut impl rand::prelude::Rng) -> Vec3 {
|
||||
pub fn random_unit_vec(r: &mut impl rand::prelude::Rng) -> Vec3 {
|
||||
// https://mathworld.wolfram.com/SpherePointPicking.html
|
||||
// Marsaglia (1972) for picking x1 and x2 from (-1, 1) and generating surface
|
||||
// points directly if their sum is less than 1.
|
||||
|
@ -38,7 +38,7 @@ pub fn random_sphere_vec(r: &mut impl rand::prelude::Rng) -> Vec3 {
|
|||
x2 = r.gen_range(-1.0..=1.0);
|
||||
ssum = x1.powi(2) + x2.powi(2);
|
||||
}
|
||||
let sqrt = (1.0 - x1.powi(2) - x2.powi(2)).sqrt();
|
||||
let sqrt = (1.0 - ssum).sqrt();
|
||||
let x = 2.0 * x1 * sqrt;
|
||||
let y = 2.0 * x2 * sqrt;
|
||||
let z = 1.0 - 2.0 * ssum;
|
||||
|
|
|
@ -25,7 +25,7 @@ fn spawn_moving_lights(
|
|||
// spawn 200 orbiting bisexual lights
|
||||
for _ in 0..255 {
|
||||
// mechanics
|
||||
let axis = crate::random_sphere_vec(rng);
|
||||
let axis = crate::random_unit_vec(rng);
|
||||
let angle = rng.gen_range(0.0..TAU);
|
||||
let rate: f32 = rng.gen_range(7.0..10.0);
|
||||
let rate = rate.to_radians();
|
||||
|
|
Loading…
Reference in a new issue