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
28
# 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)
  (speed ** 2) * (speed > 0 ? -1 : 1) *
    0.5 * frontal_area * drag_cof * air_density
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



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

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



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

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



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

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



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

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