From c5096cf3f9163a3ba93a4f3be71d543154cc44f5 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 12 Aug 2024 14:57:58 +0700 Subject: [PATCH] triangulation-earclipping: Fix boolean --- content/Quadtree.org | 6 ++++++ triangulation-earclipping.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/content/Quadtree.org b/content/Quadtree.org index 04ae1b6..ba1f589 100644 --- a/content/Quadtree.org +++ b/content/Quadtree.org @@ -9,16 +9,22 @@ Several things can be created with this; ** Insertion :algorithm: ** Query :algorithm: ** Find Nearest Neighbor :algorithm: +** Morton codes +This is a technique that allows us to convert coordinates into an array index, +allowing us to pack them contiguously in memory +http://johnsietsma.com/2019/12/05/morton-order-introduction/ ** Resources [[http://ericandrewlewis.github.io/how-a-quadtree-works/][Visualize a Quadtree]] [[http://donar.umiacs.umd.edu/quadtree/][Academic Interactive Demo]] [[https://codepen.io/_bm/pen/ExPBMrW][Codepen (Js example)]] [[https://gist.github.com/patricksurry/6478178][D3.js Example]] ** Notes +#+begin_src js // exclude node if point is farther away than best distance in either axis if (x < x1 - best.d || x > x2 + best.d || y < y1 - best.d || y > y2 + best.d) { return best; } +#+end_src I don't know how to explain but I get it. Because of the euclidian distance and the fact that we're dealing with rectangles, the closest distance to a rectangle is a straight line in one of the x or y axis diff --git a/triangulation-earclipping.py b/triangulation-earclipping.py index d6e208a..aed22a0 100644 --- a/triangulation-earclipping.py +++ b/triangulation-earclipping.py @@ -117,7 +117,7 @@ def player_input(w: World): if RL.is_key_pressed(RL.KEY_SPACE): w.rotate_cam = not w.rotate_cam if RL.is_key_pressed(RL.KEY_W): - w.draw_wireframe = not w.draw_wireframe + w.draw_wireframe[0] = not w.draw_wireframe[0] def update(w: World): pass @@ -140,7 +140,7 @@ def draw_3d(w: World): RL.draw_model(w.model, RL.vector3_zero(), 1, RL.GREEN) def draw_2d(w: World): - val = RL.gui_check_box(Rect(10, 30, 50, 50), "Draw Wireframe", w.draw_wireframe) + val = RL.gui_check_box(Rect(10, 30, 25, 25), "Draw Wireframe", w.draw_wireframe) if val != 0: print(val) if val: