diff --git a/src/main.rs b/src/main.rs index 3051836..8885614 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,8 @@ fn main() { let n_rack_teeth = 10; + let r_crown = 18.0; + let n_teeth = 36; let n_teeth_sample = n_teeth; let r_pitch = 0.5 * n_teeth as f32; @@ -95,7 +97,11 @@ fn main() { let gear_offset = t * TPS - (n_teeth_sample as f32 + 5.0); let rack_offset = (t * TPS).fract_gl(); - let rack_y_at_x = |x, profile| rack_shape(x - rack_offset * PI, profile); + let rack_y_at_x = |x, profile| { + let angle = f32::atan2(x, r_crown); + let vx = angle * r_crown; + rack_shape(vx - rack_offset * PI, profile) + }; let cutter_y_at_x = |x| rack_y_at_x(x, &cutter_profile); let kr_to_xy = |k, r: f32| {