MCPcopy Create free account
hub / github.com/Notgnoshi/generative / generate_circle

Function generate_circle

tools/point-cloud.rs:76–94  ·  view source on GitHub ↗
(points: usize, rng: &mut StdRng)

Source from the content-addressed store, hash-verified

74}
75
76fn generate_circle(points: usize, rng: &mut StdRng) -> Vec<Double2> {
77 let mut v = Vec::with_capacity(points);
78
79 let r_dist = Uniform::new(0.0, 1.0).unwrap();
80 let theta_dist = Uniform::new(0.0, 2.0 * std::f64::consts::PI).unwrap();
81
82 for _ in 0..points {
83 let r = r_dist.sample(rng);
84 let theta = theta_dist.sample(rng);
85
86 let point = Double2 {
87 x: r * theta.cos(),
88 y: r * theta.sin(),
89 };
90 v.push(point);
91 }
92
93 v
94}
95
96fn generate_random_seed_if_not_specified(seed: u64) -> u64 {
97 if seed == 0 {

Callers 1

generateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected