The direction is calculated (mostly) based on your current velocity, and whether the X or Y axis is stronger. This is then compared relative to your position to the grapple point, so whether you're on the left or right side, or top or bottom side. So if you have strong velocity to the right, and you're standing on the bottom left side, you will spin counterclockwise. But if you instead on the upper left side and grappled, you would now spin clockwise. And say you're in the upper left of the grapple, but you're also falling (so your Y velocity is stronger), then you would instead spin counterclockwise, because that's the path of least momentum canceling (which you want to pick, to make the physics feel plausible). So if you do come at a grapple at a weird diagonal with an evenly split velocity, the results might be unpredictable...
Sorry for this lengthy explanation lmao. Thank you for the kind comment!