Demo controls:
- the outer boxes can be dragged, they are based on dragdots
- the numbers you see tell you what happens at the cell of the center box, there are also red indicators of the detected border collision coordinates
- the numbers are: the sides that are hit, whether or not the cell is flipped, and on the next line: the rounded hit position of each side
How it works:
- it calculates the intersections between the input vector and the border of the cell
- the input vector will be treated as a line defined as Y=AXX+B and as X=CYY+D (the program uses different variable names), where A,B,C,D are generated line constants, XX and YY are the coordinates of each rib of the cell (box) (a box is made up of vertical and horizontal lines that can be defined as X=constant or Y=constant)
- it rounds them to be either 0 (nothing), 1 (half), or 2 (full)
- it detects whether or not it needs to be flipped
- it finds a character that meets the descriptions
this can be used together with vector alignment for vector collision
by the way the vector alignment program is full of vector subprograms like:
"mag" (aka length), "unit_vector" (aka normalize), and "polar" (aka ATAN2)