WASD or Arrow keys
Finds the visual outlines of an orthogonally projected box. Wow its 5 AM. I can't be starting scratch projects past 12 like this... I first saw @finnagin5's "3D AABB Vertex Sorting" and it was cool but it seemed far too complicated for what it was meant to do. Here's the project: https://scratch.mit.edu/projects/1141247186/ I've actually previously thought about this problem, and thought it was kind of trivial to do, but didn't actually look very far into exactly what goes into the problem. The answer is symmetries. Symmetries, symmetries, symmetries. Although before I explain more, feel free to look into the project to learn for yourself as to how I solved the problem. It should be pretty easy to see kind of what goes on algorithmically. Feel free to ask me anything that you'd like to understand but is not clear from the code or my description. (yap warning ahaha) But as for the why, that's where mathematical symmetries come in to play. Or at least, that's how I think I can best describe the problem. Please understand that I'm not actually a mathematician or physicist, so I can only describe this to the best of my abilities as a math enjoyer. Before explaining how symmetries are utilized to solve the problem, I must mention that my first step was to find the near extent of an AABB. This is because the closest most point on an AABB is really just going to be a point that's not part of the edge. We don't want to render this. We'd wanna toss it. Luckily, determining this near point is trivial. Just take the vector where the camera is pointing and return another vector with same dimensions, but with signed components. A vector pointing in an entirely positive direction would just yield the number(coordinate), (1, 1, 1). It'd be (-1, -1, -1) if the direction vector was negative. Let's call this 3D sign the "key" vector. Multiplying the respective components of this key with the "extents" of the AABB returns the point that you don't want. Extents are simply the vector that dictates the expansion of an AABB from it's center. I believe I found this technique from the Quake videogame. This is where symmetries come into play. Negating the key vertex will flip the vertex to the opposite one, thanks to the symmetrical nature of the AABB. The opposite one happens to also be the exact other vertex that isn't part of an edge. In fact, it's occluded! I'd like to note that notably also, extents work the way they are cause yes, symmetry... but we can actually see it when taking the distance of every vertex to the center of an AABB. This distance will be the same for all of them. Negating dimensional components of a vertex vector will reveal a closed space where it'll just land on another vertex on the AABB. Anyways, Now we know which ones are edge vertices and which ones are not, trivially. The edges must be traversed in order to produce a convex hull. It seemed a bit difficult to me at first, but after drawing it I came to a quick realization that all I needed to do was take the key vertex and multiply it by the following sign vectors: (-1, 1, -1) (-1, 1, 1) (-1, -1, 1) (1, -1, 1) (1, -1 ,-1) (1, 1, -1) This yields the entire sorted chain of vertices that composes the projected 2D convex hull, thus, solving the problem! Ok time for me to sleep ahaha