Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Gear Math

gear_math/possibilities.livemd

Gear Math

Mix.install([{:gear_math, path: "~/Documents/electronics-helpers/gear_math/"}])

Generate Possibilities for Module & Tooth Count

ring_diameter = 100

ring_diameter
|> GearMath.module_teeth_possibilities()
# |> Enum.filter(fn {module, tooth_count} ->
#   # module === 1.0
# end)
|> Enum.uniq()
|> GearMath.group_pitch_diameter_possibilities_by_module()

# |> Enum.filter(fn {{module, min_tooth_count}, num_teeth} ->
# GearMath.Utils.real_number?(module)
# end)

Generate Planetary Possibilities

planetary_possibilities = GearMath.Planetary.possibilities(ring_diameter, {1, 5})
final_choices =
  planetary_possibilities
  |> Enum.filter(
    &amp;(&amp;1.sun_input_ring_output_ratio >= 6.0 and &amp;1.module >= 2.15 &amp;&amp; &amp;1.ring.addendum <= 100)
  )
  |> Enum.sort_by(&amp; &amp;1.sun_input_ring_output_ratio, :desc)

# |> Enum.map(&(&1.module))
choice = List.last(final_choices)
height = 9

%{
  sun_helix_beta:
    GearMath.Gear.helical_gear_sweep_angle(height, choice.module, choice.sun.tooth_count),
  planet_helix_beta:
    GearMath.Gear.helical_gear_sweep_angle(height, choice.module, choice.planet.tooth_count),
  ring_helix_beta:
    GearMath.Gear.helical_gear_sweep_angle(height, choice.module, choice.ring.tooth_count)
}

Generate Compound Planetary Possibilities

compound_possibilities = GearMath.Planetary.Compound.possibilities(ring_diameter, {1, 4})
compound_possibilities
|> Enum.filter(fn %GearMath.Planetary.Compound{
                    ratio: {_ring_ratio, sun_ratio},
                    input_planetary: input_planetary,
                    output_planetary: output_planetary
                  } ->
  input_planetary.num_planets >= 3 &amp;&amp;
    GearMath.Utils.real_number?(sun_ratio) &amp;&amp;
    GearMath.Utils.divisible_by?(input_planetary.module, Decimal.from_float(0.25)) &amp;&amp;
    GearMath.Utils.divisible_by?(output_planetary.module, Decimal.from_float(0.25)) &amp;&amp;
    sun_ratio === 6.0
end)
# |> Enum.map(&(&1.ratio))
|> Enum.uniq()
|> Enum.sort()