cut adjusted involute, to better show the difference
This commit is contained in:
parent
1c0dfa51c9
commit
b51356acd0
34
src/main.rs
34
src/main.rs
|
|
@ -2,7 +2,7 @@ use std::{f32::consts::PI, time::Duration};
|
||||||
|
|
||||||
use flo_draw::{
|
use flo_draw::{
|
||||||
DrawEvent, Key,
|
DrawEvent, Key,
|
||||||
canvas::{Color::Rgba, GraphicsContext},
|
canvas::{Color::Rgba, GraphicsContext, GraphicsPrimitives},
|
||||||
create_drawing_window_with_events, with_2d_graphics,
|
create_drawing_window_with_events, with_2d_graphics,
|
||||||
};
|
};
|
||||||
use glam::{FloatExt, Vec2, mat3, vec2, vec3};
|
use glam::{FloatExt, Vec2, mat3, vec2, vec3};
|
||||||
|
|
@ -80,6 +80,15 @@ fn main() {
|
||||||
mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, c, s), vec3(0.0, -s, c))
|
mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, c, s), vec3(0.0, -s, c))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let adjust_offset = |off: f32| {
|
||||||
|
let (s, c) = crown_angle.sin_cos();
|
||||||
|
let pitch = vec2(r_crown * c, r_pitch);
|
||||||
|
let offset = off * vec2(s, -c);
|
||||||
|
let pt = pitch + offset;
|
||||||
|
let intersect = pt * (pitch.x / pt.x);
|
||||||
|
r_pitch - intersect.y
|
||||||
|
};
|
||||||
|
let adjust_angle = |angle: f32| (angle.tan() * crown_angle.cos()).atan();
|
||||||
let gear_profile = Profile {
|
let gear_profile = Profile {
|
||||||
addemdum: ADDENDUM,
|
addemdum: ADDENDUM,
|
||||||
dedendum: DEDENDUM,
|
dedendum: DEDENDUM,
|
||||||
|
|
@ -90,11 +99,21 @@ fn main() {
|
||||||
dedendum: gear_profile.addemdum,
|
dedendum: gear_profile.addemdum,
|
||||||
pressure_angle: gear_profile.pressure_angle,
|
pressure_angle: gear_profile.pressure_angle,
|
||||||
};
|
};
|
||||||
|
let gear_profile_adj = Profile {
|
||||||
|
addemdum: adjust_offset(gear_profile.addemdum),
|
||||||
|
dedendum: -adjust_offset(-gear_profile.dedendum),
|
||||||
|
pressure_angle: adjust_angle(gear_profile.pressure_angle),
|
||||||
|
};
|
||||||
|
let cutter_profile_adj = Profile {
|
||||||
|
addemdum: adjust_offset(cutter_profile.addemdum),
|
||||||
|
dedendum: -adjust_offset(-cutter_profile.dedendum),
|
||||||
|
pressure_angle: adjust_angle(cutter_profile.pressure_angle),
|
||||||
|
};
|
||||||
|
|
||||||
let n_points_per_tooth = 100;
|
let n_points_per_tooth = 100;
|
||||||
let n_points = n_points_per_tooth * n_teeth_sample;
|
let n_points = n_points_per_tooth * n_teeth_sample;
|
||||||
let mut inv_shape = vec![r_pitch + ADDENDUM; n_points];
|
let mut inv_shape = vec![r_pitch + gear_profile_adj.addemdum; n_points];
|
||||||
let mut bevel_shape = vec![r_pitch + 3.0 * ADDENDUM; n_points];
|
let mut bevel_shape = vec![r_pitch + gear_profile_adj.addemdum; n_points];
|
||||||
let mut show_crown_gear = false;
|
let mut show_crown_gear = false;
|
||||||
let mut show_crown_cutter = true;
|
let mut show_crown_cutter = true;
|
||||||
let mut show_rack_gear = false;
|
let mut show_rack_gear = false;
|
||||||
|
|
@ -156,7 +175,7 @@ fn main() {
|
||||||
let crown_cutter = make_crown(&cutter_profile);
|
let crown_cutter = make_crown(&cutter_profile);
|
||||||
|
|
||||||
let rack_y_at_x = |x, profile| rack_shape(x - rack_offset * PI, profile);
|
let rack_y_at_x = |x, profile| rack_shape(x - rack_offset * PI, profile);
|
||||||
let inv_cutter_y_at_x = |x| rack_y_at_x(x, &cutter_profile);
|
let inv_cutter_y_at_x = |x| rack_y_at_x(x, &cutter_profile_adj);
|
||||||
|
|
||||||
let bevel_cutter: Vec<_> = crown_cutter
|
let bevel_cutter: Vec<_> = crown_cutter
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -213,6 +232,11 @@ fn main() {
|
||||||
gc.close_path();
|
gc.close_path();
|
||||||
gc.stroke_color(Rgba(0.3, 0.3, 0.3, 0.4));
|
gc.stroke_color(Rgba(0.3, 0.3, 0.3, 0.4));
|
||||||
gc.stroke();
|
gc.stroke();
|
||||||
|
gc.stroke_color(Rgba(0.3, 0.3, 0.3, 0.1));
|
||||||
|
gc.circle(0.0, r_pitch, r_pitch - gear_profile_adj.dedendum);
|
||||||
|
gc.circle(0.0, r_pitch, r_pitch);
|
||||||
|
gc.circle(0.0, r_pitch, r_pitch + gear_profile_adj.addemdum);
|
||||||
|
gc.stroke();
|
||||||
|
|
||||||
line(
|
line(
|
||||||
gc,
|
gc,
|
||||||
|
|
@ -228,7 +252,7 @@ fn main() {
|
||||||
for k in 0..n_points_per_tooth {
|
for k in 0..n_points_per_tooth {
|
||||||
let x = (tooth as f32 + k as f32 / n_points_per_tooth as f32 + rack_offset)
|
let x = (tooth as f32 + k as f32 / n_points_per_tooth as f32 + rack_offset)
|
||||||
* PI;
|
* PI;
|
||||||
pts_rack.push(vec2(x, rack_y_at_x(x, &gear_profile)));
|
pts_rack.push(vec2(x, rack_y_at_x(x, &gear_profile_adj)));
|
||||||
pts_cutter.push(vec2(x, inv_cutter_y_at_x(x)));
|
pts_cutter.push(vec2(x, inv_cutter_y_at_x(x)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user