Content: Add a note hierarchy

This commit is contained in:
Joseph Ferano 2024-08-06 12:29:41 +07:00
parent 2d7c38365d
commit aa1091c4d3
8 changed files with 167 additions and 0 deletions

10
Topics.org Normal file
View File

@ -0,0 +1,10 @@
#+TITLE Topics for Gaming Pads
* GAIMENPAAADS
* List of things to study
** Quadtrees (Ongoing)
** Triangulation
** Bezier Curves
** SIMD
** Multithreading
** Boids

19
content/GamingPads.org Normal file
View File

@ -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

6
content/Geometry.org Normal file
View File

@ -0,0 +1,6 @@
#+TODO: ⬜ 🟩️ | ✅
* Geometry
** [[file:SpatialPartitioning.org][Spatial Partitioning]]
** [[file:Triangulation.org][Triangulation]]
** Bezier Curves

8
content/KD-Tree.org Normal file
View File

@ -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:

1
content/Math.org Normal file
View File

@ -0,0 +1 @@
* Math

57
content/Quadtree.org Normal file
View File

@ -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

View File

@ -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

57
content/Triangulation.org Normal file
View File

@ -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