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

Basic 3D Math for ARKit

4f1a55d79f969b8a75f64ee4bd9a99c1?s=47 KBOY
September 15, 2018

Basic 3D Math for ARKit

4f1a55d79f969b8a75f64ee4bd9a99c1?s=128

KBOY

September 15, 2018
Tweet

Transcript

  1. Basic 3D Mathematics for ARKit Kei Fujikawa 2018.9.15@Tokyo iOS Meetup

  2. Who?

  3. Who?

  4. Why is ے೑?

  5.          

    Spajam 2nd Prized Best Body Japan Held ے೑.swift Showing in Article Smooth-sailing?
  6. Not so easy.

  7. A bunch of ے೑

  8. ے೑ 4FOHPLV1FSJPE

  9. AR!

  10. Question!

  11.          

    Spajam 2nd Prized Best Body Japan Held ے೑.swift Showing in Article
  12. I have to ride on this big wave.

  13. So,

  14. I joined AR startup this January

  15. Graffity Inc.

  16. Apps we’re making

  17. I studied ARKit for so much time

  18. Not so easy.

  19. Let’s think about this example.

  20. Place an airplane at the 30cm in front of screen’s

    touched point.
  21. None
  22. Looks way too easy

  23. Getting x,y from touch gesture and Z is 0.3?

  24. Finally

  25. None
  26. It does not show

  27. Ideal

  28. None
  29. Real

  30. None
  31. Not so easy

  32. So,

  33. I studied 3D programming.

  34. Books I read for study IUUQTBN[OUP.4V.F( IUUQTBN[OUP1,'Z5

  35. So,

  36. Today I will explain 3D Programming clearly.

  37. Basic 3D Mathematics for ARKit Kei Fujikawa 2018.9.15@Tokyo iOS Meetup

  38. Today’s goal

  39. Place an airplane at the 30cm in front of screen’s

    touched point.
  40. None
  41. We will study •Coordinate systems •Method for coordinate transformation

  42. Coordinate system for ARKit

  43. Coordinates World Object Camera Screen Drawn by iPad Pro

  44. World Coordinate system The biggest coordinates In your iPhone

  45. Object Coordinate system Airplane’s own coordinate

  46. Camera coordinate system ΧϝϥͷϩʔΧϧ࠲ඪ

  47. Camera

  48. Screen

  49. Screen

  50. Coordinates World Object Camera Screen Drawn by iPad Pro

  51. Let’s check the Goal

  52. Place an airplane at the 30cm in front of screen’s

    touched point.
  53. 30cm Get x,y from tap gesture Place the object In

    the world. Place at 30cm In front of camera Convert to world ᶃ ᶄ ᶅ Convert to Screen ᶆ ᶄ’ Convert to screen
  54. ᶃPlace at 30cm in front of camera Minus 30cm

  55. None
  56. ᶄConvert to World

  57. Convert from a coordinate to a coordinate

  58. ᶄ’Convert to screen

  59. World <-> Screen

  60. ᶅGet x,y from tap gesture

  61. ᶆPlace in the world

  62. Screen <-> World

  63. At 30cm Tapped position Convert Convert

  64. Calculate at easy coordinate system

  65. By the way

  66. You can do it all in the screen coordinate

  67. 30cm Get x,y from tap gesture Place the object In

    the world. Place at 30cm In front of camera Convert to world ᶃ ᶄ ᶅ Convert to Screen ᶆ ᶄ’ Convert to screen Removable
  68. Removabl

  69. It looks easier!!

  70. Yes

  71. You can code shorter

  72. None
  73. But

  74. 

  75. In fact

  76. This 0.996 is Same with 0.3m in camera coordinate

  77. What is 0.996?

  78. Review for coordinate system

  79. 0.0 1.0 Screen’s z 0.001m 1000m Camera’s z

  80. Screen’s Z

  81. https://developer.apple.com/documentation/scenekit/scnscenerenderer/1522631-unprojectpoint Z is 0.0~1.0

  82. Camera’s Z?

  83. None
  84. None
  85. None
  86. debug

  87. None
  88. Z is 0.01~1000

  89. Let’s change zNear.

  90. None
  91. 0.0 1.0 Screen’s z 0.001m 1000m Camera’s z

  92. Screen’s z vs Camera’s z

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

    n)cameraZ) -0.3 screenZ cameraZ
  94. 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...
  95. Way too hassle

  96. Removable?

  97. Must

  98. So,

  99. Understanding Coordinate’s system And..

  100. None
  101. Make sense?

  102. Let’s study more?

  103. Make a airplane Bigger or Rotation

  104. Scale

  105. Rotate by SCNVector4 Axis Degree

  106. Rotate by Euler angle

  107. Rotate by Euler angle x

  108. Rotate by Euler angle Y

  109. Rotate by Euler angle Z

  110. x Y Z

  111. That’s it

  112. One more thing.

  113. Making ARKit 2.0 repository

  114. End