question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_needle_before_a_convex_mirror do 4 kind :numerical 5 describes "A %{size} needle is placed %{distance} away from a convex mirror of focal length %{focal_length}. " \ 6 "%{where}, in cm, measured along the incoming light from the mirror?" 7 given size: "4.5 cm" 8 given distance: "12 cm" 9 given focal_length: "15 cm" 10 asks where: "What is the location of the image" 11 end
1 require_relative "../questions/a_needle_before_a_convex_mirror" 2 require_relative "../science/ray_optics_and_optical_instruments/spherical_mirror" 3 4 solve :a_needle_before_a_convex_mirror , using: SphericalMirror do 5 objects :mirror 6 7 take size: mirror . object_height 8 take distance: mirror . distance_in_front 9 take focal_length: mirror . size_of_the_focal_length 10 11 deduce_from "convex mirror" , mirror . focal_length => mirror . size_of_the_focal_length 12 13 where = mirror . image_distance 14 answer where :, in: "cm" , figures: 2 15 16 conclusion "A convex mirror's focus lies behind it, so the image is virtual, behind the mirror and between the " \ 17 "pole and the focus." 18 end
1 require_relative "../solutions/a_needle_before_a_convex_mirror" 2 3 play_with :a_needle_before_a_convex_mirror do 4 title "A Needle Before a Convex Mirror" 5 end