diff --git a/Topics.org b/Topics.org new file mode 100644 index 0000000..ec078c9 --- /dev/null +++ b/Topics.org @@ -0,0 +1,10 @@ +#+TITLE Topics for Gaming Pads + +* GAIMENPAAADS +* List of things to study +** Quadtrees (Ongoing) +** Triangulation +** Bezier Curves +** SIMD +** Multithreading +** Boids diff --git a/content/GamingPads.org b/content/GamingPads.org new file mode 100644 index 0000000..2e6a074 --- /dev/null +++ b/content/GamingPads.org @@ -0,0 +1,19 @@ +* Gaming Pads +It's how the acronym GAIMENPAAADS sounds, but that's a crappy acronym. Here is +a hierarchical overview of the topics +** Math +*** Trigonometry +*** Data Structures +*** Algorithms +*** Linear Algebra +*** Geometry +**** Bezier Curves +**** Triangulation +**** Spatial Partitioning +#+transclude: [[file:Quadtree.org]] :level 5 :exclude-elements "keyword" +#+transclude: [[file:KD-Tree.org]] :level 5 :exclude-elements "keyword" +** Engineering +*** Machine Architecture +*** Networking +*** Compilers +*** Operating Systems diff --git a/content/Geometry.org b/content/Geometry.org new file mode 100644 index 0000000..17a4314 --- /dev/null +++ b/content/Geometry.org @@ -0,0 +1,6 @@ +#+TODO: âŦœ đŸŸŠī¸ | ✅ + +* Geometry +** [[file:SpatialPartitioning.org][Spatial Partitioning]] +** [[file:Triangulation.org][Triangulation]] +** Bezier Curves diff --git a/content/KD-Tree.org b/content/KD-Tree.org new file mode 100644 index 0000000..8b2d768 --- /dev/null +++ b/content/KD-Tree.org @@ -0,0 +1,8 @@ +#+NAVIGATION_UP: [[file:SpatialPartitioning.org][Spacial Partitioning]] + +* KD-Tree +Info about a KD-Tree +** Linked Implementation :datastructure: +** Array Implementation :datastructure: +** Insertion :algorithm: +** Find Nearest Neighbor :algorithm: diff --git a/content/Math.org b/content/Math.org new file mode 100644 index 0000000..c9da38a --- /dev/null +++ b/content/Math.org @@ -0,0 +1 @@ +* Math diff --git a/content/Quadtree.org b/content/Quadtree.org new file mode 100644 index 0000000..4c07050 --- /dev/null +++ b/content/Quadtree.org @@ -0,0 +1,57 @@ +#+TEST: [[file:SpatialPartitioning.org][Spacial Partitioning]] + +* Quadtree +Recursively subdivide an AABB into 4 regions, hence Quad. They are usually +denoted as North West, North East, South West, and South East (NW, NE, SW, SE). +Several things can be created with this; +** Linked Implementation :datastructure: +** Array Implementation :datastructure: +** Insertion :algorithm: +** Query :algorithm: +** Find Nearest Neighbor :algorithm: +** Resources +[[http://ericandrewlewis.github.io/how-a-quadtree-works/][Visualize a Quadtree]] +[[http://donar.umiacs.umd.edu/quadtree/][Academic Interactive Demo]] +** Notes +// 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; +} + + +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 +So if the point we're checking is farther away from the rectangle on either axis, then it cannot possible be the case that it is closer +I still can't visualize or understand it intuitively, I more just trust that it works, maybe if I see it in action it'll click better +JosephFerano + — +Today at 4:15 PM +This is some clever math shit this guy is doing +Or that he picked up +https://gist.github.com/patricksurry/6478178 +Gist +D3JS quadtree nearest neighbor algorithm +D3JS quadtree nearest neighbor algorithm. GitHub Gist: instantly share code, notes, and snippets. +D3JS quadtree nearest neighbor algorithm + + // check if kid is on the right or left, and top or bottom + // and then recurse on most likely kids first, so we quickly find a + // nearby point and then exclude many larger rectangles later + var kids = node.nodes; + var rl = (2*x > x1 + x2), bt = (2*y > y1 + y2); + if (kids[bt*2+rl]) best = nearest(x, y, best, kids[bt*2+rl]); + if (kids[bt*2+(1-rl)]) best = nearest(x, y, best, kids[bt*2+(1-rl)]); + if (kids[(1-bt)*2+rl]) best = nearest(x, y, best, kids[(1-bt)*2+rl]); + if (kids[(1-bt)*2+(1-rl)]) best = nearest(x, y, best, kids[(1-bt)*2+(1-rl)]); + +That's kinda neat, estimating probability with some math and then going into the index of the array where the point is more likely to be +No idea why this works +But I think I'm done with this +Interesting, he doesn't even check if any of the rects contain the point +Hmmm +Oh I see +It's because he's tracking whether a node is visited or not, and I'm putting in a lot of work to make sure you don't revisit the same node twice, but I don't do it with a "visited" bool, which I intentionally avoided but now seeing his solution, I realize it may have been a mistake +JosephFerano + — +Today at 4:27 PM +Actually I don't think adding "visited" is a good idea, because you have to walk through the whole thing again once you're done to uncheck all the visited bools. That's a linear walk through all the nodes, which might not be much, but it's certainly making things slower +I'll have to investigate further diff --git a/content/SpatialPartitioning.org b/content/SpatialPartitioning.org new file mode 100644 index 0000000..52c88e9 --- /dev/null +++ b/content/SpatialPartitioning.org @@ -0,0 +1,9 @@ +# -*- mode: Org; eval: (org-transclusion-mode 0) -*- # +#+NAVIGATION-UP: [[file:Geometry.org][Geometry]] + +* Spatial Partitioning +These are used to divide a space in either a 2D or 3D world into smaller spaces +that can make operations like searching and filtering more efficient. + +#+transclude: [[file:Quadtree.org]] :level 2 +#+transclude: [[file:KD-Tree.org]] :level 2 diff --git a/content/Triangulation.org b/content/Triangulation.org new file mode 100644 index 0000000..7148aa2 --- /dev/null +++ b/content/Triangulation.org @@ -0,0 +1,57 @@ +#+TEST: [[file:Geometry][Geometry]] + +* Quadtree +Recursively subdivide an AABB into 4 regions, hence Quad. They are usually +denoted as North West, North East, South West, and South East (NW, NE, SW, SE). +Several things can be created with this; +** Linked Implementation :datastructure: +** Array Implementation :datastructure: +** Insertion :algorithm: +** Query :algorithm: +** Find Nearest Neighbor :algorithm: +** Resources +[[http://ericandrewlewis.github.io/how-a-quadtree-works/][Visualize a Quadtree]] +[[http://donar.umiacs.umd.edu/quadtree/][Academic Interactive Demo]] +** Notes +// 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; +} + + +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 +So if the point we're checking is farther away from the rectangle on either axis, then it cannot possible be the case that it is closer +I still can't visualize or understand it intuitively, I more just trust that it works, maybe if I see it in action it'll click better +JosephFerano + — +Today at 4:15 PM +This is some clever math shit this guy is doing +Or that he picked up +https://gist.github.com/patricksurry/6478178 +Gist +D3JS quadtree nearest neighbor algorithm +D3JS quadtree nearest neighbor algorithm. GitHub Gist: instantly share code, notes, and snippets. +D3JS quadtree nearest neighbor algorithm + + // check if kid is on the right or left, and top or bottom + // and then recurse on most likely kids first, so we quickly find a + // nearby point and then exclude many larger rectangles later + var kids = node.nodes; + var rl = (2*x > x1 + x2), bt = (2*y > y1 + y2); + if (kids[bt*2+rl]) best = nearest(x, y, best, kids[bt*2+rl]); + if (kids[bt*2+(1-rl)]) best = nearest(x, y, best, kids[bt*2+(1-rl)]); + if (kids[(1-bt)*2+rl]) best = nearest(x, y, best, kids[(1-bt)*2+rl]); + if (kids[(1-bt)*2+(1-rl)]) best = nearest(x, y, best, kids[(1-bt)*2+(1-rl)]); + +That's kinda neat, estimating probability with some math and then going into the index of the array where the point is more likely to be +No idea why this works +But I think I'm done with this +Interesting, he doesn't even check if any of the rects contain the point +Hmmm +Oh I see +It's because he's tracking whether a node is visited or not, and I'm putting in a lot of work to make sure you don't revisit the same node twice, but I don't do it with a "visited" bool, which I intentionally avoided but now seeing his solution, I realize it may have been a mistake +JosephFerano + — +Today at 4:27 PM +Actually I don't think adding "visited" is a good idea, because you have to walk through the whole thing again once you're done to uncheck all the visited bools. That's a linear walk through all the nodes, which might not be much, but it's certainly making things slower +I'll have to investigate further