Upgrade to Pro — share decks privately, control downloads, hide ads and more …

空の色を計算してみた/calculate-sky-color

 空の色を計算してみた/calculate-sky-color

kohei.okamoto

August 13, 2021
Tweet

More Decks by kohei.okamoto

Other Decks in Science

Transcript

  1. ࣗݾ঺հɿԬຊ ᕣฏ • ࠇഎܠͷεϥΠυॳ௅ઓͰυΩυΩͯ͠·͢ • େֶ͸Խֶ΍ͬͯ·ͨ͠ • લ৬͸ۚ༥ܥͷγεςϜ࡞ͬͯ·ͨ͠ • ࠓ͸OESͷWebνʔϜͰ։ൃ͍ͯ͠·͢

    • go࢖ͬͨ͜ͱͳ͍ίϯϓϨοΫεͩͬͨͷͰɺࠓճ͸͸͡ΊͯgoΛ ৮ͬͯΈ·ͨ͠ (ͱ͍͍ͭͭɺ͓୊తʹશવίʔυॻ͍ͯ·ͤΜw)
  2. ࢄཚʹ΋͍Ζ͍Ζ (ͪΐͬͱ୤ઢ) • ϨΠϦʔࢄཚ • ޫͷ೾௕ΑΓ΋ࡉཻ͔͍ࢠʹର͢Δࢄཚ • ࠓճ͸ͬͪ͜ • ϛʔࢄཚ

    • ޫͷ೾௕ΑΓ΋େཻ͖͍ࢠʹର͢Δࢄཚ • લํ΁ͷࢄཚͷ೾௕ґଘੑ͕গͳ͍ɻͷͰɺશ෦ͷޫ͕ࢄཚ͞ΕͯӢ ͸ന͘Έ͑·͢ɻ
  3. ࠓճͷΞϓϩʔν 1. ଠཅޫͷR / G / BͷޫͷॏͶ߹Θͤͱͯۙ͠ࣅ͢Δɻ 2. R /

    G / BͦΕͧΕࢄཚ͞ΕΔޫͷ૬ର஋Λܭࢉ͢Δ 3. RGB஋ʹ্هͰٻΊͨ૬ର஋Λೖྗ͢Δ 4. ্هͱ୯೾௕ͷޫΛݟൺ΂͍͍ͯͩͨͷ೾௕ΛٻΊͯΈΔ
  4. ࠓճͷΞϓϩʔν 1. ଠཅޫͷR / G / BͷޫͷॏͶ߹Θͤͱͯۙ͠ࣅ͢Δɻ 2. R /

    G / BͦΕͧΕࢄཚ͞ΕΔޫͷ૬ର஋Λܭࢉ͢Δ 3. RGB஋ʹ্هͰٻΊͨ૬ର஋Λೖྗ͢Δ 4. ্هͱ୯೾௕ͷޫΛݟൺ΂͍͍ͯͩͨͷ೾௕ΛٻΊͯΈΔ
  5. ࠓճͷΞϓϩʔν 1. ଠཅޫͷR / G / BͷޫͷॏͶ߹Θͤͱͯۙ͠ࣅ͢Δɻ 2. R /

    G / BͦΕͧΕࢄཚ͞ΕΔޫͷ૬ର஋Λܭࢉ͢Δ 3. RGB஋ʹ্هͰٻΊͨ૬ର஋Λೖྗ͢Δ 4. ্هͱ୯೾௕ͷޫΛݟൺ΂͍͍ͯͩͨͷ೾௕ΛٻΊͯΈΔ
  6. ࠓճ͸૬ର஋͕΄͍͠ͷͰɺద౰ʹఆ਺Λ͔͚ͨ type Light struct { Wavelength in t Intensity in

    t } func scatteredLight(light Light) Light { return Light{light.Wavelength, light.Intensity << 40 / (light.Wavelength * light.Wavelength * light.Wavelength * light.Wavelength) } }
  7. ͜Μͳײ͡Ͱग़ྗͯ͠RGB஋Λऔಘ red := Light{700, 6 } green := Light{546, 7

    } blue := Light{436, 8 } fmt.Println("sky color!!" ) fmt.Println("red: ", scatteredLight(red) ) fmt.Println("green: ", scatteredLight(green) ) fmt.Println("blue: ", scatteredLight(blue))
  8. ͜Μͳײ͡Ͱग़ྗͯ͠RGB஋Λऔಘ red := Light{700, 6 } green := Light{546, 7

    } blue := Light{436, 8 } fmt.Println("sky color!!" ) fmt.Println("red: ", scatteredLight(red) ) fmt.Println("green: ", scatteredLight(green) ) fmt.Println("blue: ", scatteredLight(blue))
  9. ࠓճͷΞϓϩʔν 1. ଠཅޫͷR / G / BͷޫͷॏͶ߹Θͤͱͯۙ͠ࣅ͢Δɻ 2. R /

    G / BͦΕͧΕࢄཚ͞ΕΔޫͷ૬ର஋Λܭࢉ͢Δ 3. RGB஋ʹ্هͰٻΊͨ૬ର஋Λೖྗ͢Δ 4. ্هͱ୯೾௕ͷޫΛݟൺ΂͍͍ͯͩͨͷ೾௕ΛٻΊͯΈΔ
  10. ࠓճͷΞϓϩʔν 1. ଠཅޫͷR / G / BͷޫͷॏͶ߹Θͤͱͯۙ͠ࣅ͢Δɻ 2. R /

    G / BͦΕͧΕࢄཚ͞ΕΔޫͷ૬ର஋Λܭࢉ͢Δ 3. RGB஋ʹ্هͰٻΊͨ૬ର஋Λೖྗ͢Δ 4. ্هͱ୯೾௕ͷޫΛݟൺ΂͍͍ͯͩͨͷ೾௕ΛٻΊͯΈΔ