Sha256: b6c76720705eb1490211ff3040b14281a742525ecbc11543aa6f02ef4ec8f39a
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
require 'driving_physics/motor' require 'driving_physics/gearbox' module DrivingPhysics class Powertrain attr_reader :motor, :gearbox def initialize(motor, gearbox) @motor = motor @gearbox = gearbox end def to_s ["\t[MOTOR]", @motor, "\t[GEARBOX]", @gearbox].join("\n") end def select_gear(gear) @gearbox.gear = gear end def axle_torque(rpm) crank_alpha = @motor.alpha(@motor.torque(rpm), omega: DrivingPhysics.omega(rpm)) crank_torque = @motor.implied_torque(crank_alpha) axle_alpha = @gearbox.alpha(@gearbox.axle_torque(crank_torque), omega: @gearbox.axle_omega(rpm)) @gearbox.implied_torque(axle_alpha) end def axle_omega(rpm) @gearbox.axle_omega(rpm) end def crank_rpm(axle_omega) @gearbox.crank_rpm(axle_omega) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
driving_physics-0.0.1.1 | lib/driving_physics/powertrain.rb |