I've got a question for all the math/trig geniuses.
I am attempting to achieve an accurate reflection of velocity when my pawn contacts a surface (angled surfaces included).
I am getting the normal of what i contact.
set the new velocity variables to use when getting the angle..
then I'm converting my velocity to an angle in radians, and then converting that to degrees(for testing)..
veloX = Velocity.X;
veloZ = Velocity.Z;
then multiplying the normal by 2 and subtracting the angle to get the new reflected angle and turn it back into a radian..
angleInRadians = atan2 (veloZ, veloX);
angleInDegrees = angleInRadians * 180 / PI;
I can not find a way to convert radians back into velocity.. so I am trying to get the new reflected velocity from the angle in degrees..
nAng = cNorm*2-angleInDegrees;
nRad = nAng*PI/180;
Finally I set the pawns velocity to equal the new reflected velocity.
V = Sqrt((veloX*veloX)+(veloZ*veloZ));
velocZ = Sqrt((V*V)-(veloX*veloX));
I am doing something wrong and often get sporadic results..if anyone sees where I am going astray please help by pointing it out or how I should go about doing it.