1require_relative "../physics"23question :along_a_straight_line do4 describes "A body starts at the origin with velocity %{starting_velocity} and speeds up or slows down steadily at %{acceleration}. " \5 "%{position} after %{time}, and %{velocity}?"6 given :starting_velocity7 given :acceleration8 given :time9 asks position: "Where is it", velocity: "how fast is it going"10end
1require_relative "../questions/along_a_straight_line"2require_relative "../science/motion_in_a_straight_line/uniform_acceleration"34solve :along_a_straight_line, using: UniformAcceleration do5 take starting_velocity: :v_0, acceleration: :a, time: :t, position: :x, velocity: :v6 deduce_from "the origin", x_0: "0 m"7 find_value :position8 find_value :velocity910 conclusion "Where the steady change of velocity has taken it: its velocity changes by the same " \11 "amount every second, and its position by that velocity, second after second."12end
1require_relative "../solutions/along_a_straight_line"23play_with :along_a_straight_line do4 title "Along a Straight Line"56 input :starting_velocity, -20.0..20.0, in: "m/s", step: 0.5, default: 10.0, as: "starting velocity"7 input :acceleration, -10.0..10.0, in: "m/s2", step: 0.5, default: -2.0, as: "acceleration"8 input :time, 0.0..10.0, in: "s", step: 0.1, default: 3.0, as: "time"910 output :position, in: "m"11 output :velocity, in: "m/s"12end