Module: DrivingPhysics::ScalarForce

Defined in:
lib/driving_physics/scalar_force.rb

Class Method Summary collapse

Class Method Details

.air_resistance(speed, frontal_area: FRONTAL_AREA, drag_cof: DRAG_COF, air_density: AIR_DENSITY) ⇒ Object

opposes the direction of speed



22
23
24
25
26
27
# File 'lib/driving_physics/scalar_force.rb', line 22

def self.air_resistance(speed,
                        frontal_area: FRONTAL_AREA,
                        drag_cof: DRAG_COF,
                        air_density: AIR_DENSITY)
  -1 * 0.5 * frontal_area * drag_cof * air_density * speed ** 2
end

.all_resistance(speed, frontal_area: FRONTAL_AREA, drag_cof: DRAG_COF, air_density: AIR_DENSITY, rot_cof: ROT_COF, nf_mag:, roll_cof: ROLL_COF) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/driving_physics/scalar_force.rb', line 56

def self.all_resistance(speed,
                        frontal_area: FRONTAL_AREA,
                        drag_cof: DRAG_COF,
                        air_density: AIR_DENSITY,
                        rot_cof: ROT_COF,
                        nf_mag:,
                        roll_cof: ROLL_COF)
  speed_resistance(speed,
                   frontal_area: frontal_area,
                   drag_cof: drag_cof,
                   air_density: air_density,
                   rot_cof: rot_cof) +
    rolling_resistance(nf_mag, roll_cof: roll_cof)
end

.rolling_resistance(normal_force, roll_cof: ROLL_COF) ⇒ Object

opposes the direction of speed normal force is not always mass * G, e.g. aero downforce



36
37
38
# File 'lib/driving_physics/scalar_force.rb', line 36

def self.rolling_resistance(normal_force, roll_cof: ROLL_COF)
  -1 * normal_force * roll_cof
end

.rotational_resistance(speed, rot_cof: ROT_COF) ⇒ Object

opposes the direction of speed



30
31
32
# File 'lib/driving_physics/scalar_force.rb', line 30

def self.rotational_resistance(speed, rot_cof: ROT_COF)
  -1 * speed * rot_cof
end

.speed_resistance(speed, frontal_area: FRONTAL_AREA, drag_cof: DRAG_COF, air_density: AIR_DENSITY, rot_cof: ROT_COF) ⇒ Object

convenience methods



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/driving_physics/scalar_force.rb', line 44

def self.speed_resistance(speed,
                          frontal_area: FRONTAL_AREA,
                          drag_cof: DRAG_COF,
                          air_density: AIR_DENSITY,
                          rot_cof: ROT_COF)
  air_resistance(speed,
                 frontal_area: frontal_area,
                 drag_cof: drag_cof,
                 air_density: air_density) +
    rotational_resistance(speed, rot_cof: rot_cof)
end