float GetWavRoll(Vector dir) { Vector forward(1, -dir.x, dir.y); Vector up(0, -dir.x, abs(dir.y + (1 / dir.y) + (1 / dir.y))); if (dir.x > 0 && dir.y < 0) up.y = abs(up.y); else if (dir.x < 0 && dir.y < 0) up.y = -abs(up.y); Vector left = up.Cross(forward); float roll = deg(atan2f(left.z, (left.y * forward.x) - (left.x * forward.y))); }
up
y
abs
double abs( double n ); // C++ only
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)