KBOY
September 15, 2018
490

# Basic 3D Math for ARKit

## KBOY

September 15, 2018

## 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. Looks way too easy

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

23. Finally

24. It does not show

25. Ideal

26. Real

27. Not so easy

28. So,

29. I studied
3D programming.

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

31. So,

32. Today
I will explain
3D Programming
clearly.

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

34. Today’s goal

35. Place an airplane
at the 30cm
in front of screen’s
touched point.

36. We will study
•Coordinate systems
•Method for coordinate
transformation

37. Coordinate system
for ARKit

38. Coordinates
World
Object
Camera
Screen
Drawn by iPad Pro

39. World Coordinate system
The biggest coordinates

40. Object Coordinate system
Airplane’s own
coordinate

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

42. Camera

43. Screen

44. Screen

45. Coordinates
World
Object
Camera
Screen
Drawn by iPad Pro

46. Let’s check the Goal

47. Place an airplane
at the 30cm
in front of screen’s
touched point.

48. 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

49. ᶃPlace at 30cm
in front of camera
Minus
30cm

50. ᶄConvert to World

51. Convert from
a coordinate
to
a coordinate

52. ᶄ’Convert to screen

53. World <-> Screen

54. ᶅGet x,y from tap gesture

55. ᶆPlace in the world

56. Screen <-> World

57. At 30cm
Tapped
position
Convert
Convert

58. Calculate at
easy coordinate system

59. By the way

60. You can do it all
in the screen coordinate

61. 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

62. Removabl

63. It looks easier!!

64. Yes

65. You can code shorter

66. But

67. In fact

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

69. What is 0.996?

70. Review for
coordinate system

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

72. Screen’s Z

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

74. Camera’s Z?

75. debug

76. Z is 0.01~1000

77. Let’s change zNear.

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

79. Screen’s z
vs
Camera’s z

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

81. 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...

82. Way too hassle

83. Removable?

84. Must

85. So,

86. Understanding
Coordinate’s system
And..

87. Make sense?

88. Let’s study more?

89. Make a airplane
Bigger or Rotation

90. Scale

91. Rotate by SCNVector4
Axis
Degree

92. Rotate by Euler angle

93. Rotate by Euler angle
x

94. Rotate by Euler angle
Y

95. Rotate by Euler angle
Z

96. x Y Z

97. That’s it

98. One more thing.

99. Making
ARKit 2.0 repository

100. End