{"id":844,"date":"2019-03-22T22:23:49","date_gmt":"2019-03-23T03:23:49","guid":{"rendered":"http:\/\/sunapi386.ca\/wordpress\/?p=844"},"modified":"2020-01-26T03:33:20","modified_gmt":"2020-01-26T08:33:20","slug":"space-filling-curves-vs-octree","status":"publish","type":"post","link":"https:\/\/sunapi386.ca\/wordpress\/space-filling-curves-vs-octree\/","title":{"rendered":"Space Filling Curves vs. Octree"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Octree<\/h2>\n\n\n\n<p>An\u00a0<strong>octree<\/strong> is a tree data structure in which each internal node has exactly eight children. Octrees are most often used to partition a three-dimensional space by recursively subdividing it into eight octants. Octrees are the three-dimensional analog of quadtrees.<\/p>\n\n\n\n<p>We humans mostly deal with low dimensional data, so we give this type of structure some names:<br><br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1-D data: binary tree<\/li><li>2-D data: quadtree<\/li><li>3-D data: octree<\/li><li>K-D data: <strong>k-d tree<\/strong>, or k-dimensional\u00a0<strong>tree<\/strong>, is a data structure used in computer science for organizing some number of points in a space with k dimensions.<\/li><\/ul>\n\n\n\n<p>These are all tree-like data structures, which are very useful for range and nearest neighbor searches.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/1uIuBlcjMAH-WhzYvl_iXwMPPTi4-Shz9OBYeK-SeAhMw-ptQ9lXF1y0550ELEZqyBeKvDIheD0jG4ui_M19m_W-26h-4BYRPAHTlLyaKRTTVB6RLUMiVskYFDWu_y7KYOy-jYsf\" alt=\"\"\/><figcaption>Octree example<br><br><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Space Filling Curves<\/strong><\/h2>\n\n\n\n<p><strong>Space filling curves<\/strong> refers to a <em>class of functions<\/em> that k dimensional data to 1 dimension. <\/p>\n\n\n\n<p>Meaning a class of functions that can map k-dimensional data into a single number n<\/p>\n\n\n\n<p style=\"text-align:center\"><em>f(n_1, n_2, &#8230;, n_k) -> n <\/em><\/p>\n\n\n\n<p>The caveat is there is a restriction on the number it maps, i.e. n_1, as space filling curves are a fractal functions, it cannot be extended to the reals, but rather to the binary fractions (a subset of the rationals). This lets you get arbitrarily close to any number you want (and cover all the IEEE floating points).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/h2AG8Mf4nkrjJC4M15_AO4Ghug4dRUNDngs4diLulvNU2_ubNlyvqLRe5gKJFnWXiovG_mVGQCe9iYUVQB6WqKdmE02lYJsuWVEdupE4AJkQW1PITkrQnLdf3_DvVrotDmIBeNrw\" alt=\"\"\/><figcaption>Class of functions means that there are many functions that can be considered a space filling curve. Common to use Hibert and Z-order.<br><br><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/tKLAndmJhaDHJXTOtsFakcv5fe3Z1Fh_mbyJ3dgSFaJy2zO918_fl4yjrR5BK8N8uUsh8v_vPOptZHSqlKQceGV1xuQUJkq3sdAdUZcPoVE_qcgu2eh7V_TQMoll72TP6IPd6O42\" alt=\"\"\/><figcaption>Visualization of a 3D space filling curve may look like with a Hilbert curve function.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Compare and contrast<\/h2>\n\n\n\n<p>There are certain optimal use cases for each of these. <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Trees have the benefit being able to limit the depth of your queries, which makes it especially useful in computer graphics so you can stop querying for points that you don&#8217;t need.<\/li><li>Space filling curves have the benefit of modify data faster, because the location to store that data can be calculated. Because trees have the cost of potentially rebalancing subtrees and creating\/updating\/deleting. <\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Other structures?<\/h2>\n\n\n\n<p>There are some variants on structures for storing multi-dimensional data.<\/p>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/R-tree\"><strong>R-Tree<\/strong><\/a><\/p>\n\n\n\n<p>It&#8217;s yet another type of tree.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/1m7HULfC39N-ZXcG1LM0UIEC18laSjcnoZDmi8dxD8UuyYerFoJtIlfbQvlv-xHHMOjU01NzTKL4qON8riV--HDgvhCkMcDf1lPj0pYgx8AQbOZSCgS7jExIaey1IF6aUXWnEg5N\" alt=\"\"\/><figcaption>Visualization of an R*-tree for 3D points using <a href=\"https:\/\/en.wikipedia.org\/wiki\/ELKI\">ELKI<\/a>.<a href=\"https:\/\/en.wikipedia.org\/wiki\/Hilbert_R-tree\">Hilbert R-Tree<\/a> is a variant on the R-Tree to achieve better performance. <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Data Stores<\/h2>\n\n\n\n<p>I won&#8217;t go in too much detail because this is out of scope, but in programming there are databases and data stores which can handle large amount of high dimensional data. <\/p>\n\n\n\n<p>First, a distinction. A <strong>database<\/strong> can handle complex queries. A <strong>data store<\/strong> can be dumber, simple storage format and won&#8217;t handle things like transaction for you. <\/p>\n\n\n\n<p>An analogy could be like &#8220;<strong>database<\/strong> is like an accountant, who you can ask for certain data and operations, such as &#8216;give me all last year&#8217;s data for people with last names in T'&#8221;, whereas &#8220;<strong>data store<\/strong> is like a library and you have to go find and collect that data yourself, but it&#8217;s stored in an organized fashion&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Octree An\u00a0octree is a tree data structure in which each internal node has exactly eight children. Octrees are most often used to partition a three-dimensional space by recursively subdividing it into eight octants. Octrees are the three-dimensional analog of quadtrees. We humans mostly deal with low dimensional data, so we give this type of structure &hellip; <a href=\"https:\/\/sunapi386.ca\/wordpress\/space-filling-curves-vs-octree\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Space Filling Curves vs. Octree<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[39,52,51,50,54,53],"class_list":["post-844","post","type-post","status-publish","format-standard","hentry","category-thoughts","tag-3d","tag-data-structure","tag-lidar","tag-mapping","tag-octree","tag-space-filling-curve"],"_links":{"self":[{"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/posts\/844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/comments?post=844"}],"version-history":[{"count":1,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"predecessor-version":[{"id":845,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/posts\/844\/revisions\/845"}],"wp:attachment":[{"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunapi386.ca\/wordpress\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}