{"id":1694,"date":"2020-03-29T23:37:00","date_gmt":"2020-03-29T21:37:00","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=1694"},"modified":"2023-06-26T15:39:32","modified_gmt":"2023-06-26T13:39:32","slug":"arkit-measure-distances-with-augmented-reality","status":"publish","type":"post","link":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/","title":{"rendered":"ARKit &#8211; Measure distances with augmented reality"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Today a tutorial about <em>augmented reality<\/em>, in particular the use of the new <em>Apple framework<\/em>, <strong>ARKit<\/strong>, to measure distances <em>between two points<\/em> in a <em>3D virtual space<\/em>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"473\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=1024%2C473\" alt=\"\" class=\"wp-image-1729\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=1024%2C473 1024w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=300%2C139 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=768%2C355 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=1536%2C709 1536w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?resize=2048%2C946 2048w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">Final result: \u203926 cm distance between the two green points.<\/figcaption><\/figure>\n<\/div>\n\n\n<!--more-->\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-css-opacity has-vivid-red-background-color has-background\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How to?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First of all, as usual, you need to create a <em>new XCode project<\/em>. Select the &#8220;<strong>Augmented Reality App<\/strong>&#8221; type:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"682\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=1024%2C682\" alt=\"\" class=\"wp-image-1736\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=1024%2C682 1024w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=300%2C200 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=768%2C512 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=1536%2C1023 1536w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/Schermata-2020-03-06-alle-15.15.39.png?resize=2048%2C1364 2048w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Open your <strong>ViewController.swift <\/strong> and remove the useless stuff, like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">let scene = SCNScene(named: \"art.scnassets\/ship.scn\")!\nsceneView.scene = scene <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and all the <strong>ARSCNViewDelegate<\/strong> methods.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-css-opacity has-vivid-red-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Well, your code is now clear!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You need to add now two variables, an array of <strong>SCNNode<\/strong> (the dots) and another <strong>SCNNode<\/strong> that is the text displayed on the screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Second thing is to add the touch handler, in this case, <strong>touchedBegan<\/strong> in order to add points:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">var dotNodes = [SCNNode]()\nvar textNode = SCNNode()\n\noverride func <strong>touchesBegan<\/strong>(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) { } <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the <strong>touchBegan<\/strong>, you need to recognize the number of touches, and add the green dots:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">override func <strong>touchesBegan<\/strong>(_ touches: Set, with event: UIEvent?) {\n if dotNodes.count &gt;= 2 { <strong>resetDots<\/strong>() }\n\n if let touchLocation = touches.first?.location(in: sceneView) {\n      let hitTestResults = sceneView.hitTest(touchLocation, types: .featurePoint)\n      if let hitResult = hitTestResults.first {\n          <strong>addDot<\/strong>(at: hitResult)\n      }\n  }\n } <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your <strong>addDot<\/strong> function, append on the main AR scene a child node, the <strong>dot<\/strong>, based on the user touch location.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\"> func <strong>addDot<\/strong>( at hitResult: ARHitTestResult ) {\n     \/\/ the size of the green circle\n &nbsp; &nbsp; let dotGeometry = SCNSphere(radius: 0.005)\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; let material = SCNMaterial()\n &nbsp; &nbsp; material.diffuse.contents = UIColor.systemGreen\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; dotGeometry.materials = [material]\n\n     \/\/ the \"dot\" element\n &nbsp; &nbsp; let dotNode = <strong>SCNNode<\/strong>(geometry: dotGeometry)\n &nbsp; &nbsp; dotNode.position = SCNVector3(\n &nbsp; &nbsp; &nbsp; &nbsp; hitResult.worldTransform.columns.3.x,\n &nbsp; &nbsp; &nbsp; &nbsp; hitResult.worldTransform.columns.3.y,\n &nbsp; &nbsp; &nbsp; &nbsp; hitResult.worldTransform.columns.3.z)\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; sceneView.scene.rootNode.<strong>addChildNode<\/strong>(dotNode)\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; dotNodes.append(dotNode)\n\n     \/\/ we have 2 points on scree, try to calculate distance\n &nbsp; &nbsp; if dotNodes.count &gt;= 2 {\n &nbsp; &nbsp; &nbsp; &nbsp; <strong>calculateDistance<\/strong>()\n &nbsp; &nbsp; }\n } <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and last one, <strong>calculateDistance<\/strong> calculate distance between points:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\"> func <strong>calculateDistance<\/strong>() {\n &nbsp; &nbsp; let start = dotNodes.first!\n &nbsp; &nbsp; let end = dotNodes.last!\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; var distance = <strong>sqrt<\/strong>(\n &nbsp; &nbsp; &nbsp; &nbsp; pow(end.position.x - start.position.x, 2) +\n &nbsp; &nbsp; &nbsp; &nbsp; pow(end.position.y - start.position.y, 2) +\n &nbsp; &nbsp; &nbsp; &nbsp; pow(end.position.z - start.position.z, 2)\n &nbsp; &nbsp; )\n &nbsp;&nbsp; &nbsp;\n     \/\/ convert to cm\n &nbsp; &nbsp; distance *= 100\n \n &nbsp; &nbsp; let distanceFormatted = String(format: \"%.2f cm\", abs(distance))\n &nbsp; &nbsp; <strong>updateText<\/strong>(text: distanceFormatted, atPosition: end.position)\n } <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Cool! We have a distance now.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-css-opacity has-vivid-red-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">The last cool thing is to write text on screen. We use <strong>updateText<\/strong> to draw on screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The text on screen works in the same way as the dot. Is a <em>SCNode<\/em> added on the root scene.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">func <strong>updateText<\/strong>( text: String, atPosition: SCNVector3 ) {\n &nbsp; &nbsp; textNode.removeFromParentNode()\n \n &nbsp; &nbsp; let textGeometry = SCNText(string: text, extrusionDepth: 1.0)\n &nbsp; &nbsp; textGeometry.firstMaterial?.diffuse.contents = UIColor.systemRed\n &nbsp;&nbsp; &nbsp;\n &nbsp; &nbsp; textNode = <strong>SCNNode<\/strong>(geometry: textGeometry)\n &nbsp; &nbsp; textNode.position = SCNVector3(\n &nbsp; &nbsp; &nbsp; &nbsp; atPosition.x,\n &nbsp; &nbsp; &nbsp; &nbsp; atPosition.y + 0.01,\n &nbsp; &nbsp; &nbsp; &nbsp; atPosition.z\n &nbsp; &nbsp; )\n \n &nbsp; &nbsp; textNode.scale = SCNVector3(0.01, 0.01, 0.01)\n &nbsp; &nbsp; sceneView.scene.rootNode.<strong>addChildNode<\/strong>(textNode)\n } <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s all. It is very easy.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-red-color has-css-opacity has-vivid-red-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Clear all points<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">func <strong>resetDots<\/strong>() {\n &nbsp; &nbsp; for dot in dotNodes {\n &nbsp; &nbsp; &nbsp; &nbsp; dot.removeFromParentNode()\n &nbsp; &nbsp; }\n &nbsp; &nbsp; dotNodes = [SCNNode]()\n} <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As final result you should see something like this:<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video height=\"1920\" style=\"aspect-ratio: 886 \/ 1920;\" width=\"886\" controls src=\"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/RPReplay_Final1583503771-2.mov\"><\/video><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Enjoy measuring things!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today a tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[238,821,828,627,822,824,825,823,826,827],"class_list":["post-1694","post","type-post","status-publish","format-standard","hentry","category-generic","tag-3d","tag-arkit","tag-augmented-reality","tag-distance","tag-measure","tag-points","tag-scnmaterial","tag-scnnode","tag-scnsphere","tag-touchesbegan"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ARKit - Measure distances with augmented reality - while (true) {\u00a0}<\/title>\n<meta name=\"description\" content=\"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ARKit - Measure distances with augmented reality - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-29T21:37:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-26T13:39:32+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276-1024x473.png\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"ARKit &#8211; Measure distances with augmented reality\",\"datePublished\":\"2020-03-29T21:37:00+00:00\",\"dateModified\":\"2023-06-26T13:39:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/\"},\"wordCount\":235,\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/IMG_1276-1024x473.png\",\"keywords\":[\"3d\",\"arkit\",\"augmented reality\",\"distance\",\"measure\",\"points\",\"scnmaterial\",\"scnnode\",\"scnsphere\",\"touchesBegan\"],\"articleSection\":[\"generic\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/\",\"name\":\"ARKit - Measure distances with augmented reality - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/IMG_1276-1024x473.png\",\"datePublished\":\"2020-03-29T21:37:00+00:00\",\"dateModified\":\"2023-06-26T13:39:32+00:00\",\"description\":\"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/IMG_1276.png?fit=2436%2C1125\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/IMG_1276.png?fit=2436%2C1125\",\"width\":2436,\"height\":1125},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arkit-measure-distances-with-augmented-reality\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ARKit &#8211; Measure distances with augmented reality\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ARKit - Measure distances with augmented reality - while (true) {\u00a0}","description":"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/","og_locale":"en_US","og_type":"article","og_title":"ARKit - Measure distances with augmented reality - while (true) {\u00a0}","og_description":"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.","og_url":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2020-03-29T21:37:00+00:00","article_modified_time":"2023-06-26T13:39:32+00:00","og_image":[{"url":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276-1024x473.png","type":"","width":"","height":""}],"author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#article","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/"},"author":{"name":"Alberto Pasca","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"ARKit &#8211; Measure distances with augmented reality","datePublished":"2020-03-29T21:37:00+00:00","dateModified":"2023-06-26T13:39:32+00:00","mainEntityOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/"},"wordCount":235,"publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276-1024x473.png","keywords":["3d","arkit","augmented reality","distance","measure","points","scnmaterial","scnnode","scnsphere","touchesBegan"],"articleSection":["generic"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/","url":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/","name":"ARKit - Measure distances with augmented reality - while (true) {\u00a0}","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#primaryimage"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276-1024x473.png","datePublished":"2020-03-29T21:37:00+00:00","dateModified":"2023-06-26T13:39:32+00:00","description":"A tutorial about augmented reality, in particular the use of the new Apple framework, ARKit, to measure distances between two points in a 3D virtual space.","breadcrumb":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#primaryimage","url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?fit=2436%2C1125","contentUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2020\/03\/IMG_1276.png?fit=2436%2C1125","width":2436,"height":1125},{"@type":"BreadcrumbList","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arkit-measure-distances-with-augmented-reality\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"ARKit &#8211; Measure distances with augmented reality"}]},{"@type":"WebSite","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website","url":"https:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=1694"}],"version-history":[{"count":68,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1694\/revisions"}],"predecessor-version":[{"id":3359,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1694\/revisions\/3359"}],"wp:attachment":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=1694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=1694"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=1694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}