Struggling with accurate terminology; I've got a 3D app with triangulated terrain, where it looks like a checkerboard from the top view, where every cell is two tris, and every cell is equal size (1 sq unit). I'm storing the "unit circle" slope/scalar (?) for every triangle, two for each cell, so that I can index into a cell during runtime and lookup its slope, to see if the tri I'm over is flat enough to walk on, or if I should start sliding down the slope instead. For example, a triangle with a perfect 45 degree slope, has "0.707106" saved for the "slope" value, which was calculated via dot product of the tri's normal and a World Up vector.
What I need, is to somehow convert that slope scalar to a different scalar value which needs to represent a ratio of how much to slide forward if we hypothetically fell straight down into the ground because of gravity, based on that slope value. That's hard to explain, but for example:
- 0.707106 "slope" cell: 1 unit across, 1 units down... Needs to somehow convert to "1.0" (this first case is the perfect 45 degree slope. A value of "1.0" would mean, we translate downwards by the same exact amount we should translate forward, hence "1.0" ratio)
- 0.447213 "slope" cell: 1 unit across, 2 units down... Needs to somehow convert to "0.5" (this second case is a steeper slope, so assuming we are still falling down at the same speed, I only need to translate forward only half as much as I fell into the floor, hence 0.5)
- 0.316227 "slope" cell: 1 unit across, 3 units down... Needs to somehow convert to "0.3333"
Those were simplified examples, whereas the actual terrain is more randomized. The examples are also 2D, whereas the app is 3D. So, can I derive the ratio/scalar I'm looking for, from my "slope" dot product scalar? I've got the sliding/translating logic completed, but I'm just translating forward at the wrong rate, so I only need to understand how to properly find that missing ratio/scalar. Thank you