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

ARKitのための3D算数

KBOY
August 30, 2018

 ARKitのための3D算数

iOSDC 2018

KBOY

August 30, 2018
Tweet

More Decks by KBOY

Other Decks in Programming

Transcript

  1. ARKitͷͨΊͷ
    3Dࢉ਺
    KBOY@ے೑ΤϯδχΞ
    2018.8.30@iOSDC 2018

    View full-size slide

  2. ࣗݾ঺հ
    ૣҴా͕฼ߍͰ͢

    View full-size slide

  3. ے೑ΤϯδχΞͷܦྺ

    View full-size slide






  4. ೥݄ ݄ ݄ ೥݄ ೥݄
    Spajam༏ल৆
    ϕετϘσΟδϟύϯग़৔
    ے೑.swift։࠵
    స৬υϥϑτग़ԋ
    ॱ෩ຬൕʂʁ

    View full-size slide

  5. ͔ͦ͠͠͏؁͘͸ͳ͍

    View full-size slide

  6. ے೑ΤϯδχΞͷ୆಄

    View full-size slide

  7. ے೑ΤϯδχΞ
    ઓࠃ࣌୅

    View full-size slide

  8. ͦ͏ͩʂARͩʂ

    View full-size slide






  9. ೥݄ ݄ ݄ ೥݄ ೥݄
    Spajam༏ल৆
    ϕετϘσΟδϟύϯग़৔
    స৬υϥϑτग़ԋ
    ے೑.swift։࠵

    View full-size slide

  10. ৐Δ͔͠ͳ͍
    ͜ͷϏοά΢Σʔϒʹ

    View full-size slide

  11. ͱ͍͏͜ͱͰ

    View full-size slide

  12. ࠓ೥1݄ʹ
    ARελʔτΞοϓ΁JOIN

    View full-size slide

  13. Graffity Inc.
    Ϧʔμʔ

    View full-size slide

  14. ͜ΜͳΞϓϦ࡞ͬͯ·͢

    View full-size slide

  15. ͱ͍͏͜ͱͰARKitΛ
    ؤுͬͯษڧ͠·ͨ͠

    View full-size slide

  16. ͔͠͠
    ͦ͏؁͘͸ͳ͍

    View full-size slide

  17. ͜͏͍͏ྫΛ
    ߟ͑ͯΈ·͠ΐ͏

    View full-size slide

  18. εΫϦʔϯ্ͷλοϓͨ͠෦෼ͷ
    30cmલʹ
    ඈߦػΛஔ͘

    View full-size slide

  19. ༨༟ͬ͠ΐʂ

    View full-size slide

  20. λοϓδΣενϟʔ͔Β
    x, yΛऔಘ,
    z͸0.3mΛೖΕΕ͹׬੒ʂ

    View full-size slide

  21. શવग़ͯ͜ͳ͍…

    View full-size slide

  22. ΍ͬͺΓ
    ͦ͏؁͘͸ͳ͍

    View full-size slide

  23. ͦΜͳ࣌ɺϦʔμʔ͕
    खΛࠩ͠৳΂ͯ͘Εͨ

    View full-size slide

  24. 3DϓϩάϥϛϯάΛ
    ษڧ͢Ε͹༨༟ͩΑ

    View full-size slide

  25. Ϧʔμʔʂʂ

    View full-size slide

  26. 3Dϓϩάϥϛϯά
    Λษڧͨ͠ɻ

    View full-size slide

  27. ษڧʹ࢖ͬͨຊ
    IUUQTBN[OUP.4V.F( IUUQTBN[OUP1,'Z5

    View full-size slide

  28. ͱ͍͏͜ͱͰ

    View full-size slide

  29. ࠓ೔͸օ͞Μʹ
    Θ͔Γ΍͘͢
    3DϓϩάϥϛϯάΛ
    આ໌͠·͢

    View full-size slide

  30. ARKitͷͨΊͷ
    3Dࢉ਺
    KBOY@ے೑ΤϯδχΞ
    2018.8.30@iOSDC 2018

    View full-size slide

  31. ࠓ೔ͷΰʔϧ

    View full-size slide

  32. εΫϦʔϯ্ͷλοϓͨ͠෦෼ͷ
    30cmલʹ
    ඈߦػΛஔ͘

    View full-size slide

  33. ษڧ͢Δ͜ͱ
    •࠲ඪܥΛ஌Δ
    •࠲ඪม׵ͷϝιουΛ஌Δ

    View full-size slide

  34. ARKitͰ࢖͏࠲ඪܥ

    View full-size slide

  35. ࠲ඪ·ͱΊ
    ϫʔϧυ࠲ඪܥ
    ΦϒδΣΫτ࠲ඪܥ
    Χϝϥ࠲ඪܥ
    εΫϦʔϯ࠲ඪܥ
    iPad ProͰॻ͖·ͨ͠ɻ

    View full-size slide

  36. ϫʔϧυ࠲ඪܥ
    ͜ΕΑΓେ͖ͳ֎ଆͷ
    ࠲ඪۭؒͰදݱͰ͖ͳ͍

    View full-size slide

  37. ΦϒδΣΫτ࠲ඪܥ
    ඈߦػࣗ਎ͷϩʔΧϧ࠲ඪʂ

    View full-size slide

  38. Χϝϥ࠲ඪܥ
    ΧϝϥͷϩʔΧϧ࠲ඪ

    View full-size slide

  39. Χϝϥ࠲ඪܥ

    View full-size slide

  40. εΫϦʔϯ࠲ඪܥ

    View full-size slide

  41. εΫϦʔϯ࠲ඪܥ

    View full-size slide

  42. ࠲ඪ·ͱΊ
    ϫʔϧυ࠲ඪܥ
    ΦϒδΣΫτ࠲ඪܥ
    Χϝϥ࠲ඪܥ
    εΫϦʔϯ࠲ඪܥ
    iPad ProͰॻ͖·ͨ͠ɻ

    View full-size slide

  43. ΰʔϧͷ֬ೝ

    View full-size slide

  44. εΫϦʔϯ্ͷλοϓͨ͠෦෼ͷ
    30cmલʹ
    ඈߦػΛஔ͘

    View full-size slide

  45. 30cm
    εΫϦʔϯλοϓͷ
    xy࠲ඪऔಘ
    ϫʔϧυ࠲ඪʹม׵ͯ͠
    ͦ͜ʹஔ͘ʂ
    Χϝϥͷ30cmલʹஔ͘
    ϫʔϧυ࠲ඪʹม׵
    ᶃ ᶄ

    εΫϦʔϯ࠲ඪʹม׵

    ᶄ’
    εΫϦʔϯ࠲ඪʹม׵

    View full-size slide

  46. ᶃΧϝϥ࠲ඪͰ30cmલʹஔ͘
    ϚΠφε
    30cm

    View full-size slide

  47. ᶄϫʔϧυ࠲ඪʹม׵

    View full-size slide

  48. ͋Δ࠲ඪܥ͔Β
    ͋Δ࠲ඪܥ΁
    ม׵Ͱ͖Δ

    View full-size slide

  49. ᶄ’εΫϦʔϯ࠲ඪʹม׵

    View full-size slide

  50. ϫʔϧυ࠲ඪܥ→εΫϦʔϯ࠲ඪܥ

    View full-size slide

  51. ᶅεΫϦʔϯλοϓͷxy࠲ඪऔಘ

    View full-size slide

  52. ᶆϫʔϧυ࠲ඪʹม׵ͯ͠ஔ͘

    View full-size slide

  53. εΫϦʔϯ࠲ඪܥ→ϫʔϧυ࠲ඪܥ

    View full-size slide

  54. 30cmલ
    λοϓͨ͠Ґஔ
    ม׵
    ม׵

    View full-size slide

  55. ͦΕͧΕɺ౎߹ͷ͍͍
    ࠲ඪܥͰܭࢉ͢Δ

    View full-size slide

  56. εΫϦʔϯ࠲ඪܥ͚ͩ
    Ͱ΋શͯΛදݱͰ͖Δ

    View full-size slide

  57. εΫϦʔϯλοϓͷ
    xy࠲ඪऔಘ
    ϫʔϧυ࠲ඪʹม׵ͯ͠
    ͦ͜ʹஔ͘ʂ
    Χϝϥͷ30cmલʹஔ͘
    ϫʔϧυ࠲ඪʹม׵
    ᶃ ᶄ

    εΫϦʔϯ࠲ඪʹม׵

    ᶄ’
    εΫϦʔϯ࠲ඪʹม׵
    ͜͜ল͚Δ
    30cm

    View full-size slide

  58. ͬͪ͜ͷํָ͕͡ΌΜʂ

    View full-size slide

  59. ͜ͷ୹͍ίʔυͰߦ͚Δ

    View full-size slide

  60. ͜ͷ0.996͸
    Χϝϥ࠲ඪܥͷ0.3mͱ
    ಉ͡ҙຯ

    View full-size slide

  61. ͜͜Ͱ࠲ඪܥͷ෮श

    View full-size slide

  62. 0.0
    1.0
    εΫϦʔϯ࠲ඪܥͷ
    z
    0.001m
    1000m
    Χϝϥ࠲ඪܥͷ
    z

    View full-size slide

  63. εΫϦʔϯ࠲ඪܥͷz

    View full-size slide

  64. https://developer.apple.com/documentation/scenekit/scnscenerenderer/1522631-unprojectpoint
    εΫϦʔϯ࠲ඪܥͷ
    z͸0.0~1.0

    View full-size slide

  65. Χϝϥ࠲ඪܥͷz͸ʁ

    View full-size slide

  66. debugͯ͠ΈΔͱ

    View full-size slide

  67. zNearΛ
    มԽͤͯ͞ΈΑ͏

    View full-size slide

  68. 0.0
    1.0
    εΫϦʔϯ࠲ඪܥͷ
    z
    0.001m
    1000m
    Χϝϥ࠲ඪܥͷ
    z

    View full-size slide

  69. εΫϦʔϯ࠲ඪͷz
    vs
    Χϝϥ࠲ඪͷz

    View full-size slide

  70. http://www.alecjacobson.com/weblog/?p=3835
    -0.001
    -1000
    0.996
    screenZ = f(n + cameraZ)/((f − n)cameraZ)
    -0.3
    screenZ
    cameraZ

    View full-size slide

  71. screenZ = f(n + cameraZ)/((f − n)cameraZ)
    screenZ = 1000(0.001 + (−0.3))/((1000 − 0.002)(−0.3))
    f = 1000
    n = 0.001
    cameraZ = − 0.3
    screenZ = 0.9966...

    View full-size slide

  72. ࣮ʹ໘౗͍͘͞

    View full-size slide

  73. ͜͜ল͚Δʂʁ

    View full-size slide

  74. ͱ͍͏͜ͱͰ

    View full-size slide

  75. ࠲ඪม׵Λۦ࢖ͯ͠

    View full-size slide

  76. ΋͏ͪΐ͍΍ͬͯΈ·͠ΐ͏ʂ

    View full-size slide

  77. ඈߦػΛ֦େͨ͠Γɺ
    ճసͤ͞Α͏ʂ

    View full-size slide

  78. ֦େɾॖখ

    View full-size slide

  79. ճస (SCNVector4)

    ֯౓

    View full-size slide

  80. ճస(Euler angle)

    View full-size slide

  81. ճస (Euler angle)
    x

    View full-size slide

  82. ճస (Euler angle)
    Y

    View full-size slide

  83. ճస (Euler angle)
    Z

    View full-size slide

  84. ͜͜·Ͱ͕ࢉ਺

    View full-size slide

  85. ·ͩ਺ֶ͕͋Γ·͢ɻ

    View full-size slide

  86. ࠲ඪͷ֓೦Λཧղͯ͠
    SceneKit΍ARKitΛ
    ࢖͍͜ͳͤΕ͹ྑ͍ɻ

    View full-size slide

  87. ਺ֶʹ͍ͭͯ͸QiitaͰɻ

    View full-size slide

  88. ARKitͷͨΊͷ
    3D
    ਺ֶ

    View full-size slide

  89. Graffity Inc.
    ΤϯδχΞืूதʂ

    View full-size slide

  90. ݸਓͰARKitͷಈըڭࡐ࡞੒த

    View full-size slide

  91. One More Thing

    View full-size slide

  92. ࠓ೥΋΍Γ·͢
    .kt

    View full-size slide

  93. ے೑.kt
    w :BIPP-PEHF
    w ೥݄೔

    View full-size slide